RenderDcompSurfaceTextureHost.h (2430B)
1 /* -*- Mode: C++; tab-width: ; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #ifndef MOZILLA_GFX_RENDERDCOMPSURFACETEXTUREHOST_H 7 #define MOZILLA_GFX_RENDERDCOMPSURFACETEXTUREHOST_H 8 9 #include "GLTypes.h" 10 #include "RenderTextureHostSWGL.h" 11 #include "mozilla/webrender/RenderThread.h" 12 13 struct IDCompositionDevice; 14 struct IDCompositionSurface; 15 16 inline mozilla::LazyLogModule gDcompSurface("DcompSurface"); 17 18 namespace mozilla::wr { 19 20 /** 21 * A render texture host is responsible to create a dcomp surface from an 22 * existing dcomp handle. Currently usage is that MF media engine will create 23 * a surface handle from another remote process, and we reconstruct the surface 24 * and use it in the DCLayerTree in the GPU process. 25 */ 26 class RenderDcompSurfaceTextureHost final : public RenderTextureHostSWGL { 27 public: 28 RenderDcompSurfaceTextureHost(HANDLE aHandle, gfx::IntSize aSize, 29 gfx::SurfaceFormat aFormat); 30 31 // RenderTextureHost 32 RenderDcompSurfaceTextureHost* AsRenderDcompSurfaceTextureHost() override { 33 return this; 34 } 35 36 // RenderTextureHostSWGL 37 gfx::SurfaceFormat GetFormat() const override { return mFormat; } 38 gfx::ColorDepth GetColorDepth() const override { 39 return gfx::ColorDepth::COLOR_8; 40 } 41 size_t GetPlaneCount() const override { return 1; } 42 bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex, 43 PlaneInfo& aPlaneInfo) override { 44 return false; 45 } 46 void UnmapPlanes() override {} 47 gfx::YUVRangedColorSpace GetYUVColorSpace() const override { 48 return gfx::YUVRangedColorSpace::GbrIdentity; 49 } 50 size_t Bytes() override { return 0; } 51 52 gfx::IntSize GetSize() const { return mSize; }; 53 54 HANDLE GetDcompSurfaceHandle() const { return mHandle; } 55 56 // Not thread-safe. They should only be called on the renderer thread on the 57 // GPU process. 58 IDCompositionSurface* CreateSurfaceFromDevice(IDCompositionDevice* aDevice); 59 IDCompositionSurface* GetSurface() const { return mDcompSurface; }; 60 61 private: 62 const HANDLE mHandle; 63 const gfx::IntSize mSize; 64 const gfx::SurfaceFormat mFormat; 65 RefPtr<IDCompositionSurface> mDcompSurface; 66 }; 67 68 } // namespace mozilla::wr 69 70 #endif // MOZILLA_GFX_RENDERDCOMPSURFACETEXTUREHOST_H