MacIOSurfaceTextureHostOGL.h (2856B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_H 8 #define MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_H 9 10 #include "MacIOSurfaceHelpers.h" 11 #include "mozilla/gfx/2D.h" 12 #include "mozilla/layers/CompositorOGL.h" 13 #include "mozilla/layers/TextureHostOGL.h" 14 15 class MacIOSurface; 16 17 namespace mozilla { 18 namespace layers { 19 20 class GpuFence; 21 22 /** 23 * A TextureHost for shared MacIOSurface 24 * 25 * Most of the logic actually happens in MacIOSurfaceTextureSourceOGL. 26 */ 27 class MacIOSurfaceTextureHostOGL : public TextureHost { 28 public: 29 MacIOSurfaceTextureHostOGL(TextureFlags aFlags, 30 const SurfaceDescriptorMacIOSurface& aDescriptor); 31 virtual ~MacIOSurfaceTextureHostOGL(); 32 33 // MacIOSurfaceTextureSourceOGL doesn't own any GL texture 34 void DeallocateDeviceData() override {} 35 36 gfx::SurfaceFormat GetFormat() const override; 37 gfx::SurfaceFormat GetReadFormat() const override; 38 39 already_AddRefed<gfx::DataSourceSurface> GetAsSurface( 40 gfx::DataSourceSurface* aSurface) override { 41 RefPtr<gfx::SourceSurface> surf = 42 CreateSourceSurfaceFromMacIOSurface(GetMacIOSurface(), aSurface); 43 return surf->GetDataSurface(); 44 } 45 46 gl::GLContext* gl() const; 47 48 gfx::IntSize GetSize() const override; 49 50 #ifdef MOZ_LAYERS_HAVE_LOG 51 const char* Name() override { return "MacIOSurfaceTextureHostOGL"; } 52 #endif 53 54 MacIOSurfaceTextureHostOGL* AsMacIOSurfaceTextureHost() override { 55 return this; 56 } 57 58 MacIOSurface* GetMacIOSurface() override { return mSurface; } 59 60 void CreateRenderTexture( 61 const wr::ExternalImageId& aExternalImageId) override; 62 63 uint32_t NumSubTextures() override; 64 65 void PushResourceUpdates(wr::TransactionBuilder& aResources, 66 ResourceUpdateOp aOp, 67 const Range<wr::ImageKey>& aImageKeys, 68 const wr::ExternalImageId& aExtID) override; 69 70 void PushDisplayItems(wr::DisplayListBuilder& aBuilder, 71 const wr::LayoutRect& aBounds, 72 const wr::LayoutRect& aClip, wr::ImageRendering aFilter, 73 const Range<wr::ImageKey>& aImageKeys, 74 PushDisplayItemFlagSet aFlags) override; 75 76 gfx::YUVColorSpace GetYUVColorSpace() const override; 77 gfx::ColorRange GetColorRange() const override; 78 79 const RefPtr<MacIOSurface> mSurface; 80 const RefPtr<GpuFence> mGpuFence; 81 82 protected: 83 RefPtr<GLTextureSource> mTextureSource; 84 }; 85 86 } // namespace layers 87 } // namespace mozilla 88 89 #endif // MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_H