Bug 1685225 - Use state bits to determine the color for non-native theme meter chunks...
[gecko.git] / gfx / webrender_bindings / RenderTextureHostSWGL.h
blob37423d758056077b27e55d85e98d9e32ed15badd
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,
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;
40 struct PlaneInfo {
41 explicit PlaneInfo(GLuint aTexture) : mTexture(aTexture) {}
43 GLuint mTexture = 0;
44 void* mData = nullptr;
45 int32_t mStride = 0;
46 gfx::IntSize mSize;
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 {
62 size_t bytes = 0;
63 for (auto &plane : mPlanes) {
64 bytes += plane.mStride * plane.mSize.height;
66 return bytes;
68 protected:
69 bool mLocked = false;
70 void* mContext = nullptr;
71 std::vector<PlaneInfo> mPlanes;
73 bool SetContext(void* aContext);
75 bool UpdatePlanes(RenderCompositor* aCompositor,
76 wr::ImageRendering aRendering);
78 void CleanupPlanes();
80 virtual ~RenderTextureHostSWGL();
83 } // namespace wr
84 } // namespace mozilla
86 #endif // MOZILLA_GFX_RENDERTEXTUREHOSTSWGL_H