Bug 863498. Get the SurfaceTexture transform every draw. r=nical
☠☠ backed out by 59fe6fbf1adf ☠ ☠
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Wed, 08 May 2013 18:04:59 -0400
changeset 131366 a23a23055e1370d6420649ee491ec1d6415602a5
parent 131365 c5daf23a9a2004f47bf162313314624a882ed863
child 131367 52bd3c5ba8fda5baf01e9344fc883b9aacc8d45a
push id27827
push userjmuizelaar@mozilla.com
push dateThu, 09 May 2013 16:00:21 +0000
treeherdermozilla-inbound@a23a23055e13 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs863498
milestone23.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 863498. Get the SurfaceTexture transform every draw. r=nical ShadowImageLayerOGL::RenderLayer used to call gl()->GetSharedHandleDetails() directly and uses that result. This makes us do something similar. As a concequence we also drop the mTextureTransform member because we are not caching it anymore. I do wonder if it would make more sense for the content thread to send the transform along with the update to make sure that it always matches. This would also make it so that we have no chance of causing a GC in the compositor to get the transform by calling through java.
gfx/layers/opengl/TextureHostOGL.cpp
gfx/layers/opengl/TextureHostOGL.h
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -258,17 +258,16 @@ SharedTextureHostOGL::SwapTexturesImpl(c
   mShareType = texture.shareType();
   mSharedHandle = newHandle;
 
   GLContext::SharedHandleDetails handleDetails;
   if (mSharedHandle && mGL->GetSharedHandleDetails(mShareType, mSharedHandle, handleDetails)) {
     mTextureTarget = handleDetails.mTarget;
     mShaderProgram = handleDetails.mProgramType;
     mFormat = FormatFromShaderType(mShaderProgram);
-    mTextureTransform = handleDetails.mTextureTransform;
   }
 }
 
 bool
 SharedTextureHostOGL::Lock()
 {
   MakeTextureIfNeeded(mGL, mTextureHandle);
 
@@ -284,16 +283,30 @@ SharedTextureHostOGL::Lock()
 
 void
 SharedTextureHostOGL::Unlock()
 {
   mGL->DetachSharedHandle(mShareType, mSharedHandle);
   mGL->fBindTexture(LOCAL_GL_TEXTURE_2D, 0);
 }
 
+
+gfx3DMatrix
+SharedTextureHostOGL::GetTextureTransform() MOZ_OVERRIDE
+{
+  GLContext::SharedHandleDetails handleDetails;
+  // GetSharedHandleDetails can call into Java which we'd
+  // rather not do from the compositor
+  if (mSharedHandle) {
+    mGL->GetSharedHandleDetails(mShareType, mSharedHandle, handleDetails);
+  }
+  return handleDetails.mTextureTransform;
+}
+
+
 void
 SurfaceStreamHostOGL::SetCompositor(Compositor* aCompositor)
 {
   CompositorOGL* glCompositor = static_cast<CompositorOGL*>(aCompositor);
   if (mGL && !glCompositor) {
     DeleteTextures();
   }
   mGL = glCompositor ? glCompositor->gl() : nullptr;
--- a/gfx/layers/opengl/TextureHostOGL.h
+++ b/gfx/layers/opengl/TextureHostOGL.h
@@ -46,17 +46,17 @@ public:
   virtual void BindTexture(GLenum aTextureUnit) = 0;
   virtual gfx::IntSize GetSize() const = 0;
   virtual gl::ShaderProgramType GetShaderProgram() const {
     MOZ_NOT_REACHED("unhandled shader type");
   }
   // TODO: Noone's implementing this anymore, should see if we need this.
   virtual GLenum GetTextureTarget() const { return LOCAL_GL_TEXTURE_2D; }
   virtual GLenum GetWrapMode() const = 0;// { return LOCAL_GL_CLAMP_TO_EDGE; } // default
-  virtual gfx3DMatrix GetTextureTransform() const { return gfx3DMatrix(); }
+  virtual gfx3DMatrix GetTextureTransform() { return gfx3DMatrix(); }
 };
 
 inline gl::ShaderProgramType
 GetProgramTypeForTexture(const TextureHost *aTextureHost)
 {
   switch (aTextureHost->GetFormat()) {
   case gfx::FORMAT_B8G8R8A8:
     return gl::BGRALayerProgramType;;
@@ -355,37 +355,33 @@ public:
   GLuint GetTextureID() { return mTextureHandle; }
   ContentType GetContentType()
   {
     return (mFormat == gfx::FORMAT_B8G8R8A8) ?
              gfxASurface::CONTENT_COLOR_ALPHA :
              gfxASurface::CONTENT_COLOR;
   }
 
-  virtual gfx3DMatrix GetTextureTransform() const MOZ_OVERRIDE
-  {
-    return mTextureTransform;
-  }
+  virtual gfx3DMatrix GetTextureTransform() MOZ_OVERRIDE;
 
 #ifdef MOZ_LAYERS_HAVE_LOG
   virtual const char* Name() { return "SharedTextureHostOGL"; }
 #endif
 
 protected:
   void DeleteTextures();
 
   gfx::IntSize mSize;
   nsRefPtr<gl::GLContext> mGL;
   GLuint mTextureHandle;
   GLenum mWrapMode;
   GLenum mTextureTarget;
   gl::SharedTextureHandle mSharedHandle;
   gl::ShaderProgramType mShaderProgram;
   gl::GLContext::SharedTextureShareType mShareType;
-  gfx3DMatrix mTextureTransform;
 };
 
 class SurfaceStreamHostOGL : public TextureHost
                            , public TextureSourceOGL
 {
 public:
   typedef gfxASurface::gfxContentType ContentType;
   typedef mozilla::gl::GLContext GLContext;