This repository has been archived by the owner on Aug 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathRenderD3D11TextureHostOGL.h
102 lines (71 loc) · 2.8 KB
/
RenderD3D11TextureHostOGL.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MOZILLA_GFX_RENDERD3D11TEXTUREHOSTOGL_H
#define MOZILLA_GFX_RENDERD3D11TEXTUREHOSTOGL_H
#include "RenderTextureHostOGL.h"
#include "GLTypes.h"
struct ID3D11Texture2D;
struct IDXGIKeyedMutex;
namespace mozilla {
namespace wr {
class RenderDXGITextureHostOGL final : public RenderTextureHostOGL {
public:
explicit RenderDXGITextureHostOGL(WindowsHandle aHandle,
gfx::SurfaceFormat aFormat,
gfx::IntSize aSize);
wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL,
wr::ImageRendering aRendering) override;
void Unlock() override;
void ClearCachedResources() override;
virtual gfx::IntSize GetSize(uint8_t aChannelIndex) const;
virtual GLuint GetGLHandle(uint8_t aChannelIndex) const;
private:
virtual ~RenderDXGITextureHostOGL();
bool EnsureLockable(wr::ImageRendering aRendering);
void DeleteTextureHandle();
RefPtr<gl::GLContext> mGL;
WindowsHandle mHandle;
RefPtr<ID3D11Texture2D> mTexture;
RefPtr<IDXGIKeyedMutex> mKeyedMutex;
EGLSurface mSurface;
EGLStreamKHR mStream;
// We could use NV12 format for this texture. So, we might have 2 gl texture
// handles for Y and CbCr data.
GLuint mTextureHandle[2];
gfx::SurfaceFormat mFormat;
gfx::IntSize mSize;
bool mLocked;
};
class RenderDXGIYCbCrTextureHostOGL final : public RenderTextureHostOGL {
public:
explicit RenderDXGIYCbCrTextureHostOGL(WindowsHandle (&aHandles)[3],
gfx::IntSize aSize,
gfx::IntSize aSizeCbCr);
wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL,
wr::ImageRendering aRendering) override;
void Unlock() override;
void ClearCachedResources() override;
virtual gfx::IntSize GetSize(uint8_t aChannelIndex) const;
virtual GLuint GetGLHandle(uint8_t aChannelIndex) const;
private:
virtual ~RenderDXGIYCbCrTextureHostOGL();
bool EnsureLockable(wr::ImageRendering aRendering);
void DeleteTextureHandle();
RefPtr<gl::GLContext> mGL;
WindowsHandle mHandles[3];
RefPtr<ID3D11Texture2D> mTextures[3];
RefPtr<IDXGIKeyedMutex> mKeyedMutexs[3];
EGLSurface mSurfaces[3];
EGLStreamKHR mStreams[3];
// The gl handles for Y, Cb and Cr data.
GLuint mTextureHandles[3];
gfx::IntSize mSize;
gfx::IntSize mSizeCbCr;
bool mLocked;
};
} // namespace wr
} // namespace mozilla
#endif // MOZILLA_GFX_RENDERD3D11TEXTUREHOSTOGL_H