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/. */
7 #ifndef MOZILLA_GFX_RENDERTEXTUREHOSTSWGL_H
8 #define MOZILLA_GFX_RENDERTEXTUREHOSTSWGL_H
11 #include "RenderTextureHost.h"
16 class RenderTextureHostSWGL
: public RenderTextureHost
{
18 RenderTextureHostSWGL() {}
20 wr::WrExternalImage
LockSWGL(uint8_t aChannelIndex
, void* aContext
,
21 RenderCompositor
* aCompositor
,
22 wr::ImageRendering aRendering
) override
;
24 void UnlockSWGL() override
;
26 RenderTextureHostSWGL
* AsRenderTextureHostSWGL() override
{ return this; }
28 virtual size_t GetPlaneCount() const = 0;
30 virtual gfx::SurfaceFormat
GetFormat() const = 0;
32 virtual gfx::ColorDepth
GetColorDepth() const {
33 return gfx::ColorDepth::UNKNOWN
;
36 virtual gfx::YUVColorSpace
GetYUVColorSpace() const {
37 return gfx::YUVColorSpace::UNKNOWN
;
41 explicit PlaneInfo(GLuint aTexture
) : mTexture(aTexture
) {}
44 void* mData
= nullptr;
49 virtual bool MapPlane(RenderCompositor
* aCompositor
, uint8_t aChannelIndex
,
50 PlaneInfo
& aPlaneInfo
) = 0;
52 virtual void UnmapPlanes() = 0;
54 // Lock this texture host as an attached external image for a SWGL compositor
55 // surface. See swgl_bindings.rs for a description of the resulting
56 // WrSWGLCompositeSurfaceInfo. This is paired with a call to UnlockSWGL when
57 // composition is done.
58 bool LockSWGLCompositeSurface(void* aContext
,
59 wr::WrSWGLCompositeSurfaceInfo
* aInfo
);
61 size_t Bytes() override
{
63 for (auto &plane
: mPlanes
) {
64 bytes
+= plane
.mStride
* plane
.mSize
.height
;
70 void* mContext
= nullptr;
71 std::vector
<PlaneInfo
> mPlanes
;
73 bool SetContext(void* aContext
);
75 bool UpdatePlanes(RenderCompositor
* aCompositor
,
76 wr::ImageRendering aRendering
);
80 virtual ~RenderTextureHostSWGL();
84 } // namespace mozilla
86 #endif // MOZILLA_GFX_RENDERTEXTUREHOSTSWGL_H