78 lines
2.4 KiB
Diff
78 lines
2.4 KiB
Diff
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++) {
|
|
|