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/. */
6 #ifndef MOZILLA_GFX_RENDERDCOMPSURFACETEXTUREHOST_H
7 #define MOZILLA_GFX_RENDERDCOMPSURFACETEXTUREHOST_H
10 #include "RenderTextureHostSWGL.h"
11 #include "mozilla/webrender/RenderThread.h"
13 struct IDCompositionDevice
;
14 struct IDCompositionSurface
;
16 inline mozilla::LazyLogModule
gDcompSurface("DcompSurface");
18 namespace mozilla::wr
{
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.
26 class RenderDcompSurfaceTextureHost final
: public RenderTextureHostSWGL
{
28 RenderDcompSurfaceTextureHost(HANDLE aHandle
, gfx::IntSize aSize
,
29 gfx::SurfaceFormat aFormat
);
32 RenderDcompSurfaceTextureHost
* AsRenderDcompSurfaceTextureHost() override
{
36 // RenderTextureHostSWGL
37 gfx::SurfaceFormat
GetFormat() const override
{ return mFormat
; }
38 gfx::ColorDepth
GetColorDepth() const override
{
39 return gfx::ColorDepth::COLOR_8
;
41 size_t GetPlaneCount() const override
{ return 1; }
42 bool MapPlane(RenderCompositor
* aCompositor
, uint8_t aChannelIndex
,
43 PlaneInfo
& aPlaneInfo
) override
{
46 void UnmapPlanes() override
{}
47 gfx::YUVRangedColorSpace
GetYUVColorSpace() const override
{
48 return gfx::YUVRangedColorSpace::GbrIdentity
;
50 size_t Bytes() override
{ return 0; }
52 gfx::IntSize
GetSize() const { return mSize
; };
54 HANDLE
GetDcompSurfaceHandle() const { return mHandle
; }
56 // Not thread-safe. They should only be called on the renderer thread on the
58 IDCompositionSurface
* CreateSurfaceFromDevice(IDCompositionDevice
* aDevice
);
59 IDCompositionSurface
* GetSurface() const { return mDcompSurface
; };
63 const gfx::IntSize mSize
;
64 const gfx::SurfaceFormat mFormat
;
65 RefPtr
<IDCompositionSurface
> mDcompSurface
;
68 } // namespace mozilla::wr
70 #endif // MOZILLA_GFX_RENDERDCOMPSURFACETEXTUREHOST_H