Recreate GLTextureSources after changing compositors on Mac. (bug 1247611, r=mattwoodrow)
authorDavid Anderson <danderson@mozilla.com>
Wed, 30 Mar 2016 09:33:24 -0400
changeset 291082 7c4258b493b12d00a89276c41a5f39cdcf28d2fc
parent 291081 57e8e4c71ecf66ccf431eebf8c88083df266f65c
child 291083 5df20795af1438c88a7997255e52ac44ec07047e
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1247611
milestone48.0a1
Recreate GLTextureSources after changing compositors on Mac. (bug 1247611, r=mattwoodrow)
gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
gfx/layers/opengl/TextureHostOGL.cpp
--- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
+++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
@@ -68,21 +68,23 @@ MacIOSurfaceTextureHostOGL::Lock()
 void
 MacIOSurfaceTextureHostOGL::SetCompositor(Compositor* aCompositor)
 {
   if (!AssertGLCompositor(aCompositor)) {
     mTextureSource = nullptr;
     mCompositor = nullptr;
     return;
   }
+
   CompositorOGL* glCompositor = static_cast<CompositorOGL*>(aCompositor);
+  if (mCompositor != glCompositor) {
+    // Cannot share GL texture identifiers across compositors.
+    mTextureSource = nullptr;
+  }
   mCompositor = glCompositor;
-  if (mTextureSource) {
-    mTextureSource->SetCompositor(glCompositor);
-  }
 }
 
 gfx::SurfaceFormat
 MacIOSurfaceTextureHostOGL::GetFormat() const {
   return mSurface->GetFormat();
 }
 
 gfx::SurfaceFormat
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -348,16 +348,21 @@ GLTextureSource::BindTexture(GLenum aTex
 }
 
 void
 GLTextureSource::SetCompositor(Compositor* aCompositor)
 {
   if (!AssertGLCompositor(aCompositor)) {
     return;
   }
+
+  if (mCompositor && mCompositor != aCompositor) {
+    gfxCriticalError() << "GLTextureSource does not support changing compositors";
+  }
+
   mCompositor = static_cast<CompositorOGL*>(aCompositor);
   if (mNextSibling) {
     mNextSibling->SetCompositor(aCompositor);
   }
 }
 
 bool
 GLTextureSource::IsValid() const