summaryrefslogtreecommitdiff
path: root/D149135.diff
blob: 6e93f2bf274785867ff737aaf0500fb2259801cc (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
78
79
80
diff --git a/widget/gtk/DMABufSurface.cpp b/widget/gtk/DMABufSurface.cpp
--- a/widget/gtk/DMABufSurface.cpp
+++ b/widget/gtk/DMABufSurface.cpp
@@ -642,11 +642,11 @@
 
 void DMABufSurfaceRGBA::ReleaseTextures() {
   LOGDMABUF(("DMABufSurfaceRGBA::ReleaseTextures() UID %d\n", mUID));
   FenceDelete();
 
-  if (!mTexture) {
+  if (!mTexture && mEGLImage == LOCAL_EGL_NO_IMAGE) {
     return;
   }
 
   if (!mGL) {
 #ifdef NIGHTLY
@@ -663,17 +663,17 @@
   const auto& egl = gle->mEgl;
 
   if (mTexture && mGL->MakeCurrent()) {
     mGL->fDeleteTextures(1, &mTexture);
     mTexture = 0;
-    mGL = nullptr;
   }
 
   if (mEGLImage != LOCAL_EGL_NO_IMAGE) {
     egl->fDestroyImage(mEGLImage);
     mEGLImage = LOCAL_EGL_NO_IMAGE;
   }
+  mGL = nullptr;
 }
 
 void DMABufSurfaceRGBA::ReleaseSurface() {
   MOZ_ASSERT(!IsMapped(), "We can't release mapped buffer!");
 
@@ -1325,11 +1325,11 @@
 
   FenceDelete();
 
   bool textureActive = false;
   for (int i = 0; i < mBufferPlaneCount; i++) {
-    if (mTexture[i]) {
+    if (mTexture[i] || mEGLImage[i] != LOCAL_EGL_NO_IMAGE) {
       textureActive = true;
       break;
     }
   }
 
@@ -1346,18 +1346,23 @@
         "leaking textures!");
     return;
 #endif
   }
 
-  if (textureActive && mGL->MakeCurrent()) {
-    mGL->fDeleteTextures(DMABUF_BUFFER_PLANES, mTexture);
-    for (int i = 0; i < DMABUF_BUFFER_PLANES; i++) {
-      mTexture[i] = 0;
-    }
-    ReleaseEGLImages(mGL);
-    mGL = nullptr;
+  if (!mGL->MakeCurrent()) {
+    NS_WARNING(
+        "DMABufSurfaceYUV::ReleaseTextures(): Failed to create GL context "
+        "current. We're leaking textures!");
+    return;
   }
+
+  mGL->fDeleteTextures(DMABUF_BUFFER_PLANES, mTexture);
+  for (int i = 0; i < DMABUF_BUFFER_PLANES; i++) {
+    mTexture[i] = 0;
+  }
+  ReleaseEGLImages(mGL);
+  mGL = nullptr;
 }
 
 bool DMABufSurfaceYUV::VerifyTextureCreation() {
   LOGDMABUF(("DMABufSurfaceYUV::VerifyTextureCreation() UID %d", mUID));
 

bgstack15