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"
13 struct ID3D11Texture2D
;
14 struct IDXGIKeyedMutex
;
20 class RenderDXGITextureHostOGL final
: public RenderTextureHostOGL
{
22 explicit RenderDXGITextureHostOGL(WindowsHandle aHandle
,
23 gfx::SurfaceFormat aFormat
,
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;
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
;
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
;
60 class RenderDXGIYCbCrTextureHostOGL final
: public RenderTextureHostOGL
{
62 explicit RenderDXGIYCbCrTextureHostOGL(WindowsHandle (&aHandles
)[3],
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;
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];
94 gfx::IntSize mSizeCbCr
;
100 } // namespace mozilla
102 #endif // MOZILLA_GFX_RENDERD3D11TEXTUREHOSTOGL_H