blob: d83825447c119de31ef358eb68975c58eefb5a2e (
plain)
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
|
diff --git a/gfx/layers/DMABUFSurfaceImage.cpp b/gfx/layers/DMABUFSurfaceImage.cpp
--- a/gfx/layers/DMABUFSurfaceImage.cpp
+++ b/gfx/layers/DMABUFSurfaceImage.cpp
@@ -39,20 +39,20 @@
StaticRefPtr<GLContext> sSnapshotContext;
static StaticMutex sSnapshotContextMutex MOZ_UNANNOTATED;
already_AddRefed<gfx::SourceSurface> DMABUFSurfaceImage::GetAsSourceSurface() {
+ StaticMutexAutoLock lock(sSnapshotContextMutex);
if (!sSnapshotContext) {
nsCString discardFailureId;
sSnapshotContext = GLContextProvider::CreateHeadless({}, &discardFailureId);
if (!sSnapshotContext) {
gfxCriticalError() << "Failed to create snapshot GLContext.";
return nullptr;
}
}
- StaticMutexAutoLock lock(sSnapshotContextMutex);
sSnapshotContext->MakeCurrent();
auto releaseTextures =
mozilla::MakeScopeExit([&] { mSurface->ReleaseTextures(); });
diff --git a/widget/gtk/DMABufSurface.cpp b/widget/gtk/DMABufSurface.cpp
--- a/widget/gtk/DMABufSurface.cpp
+++ b/widget/gtk/DMABufSurface.cpp
@@ -53,24 +53,13 @@
using namespace mozilla::layers;
#define BUFFER_FLAGS 0
static RefPtr<GLContext> sSnapshotContext;
+static StaticMutex sSnapshotContextMutex MOZ_UNANNOTATED;
static Atomic<int> gNewSurfaceUID(1);
-bool EnsureSnapshotGLContext() {
- if (!sSnapshotContext) {
- nsCString discardFailureId;
- sSnapshotContext = GLContextProvider::CreateHeadless({}, &discardFailureId);
- if (!sSnapshotContext) {
- NS_WARNING("Failed to create snapshot GLContext");
- return false;
- }
- }
- return true;
-}
-
bool DMABufSurface::IsGlobalRefSet() const {
if (!mGlobalRefCountFd) {
return false;
}
struct pollfd pfd;
@@ -1263,13 +1252,18 @@
}
bool DMABufSurfaceYUV::VerifyTextureCreation() {
LOGDMABUF(("DMABufSurfaceYUV::VerifyTextureCreation() UID %d", mUID));
- if (!EnsureSnapshotGLContext()) {
- LOGDMABUF((" failed to create GL context!"));
- return false;
+ StaticMutexAutoLock lock(sSnapshotContextMutex);
+ if (!sSnapshotContext) {
+ nsCString discardFailureId;
+ sSnapshotContext = GLContextProvider::CreateHeadless({}, &discardFailureId);
+ if (!sSnapshotContext) {
+ NS_WARNING("Failed to create snapshot GLContext");
+ return false;
+ }
}
auto release = MakeScopeExit([&] { ReleaseEGLImages(sSnapshotContext); });
for (int i = 0; i < mBufferPlaneCount; i++) {
|