RenderMacIOSurfaceTextureHost.h (2048B)
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_RENDERMACIOSURFACETEXTUREHOST_H 8 #define MOZILLA_GFX_RENDERMACIOSURFACETEXTUREHOST_H 9 10 #include "mozilla/gfx/MacIOSurface.h" 11 #include "mozilla/layers/TextureHostOGL.h" 12 #include "RenderTextureHostSWGL.h" 13 14 namespace mozilla { 15 16 namespace layers { 17 class GpuFence; 18 class SurfaceDescriptorMacIOSurface; 19 } // namespace layers 20 21 namespace wr { 22 23 class RenderMacIOSurfaceTextureHost final : public RenderTextureHostSWGL { 24 public: 25 explicit RenderMacIOSurfaceTextureHost(MacIOSurface* aSurface, 26 layers::GpuFence* aGpuFence); 27 28 wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL) override; 29 void Unlock() override; 30 31 gfx::IntSize GetSize(uint8_t aChannelIndex) const; 32 GLuint GetGLHandle(uint8_t aChannelIndex) const; 33 34 RenderMacIOSurfaceTextureHost* AsRenderMacIOSurfaceTextureHost() override { 35 return this; 36 } 37 38 size_t Bytes() override; 39 40 MacIOSurface* GetSurface() { return mSurface; } 41 42 // RenderTextureHostSWGL 43 size_t GetPlaneCount() const override; 44 gfx::SurfaceFormat GetFormat() const override; 45 gfx::ColorDepth GetColorDepth() const override; 46 gfx::YUVRangedColorSpace GetYUVColorSpace() const override; 47 bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex, 48 PlaneInfo& aPlaneInfo) override; 49 void UnmapPlanes() override; 50 51 layers::GpuFence* GetGpuFence() { return mGpuFence; } 52 53 private: 54 virtual ~RenderMacIOSurfaceTextureHost(); 55 void DeleteTextureHandle(); 56 57 RefPtr<MacIOSurface> mSurface; 58 RefPtr<layers::GpuFence> mGpuFence; 59 RefPtr<gl::GLContext> mGL; 60 GLuint mTextureHandles[3]; 61 }; 62 63 } // namespace wr 64 } // namespace mozilla 65 66 #endif // MOZILLA_GFX_RENDERMACIOSURFACETEXTUREHOST_H