summaryrefslogtreecommitdiff
path: root/D144284.diff
diff options
context:
space:
mode:
Diffstat (limited to 'D144284.diff')
-rw-r--r--D144284.diff77
1 files changed, 77 insertions, 0 deletions
diff --git a/D144284.diff b/D144284.diff
new file mode 100644
index 0000000..d838254
--- /dev/null
+++ b/D144284.diff
@@ -0,0 +1,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++) {
+
bgstack15