Bug 1557368 [wpt PR 16856] - Update error type test for attachInternals(), a=testonly
[gecko.git] / gfx / webrender_bindings / RenderD3D11TextureHostOGL.h
blobef169b8dece260b59d0f2d7f7c3feb7d46997501
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_RENDERD3D11TEXTUREHOSTOGL_H
8 #define MOZILLA_GFX_RENDERD3D11TEXTUREHOSTOGL_H
10 #include "RenderTextureHostOGL.h"
11 #include "GLTypes.h"
13 struct ID3D11Texture2D;
14 struct IDXGIKeyedMutex;
16 namespace mozilla {
18 namespace wr {
20 class RenderDXGITextureHostOGL final : public RenderTextureHostOGL {
21 public:
22 explicit RenderDXGITextureHostOGL(WindowsHandle aHandle,
23 gfx::SurfaceFormat aFormat,
24 gfx::IntSize aSize);
26 wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL,
27 wr::ImageRendering aRendering) override;
28 void Unlock() override;
29 void ClearCachedResources() override;
31 virtual gfx::IntSize GetSize(uint8_t aChannelIndex) const;
32 virtual GLuint GetGLHandle(uint8_t aChannelIndex) const;
34 private:
35 virtual ~RenderDXGITextureHostOGL();
37 bool EnsureLockable(wr::ImageRendering aRendering);
39 void DeleteTextureHandle();
41 RefPtr<gl::GLContext> mGL;
43 WindowsHandle mHandle;
44 RefPtr<ID3D11Texture2D> mTexture;
45 RefPtr<IDXGIKeyedMutex> mKeyedMutex;
47 EGLSurface mSurface;
48 EGLStreamKHR mStream;
50 // We could use NV12 format for this texture. So, we might have 2 gl texture
51 // handles for Y and CbCr data.
52 GLuint mTextureHandle[2];
54 gfx::SurfaceFormat mFormat;
55 gfx::IntSize mSize;
57 bool mLocked;
60 class RenderDXGIYCbCrTextureHostOGL final : public RenderTextureHostOGL {
61 public:
62 explicit RenderDXGIYCbCrTextureHostOGL(WindowsHandle (&aHandles)[3],
63 gfx::IntSize aSize,
64 gfx::IntSize aSizeCbCr);
66 wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL,
67 wr::ImageRendering aRendering) override;
68 void Unlock() override;
69 void ClearCachedResources() override;
71 virtual gfx::IntSize GetSize(uint8_t aChannelIndex) const;
72 virtual GLuint GetGLHandle(uint8_t aChannelIndex) const;
74 private:
75 virtual ~RenderDXGIYCbCrTextureHostOGL();
77 bool EnsureLockable(wr::ImageRendering aRendering);
79 void DeleteTextureHandle();
81 RefPtr<gl::GLContext> mGL;
83 WindowsHandle mHandles[3];
84 RefPtr<ID3D11Texture2D> mTextures[3];
85 RefPtr<IDXGIKeyedMutex> mKeyedMutexs[3];
87 EGLSurface mSurfaces[3];
88 EGLStreamKHR mStreams[3];
90 // The gl handles for Y, Cb and Cr data.
91 GLuint mTextureHandles[3];
93 gfx::IntSize mSize;
94 gfx::IntSize mSizeCbCr;
96 bool mLocked;
99 } // namespace wr
100 } // namespace mozilla
102 #endif // MOZILLA_GFX_RENDERD3D11TEXTUREHOSTOGL_H