no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / gfx / webrender_bindings / RenderTextureHostSWGL.h
blobb5d1e92056b95c7cf4edcd308004978976c7c6a8
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
10 #include "GLTypes.h"
11 #include "RenderTextureHost.h"
13 namespace mozilla {
14 namespace wr {
16 class RenderTextureHostSWGL : public RenderTextureHost {
17 public:
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;
33 struct PlaneInfo {
34 explicit PlaneInfo(GLuint aTexture) : mTexture(aTexture) {}
36 GLuint mTexture = 0;
37 void* mData = nullptr;
38 int32_t mStride = 0;
39 gfx::IntSize mSize;
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");
56 size_t bytes = 0;
57 for (auto& plane : mPlanes) {
58 bytes += plane.mStride * plane.mSize.height;
60 return bytes;
63 protected:
64 bool mLocked = false;
65 void* mContext = nullptr;
66 std::vector<PlaneInfo> mPlanes;
68 bool SetContext(void* aContext);
70 bool UpdatePlanes(RenderCompositor* aCompositor);
72 void CleanupPlanes();
74 virtual ~RenderTextureHostSWGL();
77 } // namespace wr
78 } // namespace mozilla
80 #endif // MOZILLA_GFX_RENDERTEXTUREHOSTSWGL_H