Bug 1399501 - Make DestroySurface ignore null input. r=kvark
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 23 Oct 2018 14:53:37 -0700
changeset 442846 7f1abf24702dc68a85b6d4fdaec4c741565ebfd5
parent 442845 5cb0aeccd4cc8d6417d9c92d04c2ee60ce244cbd
child 442847 13b39a6aa15fa631096b96d4351c2b1d08a4626e
push id34925
push userrgurzau@mozilla.com
push dateWed, 24 Oct 2018 22:00:55 +0000
treeherdermozilla-central@ddadc29de671 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskvark
bugs1399501
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1399501 - Make DestroySurface ignore null input. r=kvark Differential Revision: https://phabricator.services.mozilla.com/D9597
gfx/gl/GLContextProviderEGL.cpp
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -155,17 +155,19 @@ is_power_of_two(int v)
         return true;
 
     return (v & (v-1)) == 0;
 }
 
 static void
 DestroySurface(const EGLSurface surf)
 {
-    MOZ_ASSERT(surf);
+    if (!surf)
+        return;
+
     const auto& egl = gl::GLLibraryEGL::Get();
 
     // TODO: This breaks TLS MakeCurrent caching.
     MOZ_ALWAYS_TRUE( egl->fDestroySurface(EGL_DISPLAY(), surf) );
 #if defined(MOZ_WAYLAND)
     DeleteWaylandGLSurface(surf);
 #endif
 }
@@ -318,22 +320,19 @@ GLContextEGL::~GLContextEGL()
         return;
     }
 
 #ifdef DEBUG
     printf_stderr("Destroying context %p surface %p on display %p\n", mContext, mSurface, EGL_DISPLAY());
 #endif
 
     mEgl->fDestroyContext(EGL_DISPLAY(), mContext);
-    if (mSurface) {
-        DestroySurface(mSurface);
-    }
-    if (mFallbackSurface) {
-        DestroySurface(mFallbackSurface);
-    }
+    DestroySurface(mSurface);
+    MOZ_ASSERT(!mFallbackSurface || mFallbackSurface != mSurface);
+    DestroySurface(mFallbackSurface);
 }
 
 bool
 GLContextEGL::Init()
 {
 #if defined(ANDROID)
     // We can't use LoadApitraceLibrary here because the GLContext
     // expects its own handle to the GL library
@@ -483,17 +482,17 @@ GLContextEGL::RenewSurface(CompositorWid
 }
 
 void
 GLContextEGL::ReleaseSurface()
 {
     if (!mOwnsContext)
         return;
 
-    mozilla::gl::DestroySurface(mSurface);
+    DestroySurface(mSurface);
     mSurface = nullptr;
 }
 
 bool
 GLContextEGL::SetupLookupFunction()
 {
     mLookupFunc = mEgl->GetLookupFunction();
     return true;