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
) override
;
23 void UnlockSWGL() override
;
25 RenderTextureHostSWGL
* AsRenderTextureHostSWGL() override
{ return this; }
27 virtual size_t GetPlaneCount() const = 0;
29 virtual gfx::ColorDepth
GetColorDepth() const {
30 return gfx::ColorDepth::COLOR_8
;
34 explicit PlaneInfo(GLuint aTexture
) : mTexture(aTexture
) {}
37 void* mData
= nullptr;
42 virtual bool MapPlane(RenderCompositor
* aCompositor
, uint8_t aChannelIndex
,
43 PlaneInfo
& aPlaneInfo
) = 0;
45 virtual void UnmapPlanes() = 0;
47 // Lock this texture host as an attached external image for a SWGL compositor
48 // surface. See swgl_bindings.rs for a description of the resulting
49 // WrSWGLCompositeSurfaceInfo. This is paired with a call to UnlockSWGL when
50 // composition is done.
51 bool LockSWGLCompositeSurface(void* aContext
,
52 wr::SWGLCompositeSurfaceInfo
* aInfo
);
54 size_t BytesFromPlanes() {
55 NS_ASSERTION(mPlanes
.size(), "Can't compute bytes without any planes");
57 for (auto& plane
: mPlanes
) {
58 bytes
+= plane
.mStride
* plane
.mSize
.height
;
65 void* mContext
= nullptr;
66 std::vector
<PlaneInfo
> mPlanes
;
68 bool SetContext(void* aContext
);
70 bool UpdatePlanes(RenderCompositor
* aCompositor
);
74 virtual ~RenderTextureHostSWGL();
78 } // namespace mozilla
80 #endif // MOZILLA_GFX_RENDERTEXTUREHOSTSWGL_H