Bug 976813 - Separate ShSurf::Texture for Prod and Cons. - r=snorp
authorJeff Gilbert <jgilbert@mozilla.com>
Mon, 10 Mar 2014 19:08:49 -0700
changeset 190094 d6e7ed4cd0a62cd94b8f0946d41cf1468c2c3710
parent 190093 72a2f1fcea40e0fd17c31c6c57de232722d739d2
child 190095 7d62c468b48b16637872106664ba2c264fb85a63
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs976813
milestone30.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 976813 - Separate ShSurf::Texture for Prod and Cons. - r=snorp
gfx/gl/GLContext.cpp
gfx/gl/GLContext.h
gfx/gl/GLScreenBuffer.cpp
gfx/gl/SharedSurface.cpp
gfx/gl/SharedSurface.h
gfx/gl/SharedSurfaceANGLE.h
gfx/gl/SharedSurfaceEGL.h
gfx/gl/SharedSurfaceGL.cpp
gfx/gl/SharedSurfaceGL.h
gfx/gl/SharedSurfaceGralloc.cpp
gfx/gl/SharedSurfaceGralloc.h
gfx/gl/SharedSurfaceIO.h
gfx/layers/CopyableCanvasLayer.cpp
gfx/layers/d3d10/CanvasLayerD3D10.cpp
gfx/layers/d3d9/CanvasLayerD3D9.cpp
gfx/layers/opengl/TextureHostOGL.cpp
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -18,16 +18,17 @@
 #include "gfxUtils.h"
 #include "GLContextProvider.h"
 #include "GLTextureImage.h"
 #include "nsPrintfCString.h"
 #include "nsThreadUtils.h"
 #include "prenv.h"
 #include "prlink.h"
 #include "ScopedGLHelpers.h"
+#include "SharedSurfaceGL.h"
 #include "SurfaceStream.h"
 #include "GfxTexturesReporter.h"
 #include "TextureGarbageBin.h"
 #include "gfx2DGlue.h"
 #include "gfxPrefs.h"
 
 #include "OGLShaderProgram.h" // for ShaderProgramType
 
@@ -1559,22 +1560,26 @@ GLContext::PublishFrame()
     MOZ_ASSERT(mScreen);
 
     if (!mScreen->PublishFrame(OffscreenSize()))
         return false;
 
     return true;
 }
 
-SharedSurface*
+SharedSurface_GL*
 GLContext::RequestFrame()
 {
     MOZ_ASSERT(mScreen);
 
-    return mScreen->Stream()->SwapConsumer();
+    SharedSurface* ret = mScreen->Stream()->SwapConsumer();
+    if (!ret)
+        return nullptr;
+
+    return SharedSurface_GL::Cast(ret);
 }
 
 
 
 void
 GLContext::ClearSafely()
 {
     // bug 659349 --- we must be very careful here: clearing a GL framebuffer is nontrivial, relies on a lot of state,
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -52,30 +52,30 @@ class nsIRunnable;
 class nsIThread;
 
 namespace android {
     class GraphicBuffer;
 }
 
 namespace mozilla {
     namespace gfx {
-        class SharedSurface;
         class SourceSurface;
         class DataSourceSurface;
         struct SurfaceCaps;
     }
 
     namespace gl {
         class GLContext;
         class GLLibraryEGL;
         class GLScreenBuffer;
         class TextureGarbageBin;
         class GLBlitHelper;
         class GLBlitTextureImageHelper;
         class GLReadTexImageHelper;
+        class SharedSurface_GL;
     }
 
     namespace layers {
         class ColorTextureLayerProgram;
     }
 }
 
 namespace mozilla {
@@ -2820,43 +2820,43 @@ public:
                               GLuint* readFB);
 
 protected:
     friend class GLScreenBuffer;
     GLScreenBuffer* mScreen;
 
     void DestroyScreenBuffer();
 
-    SharedSurface* mLockedSurface;
+    SharedSurface_GL* mLockedSurface;
 
 public:
-    void LockSurface(SharedSurface* surf) {
+    void LockSurface(SharedSurface_GL* surf) {
         MOZ_ASSERT(!mLockedSurface);
         mLockedSurface = surf;
     }
 
-    void UnlockSurface(SharedSurface* surf) {
+    void UnlockSurface(SharedSurface_GL* surf) {
         MOZ_ASSERT(mLockedSurface == surf);
         mLockedSurface = nullptr;
     }
 
-    SharedSurface* GetLockedSurface() const {
+    SharedSurface_GL* GetLockedSurface() const {
         return mLockedSurface;
     }
 
     bool IsOffscreen() const {
         return mScreen;
     }
 
     GLScreenBuffer* Screen() const {
         return mScreen;
     }
 
     bool PublishFrame();
-    SharedSurface* RequestFrame();
+    SharedSurface_GL* RequestFrame();
 
     /* Clear to transparent black, with 0 depth and stencil,
      * while preserving current ClearColor etc. values.
      * Useful for resizing offscreen buffers.
      */
     void ClearSafely();
 
     bool WorkAroundDriverBugs() const { return mWorkAroundDriverBugs; }
--- a/gfx/gl/GLScreenBuffer.cpp
+++ b/gfx/gl/GLScreenBuffer.cpp
@@ -618,21 +618,21 @@ ReadBuffer::Create(GLContext* gl,
                                     nullptr, pDepthRB, pStencilRB);
 
     GLuint colorTex = 0;
     GLuint colorRB = 0;
     GLenum target = 0;
 
     switch (surf->AttachType()) {
     case AttachmentType::GLTexture:
-        colorTex = surf->Texture();
-        target = surf->TextureTarget();
+        colorTex = surf->ProdTexture();
+        target = surf->ProdTextureTarget();
         break;
     case AttachmentType::GLRenderbuffer:
-        colorRB = surf->Renderbuffer();
+        colorRB = surf->ProdRenderbuffer();
         break;
     default:
         MOZ_CRASH("Unknown attachment type?");
     }
     MOZ_ASSERT(colorTex || colorRB);
 
     GLuint fb = 0;
     gl->fGenFramebuffers(1, &fb);
@@ -671,21 +671,21 @@ ReadBuffer::Attach(SharedSurface_GL* sur
     // Nothing else is needed for AttachType Screen.
     if (surf->AttachType() != AttachmentType::Screen) {
         GLuint colorTex = 0;
         GLuint colorRB = 0;
         GLenum target = 0;
 
         switch (surf->AttachType()) {
         case AttachmentType::GLTexture:
-            colorTex = surf->Texture();
-            target = surf->TextureTarget();
+            colorTex = surf->ProdTexture();
+            target = surf->ProdTextureTarget();
             break;
         case AttachmentType::GLRenderbuffer:
-            colorRB = surf->Renderbuffer();
+            colorRB = surf->ProdRenderbuffer();
             break;
         default:
             MOZ_CRASH("Unknown attachment type?");
         }
 
         mGL->AttachBuffersToFB(colorTex, colorRB, 0, 0, mFB, target);
         mGL->mFBOMapping[mFB] = surf;
         MOZ_ASSERT(mGL->IsFramebufferComplete(mFB));
--- a/gfx/gl/SharedSurface.cpp
+++ b/gfx/gl/SharedSurface.cpp
@@ -17,13 +17,13 @@ void
 SharedSurface::Copy(SharedSurface* src, SharedSurface* dest, SurfaceFactory* factory)
 {
     MOZ_ASSERT( src->APIType() == APITypeT::OpenGL);
     MOZ_ASSERT(dest->APIType() == APITypeT::OpenGL);
 
     SharedSurface_GL* srcGL = (SharedSurface_GL*)src;
     SharedSurface_GL* destGL = (SharedSurface_GL*)dest;
 
-    SharedSurface_GL::Copy(srcGL, destGL, (SurfaceFactory_GL*)factory);
+    SharedSurface_GL::ProdCopy(srcGL, destGL, (SurfaceFactory_GL*)factory);
 }
 
 } /* namespace gfx */
 } /* namespace mozilla */
--- a/gfx/gl/SharedSurface.h
+++ b/gfx/gl/SharedSurface.h
@@ -95,30 +95,14 @@ public:
 
     const gfx::IntSize& Size() const {
         return mSize;
     }
 
     bool HasAlpha() const {
         return mHasAlpha;
     }
-
-
-    // For use when AttachType is correct.
-    virtual GLuint Texture() const {
-        MOZ_ASSERT(AttachType() == AttachmentType::GLTexture);
-        MOZ_CRASH("Did you forget to override this function?");
-    }
-
-    virtual GLenum TextureTarget() const {
-        return Texture() ? LOCAL_GL_TEXTURE_2D : 0;
-    }
-
-    virtual GLuint Renderbuffer() const {
-        MOZ_ASSERT(AttachType() == AttachmentType::GLRenderbuffer);
-        MOZ_CRASH("Did you forget to override this function?");
-    }
 };
 
 } /* namespace gfx */
 } /* namespace mozilla */
 
 #endif /* SHARED_SURFACE_H_ */
--- a/gfx/gl/SharedSurfaceANGLE.h
+++ b/gfx/gl/SharedSurfaceANGLE.h
@@ -61,21 +61,21 @@ protected:
         , mSRV(srv)
     {}
 
     EGLDisplay Display();
 
 public:
     virtual ~SharedSurface_ANGLEShareHandle();
 
-    virtual void LockProdImpl();
-    virtual void UnlockProdImpl();
+    virtual void LockProdImpl() MOZ_OVERRIDE;
+    virtual void UnlockProdImpl() MOZ_OVERRIDE;
 
-    virtual void Fence();
-    virtual bool WaitSync();
+    virtual void Fence() MOZ_OVERRIDE;
+    virtual bool WaitSync() MOZ_OVERRIDE;
 
     // Implementation-specific functions below:
     ID3D10ShaderResourceView* GetSRV() {
         return mSRV;
     }
 };
 
 
@@ -96,17 +96,17 @@ public:
                                                    const SurfaceCaps& caps);
 
 protected:
     SurfaceFactory_ANGLEShareHandle(GLContext* gl,
                                     GLLibraryEGL* egl,
                                     ID3D10Device1* d3d,
                                     const SurfaceCaps& caps);
 
-    virtual SharedSurface* CreateShared(const gfx::IntSize& size) {
+    virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
         bool hasAlpha = mReadCaps.alpha;
         return SharedSurface_ANGLEShareHandle::Create(mProdGL, mConsD3D,
                                                       mContext, mConfig,
                                                       size, hasAlpha);
     }
 };
 
 } /* namespace gfx */
--- a/gfx/gl/SharedSurfaceEGL.h
+++ b/gfx/gl/SharedSurfaceEGL.h
@@ -52,31 +52,30 @@ protected:
                            GLLibraryEGL* egl,
                            const gfx::IntSize& size,
                            bool hasAlpha,
                            const GLFormats& formats,
                            GLuint prodTex,
                            EGLImage image);
 
     EGLDisplay Display() const;
-
+    void UpdateProdTexture(const MutexAutoLock& curAutoLock);
 
 public:
     virtual ~SharedSurface_EGLImage();
 
-    virtual void LockProdImpl() {}
-    virtual void UnlockProdImpl() {}
+    virtual void LockProdImpl() MOZ_OVERRIDE {}
+    virtual void UnlockProdImpl() MOZ_OVERRIDE {}
 
 
-    virtual void Fence();
-    virtual bool WaitSync();
+    virtual void Fence() MOZ_OVERRIDE;
+    virtual bool WaitSync() MOZ_OVERRIDE;
 
-
-    virtual GLuint Texture() const {
-        return mProdTex;
+    virtual GLuint ProdTexture() MOZ_OVERRIDE {
+      return mProdTex;
     }
 
     // Implementation-specific functions below:
     // Returns texture and target
     void AcquireConsumerTexture(GLContext* consGL, GLuint* out_texture, GLuint* out_target);
 };
 
 
@@ -95,17 +94,17 @@ protected:
     SurfaceFactory_EGLImage(GLContext* prodGL,
                             EGLContext context,
                             const SurfaceCaps& caps)
         : SurfaceFactory_GL(prodGL, SharedSurfaceType::EGLImageShare, caps)
         , mContext(context)
     {}
 
 public:
-    virtual SharedSurface* CreateShared(const gfx::IntSize& size) {
+    virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
         bool hasAlpha = mReadCaps.alpha;
         return SharedSurface_EGLImage::Create(mGL, mFormats, size, hasAlpha, mContext);
     }
 };
 
 } /* namespace gfx */
 } /* namespace mozilla */
 
--- a/gfx/gl/SharedSurfaceGL.cpp
+++ b/gfx/gl/SharedSurfaceGL.cpp
@@ -14,57 +14,57 @@
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace gl {
 
 // |src| must begin and end locked, though we may
 // temporarily unlock it if we need to.
 void
-SharedSurface_GL::Copy(SharedSurface_GL* src, SharedSurface_GL* dest,
-                       SurfaceFactory_GL* factory)
+SharedSurface_GL::ProdCopy(SharedSurface_GL* src, SharedSurface_GL* dest,
+                           SurfaceFactory_GL* factory)
 {
     GLContext* gl = src->GL();
 
     if (src->AttachType() == AttachmentType::Screen &&
         dest->AttachType() == AttachmentType::Screen)
     {
         // Here, we actually need to blit through a temp surface, so let's make one.
         nsAutoPtr<SharedSurface_GLTexture> tempSurf(
             SharedSurface_GLTexture::Create(gl, gl,
                                             factory->Formats(),
                                             src->Size(),
                                             factory->Caps().alpha));
 
-        Copy(src, tempSurf, factory);
-        Copy(tempSurf, dest, factory);
+        ProdCopy(src, tempSurf, factory);
+        ProdCopy(tempSurf, dest, factory);
         return;
     }
 
     if (src->AttachType() == AttachmentType::Screen) {
-        SharedSurface* origLocked = gl->GetLockedSurface();
+        SharedSurface_GL* origLocked = gl->GetLockedSurface();
         bool srcNeedsUnlock = false;
         bool origNeedsRelock = false;
         if (origLocked != src) {
             if (origLocked) {
                 origLocked->UnlockProd();
                 origNeedsRelock = true;
             }
 
             src->LockProd();
             srcNeedsUnlock = true;
         }
 
         if (dest->AttachType() == AttachmentType::GLTexture) {
-            GLuint destTex = dest->Texture();
-            GLenum destTarget = dest->TextureTarget();
+            GLuint destTex = dest->ProdTexture();
+            GLenum destTarget = dest->ProdTextureTarget();
 
             gl->BlitHelper()->BlitFramebufferToTexture(0, destTex, src->Size(), dest->Size(), destTarget);
         } else if (dest->AttachType() == AttachmentType::GLRenderbuffer) {
-            GLuint destRB = dest->Renderbuffer();
+            GLuint destRB = dest->ProdRenderbuffer();
             ScopedFramebufferForRenderbuffer destWrapper(gl, destRB);
 
             gl->BlitHelper()->BlitFramebufferToFramebuffer(0, destWrapper.FB(),
                                                            src->Size(), dest->Size());
         } else {
             MOZ_CRASH("Unhandled dest->AttachType().");
         }
 
@@ -73,36 +73,36 @@ SharedSurface_GL::Copy(SharedSurface_GL*
 
         if (origNeedsRelock)
             origLocked->LockProd();
 
         return;
     }
 
     if (dest->AttachType() == AttachmentType::Screen) {
-        SharedSurface* origLocked = gl->GetLockedSurface();
+        SharedSurface_GL* origLocked = gl->GetLockedSurface();
         bool destNeedsUnlock = false;
         bool origNeedsRelock = false;
         if (origLocked != dest) {
             if (origLocked) {
                 origLocked->UnlockProd();
                 origNeedsRelock = true;
             }
 
             dest->LockProd();
             destNeedsUnlock = true;
         }
 
         if (src->AttachType() == AttachmentType::GLTexture) {
-            GLuint srcTex = src->Texture();
-            GLenum srcTarget = src->TextureTarget();
+            GLuint srcTex = src->ProdTexture();
+            GLenum srcTarget = src->ProdTextureTarget();
 
             gl->BlitHelper()->BlitTextureToFramebuffer(srcTex, 0, src->Size(), dest->Size(), srcTarget);
         } else if (src->AttachType() == AttachmentType::GLRenderbuffer) {
-            GLuint srcRB = src->Renderbuffer();
+            GLuint srcRB = src->ProdRenderbuffer();
             ScopedFramebufferForRenderbuffer srcWrapper(gl, srcRB);
 
             gl->BlitHelper()->BlitFramebufferToFramebuffer(srcWrapper.FB(), 0,
                                                            src->Size(), dest->Size());
         } else {
             MOZ_CRASH("Unhandled src->AttachType().");
         }
 
@@ -114,59 +114,59 @@ SharedSurface_GL::Copy(SharedSurface_GL*
 
         return;
     }
 
     // Alright, done with cases involving Screen types.
     // Only {src,dest}x{texture,renderbuffer} left.
 
     if (src->AttachType() == AttachmentType::GLTexture) {
-        GLuint srcTex = src->Texture();
-        GLenum srcTarget = src->TextureTarget();
+        GLuint srcTex = src->ProdTexture();
+        GLenum srcTarget = src->ProdTextureTarget();
 
         if (dest->AttachType() == AttachmentType::GLTexture) {
-            GLuint destTex = dest->Texture();
-            GLenum destTarget = dest->TextureTarget();
+            GLuint destTex = dest->ProdTexture();
+            GLenum destTarget = dest->ProdTextureTarget();
 
             gl->BlitHelper()->BlitTextureToTexture(srcTex, destTex,
                                                    src->Size(), dest->Size(),
                                                    srcTarget, destTarget);
 
             return;
         }
 
         if (dest->AttachType() == AttachmentType::GLRenderbuffer) {
-            GLuint destRB = dest->Renderbuffer();
+            GLuint destRB = dest->ProdRenderbuffer();
             ScopedFramebufferForRenderbuffer destWrapper(gl, destRB);
 
             gl->BlitHelper()->BlitTextureToFramebuffer(srcTex, destWrapper.FB(),
                                                        src->Size(), dest->Size(), srcTarget);
 
             return;
         }
 
         MOZ_CRASH("Unhandled dest->AttachType().");
     }
 
     if (src->AttachType() == AttachmentType::GLRenderbuffer) {
-        GLuint srcRB = src->Renderbuffer();
+        GLuint srcRB = src->ProdRenderbuffer();
         ScopedFramebufferForRenderbuffer srcWrapper(gl, srcRB);
 
         if (dest->AttachType() == AttachmentType::GLTexture) {
-            GLuint destTex = dest->Texture();
-            GLenum destTarget = dest->TextureTarget();
+            GLuint destTex = dest->ProdTexture();
+            GLenum destTarget = dest->ProdTextureTarget();
 
             gl->BlitHelper()->BlitFramebufferToTexture(srcWrapper.FB(), destTex,
                                                        src->Size(), dest->Size(), destTarget);
 
             return;
         }
 
         if (dest->AttachType() == AttachmentType::GLRenderbuffer) {
-            GLuint destRB = dest->Renderbuffer();
+            GLuint destRB = dest->ProdRenderbuffer();
             ScopedFramebufferForRenderbuffer destWrapper(gl, destRB);
 
             gl->BlitHelper()->BlitFramebufferToFramebuffer(srcWrapper.FB(), destWrapper.FB(),
                                                            src->Size(), dest->Size());
 
             return;
         }
 
--- a/gfx/gl/SharedSurfaceGL.h
+++ b/gfx/gl/SharedSurfaceGL.h
@@ -49,32 +49,47 @@ protected:
                      GLContext* gl,
                      const gfx::IntSize& size,
                      bool hasAlpha)
         : SharedSurface(type, APITypeT::OpenGL, attachType, size, hasAlpha)
         , mGL(gl)
     {}
 
 public:
-    static void Copy(SharedSurface_GL* src, SharedSurface_GL* dest,
-                     SurfaceFactory_GL* factory);
+    static void ProdCopy(SharedSurface_GL* src, SharedSurface_GL* dest,
+                         SurfaceFactory_GL* factory);
 
     static SharedSurface_GL* Cast(SharedSurface* surf) {
         MOZ_ASSERT(surf->APIType() == APITypeT::OpenGL);
 
         return (SharedSurface_GL*)surf;
     }
 
+    // For use when AttachType is correct.
+    virtual GLuint ProdTexture() {
+        MOZ_ASSERT(AttachType() == AttachmentType::GLTexture);
+        MOZ_CRASH("Did you forget to override this function?");
+    }
+
+    virtual GLenum ProdTextureTarget() const {
+        return LOCAL_GL_TEXTURE_2D;
+    }
+
+    virtual GLuint ProdRenderbuffer() {
+        MOZ_ASSERT(AttachType() == AttachmentType::GLRenderbuffer);
+        MOZ_CRASH("Did you forget to override this function?");
+    }
+
     virtual bool ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
                             GLenum format, GLenum type, GLvoid *pixels) {
         return false;
     }
 
-    virtual void LockProd();
-    virtual void UnlockProd();
+    virtual void LockProd() MOZ_OVERRIDE;
+    virtual void UnlockProd() MOZ_OVERRIDE;
 
     GLContext* GL() const {
         return mGL;
     }
 };
 
 class SurfaceFactory_GL
     : public gfx::SurfaceFactory
@@ -144,29 +159,28 @@ protected:
                         const gfx::IntSize& size,
                         bool hasAlpha,
                         gfx::SurfaceFormat format,
                         GLuint tex);
 
 public:
     virtual ~SharedSurface_Basic();
 
-    virtual void LockProdImpl() {}
-    virtual void UnlockProdImpl() {}
+    virtual void LockProdImpl() MOZ_OVERRIDE {}
+    virtual void UnlockProdImpl() MOZ_OVERRIDE {}
 
 
-    virtual void Fence();
+    virtual void Fence() MOZ_OVERRIDE;
 
-    virtual bool WaitSync() {
+    virtual bool WaitSync() MOZ_OVERRIDE {
         // Since we already store the data in Fence, we're always done already.
         return true;
     }
 
-
-    virtual GLuint Texture() const {
+    virtual GLuint ProdTexture() MOZ_OVERRIDE {
         return mTex;
     }
 
     // Implementation-specific functions below:
     gfx::DataSourceSurface* GetData() {
         return mData;
     }
 };
@@ -174,17 +188,17 @@ public:
 class SurfaceFactory_Basic
     : public SurfaceFactory_GL
 {
 public:
     SurfaceFactory_Basic(GLContext* gl, const SurfaceCaps& caps)
         : SurfaceFactory_GL(gl, SharedSurfaceType::Basic, caps)
     {}
 
-    virtual SharedSurface* CreateShared(const gfx::IntSize& size) {
+    virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
         bool hasAlpha = mReadCaps.alpha;
         return SharedSurface_Basic::Create(mGL, mFormats, size, hasAlpha);
     }
 };
 
 
 // Using shared GL textures:
 class SharedSurface_GLTexture
@@ -228,25 +242,25 @@ protected:
         , mSync(0)
         , mMutex("SharedSurface_GLTexture mutex")
     {
     }
 
 public:
     virtual ~SharedSurface_GLTexture();
 
-    virtual void LockProdImpl() {}
-    virtual void UnlockProdImpl() {}
+    virtual void LockProdImpl() MOZ_OVERRIDE {}
+    virtual void UnlockProdImpl() MOZ_OVERRIDE {}
 
 
-    virtual void Fence();
-    virtual bool WaitSync();
+    virtual void Fence() MOZ_OVERRIDE;
+    virtual bool WaitSync() MOZ_OVERRIDE;
 
 
-    virtual GLuint Texture() const {
+    virtual GLuint ProdTexture() MOZ_OVERRIDE {
         return mTex;
     }
 
     // Custom:
     void SetConsumerGL(GLContext* consGL);
 };
 
 class SurfaceFactory_GLTexture
@@ -263,17 +277,17 @@ public:
                              GLContext* consGL,
                              const SurfaceCaps& caps)
         : SurfaceFactory_GL(prodGL, SharedSurfaceType::GLTextureShare, caps)
         , mConsGL(consGL)
     {
         MOZ_ASSERT(consGL != prodGL);
     }
 
-    virtual SharedSurface* CreateShared(const gfx::IntSize& size) {
+    virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
         bool hasAlpha = mReadCaps.alpha;
         return SharedSurface_GLTexture::Create(mGL, mConsGL, mFormats, size, hasAlpha);
     }
 };
 
 } /* namespace gfx */
 } /* namespace mozilla */
 
--- a/gfx/gl/SharedSurfaceGralloc.cpp
+++ b/gfx/gl/SharedSurfaceGralloc.cpp
@@ -147,19 +147,8 @@ SharedSurface_Gralloc::Fence()
     }
 }
 
 bool
 SharedSurface_Gralloc::WaitSync()
 {
     return true;
 }
-
-void
-SharedSurface_Gralloc::LockProdImpl()
-{
-}
-
-void
-SharedSurface_Gralloc::UnlockProdImpl()
-{
-}
-
--- a/gfx/gl/SharedSurfaceGralloc.h
+++ b/gfx/gl/SharedSurfaceGralloc.h
@@ -60,23 +60,23 @@ protected:
         , mProdTex(prodTex)
     {}
 
     static bool HasExtensions(GLLibraryEGL* egl, GLContext* gl);
 
 public:
     virtual ~SharedSurface_Gralloc();
 
-    virtual void Fence();
-    virtual bool WaitSync();
+    virtual void Fence() MOZ_OVERRIDE;
+    virtual bool WaitSync() MOZ_OVERRIDE;
 
-    virtual void LockProdImpl();
-    virtual void UnlockProdImpl();
+    virtual void LockProdImpl() MOZ_OVERRIDE {}
+    virtual void UnlockProdImpl() MOZ_OVERRIDE {}
 
-    virtual GLuint Texture() const {
+    virtual GLuint ProdTexture() MOZ_OVERRIDE {
         return mProdTex;
     }
 
     layers::TextureClient* GetTextureClient() {
         return mTextureClient;
     }
 };
 
@@ -86,17 +86,17 @@ class SurfaceFactory_Gralloc
 protected:
     RefPtr<layers::ISurfaceAllocator> mAllocator;
 
 public:
     SurfaceFactory_Gralloc(GLContext* prodGL,
                            const SurfaceCaps& caps,
                            layers::ISurfaceAllocator* allocator = nullptr);
 
-    virtual SharedSurface* CreateShared(const gfx::IntSize& size) {
+    virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
         bool hasAlpha = mReadCaps.alpha;
         if (!mAllocator) {
             return nullptr;
         }
         return SharedSurface_Gralloc::Create(mGL, mFormats, size, hasAlpha, mAllocator);
     }
 };
 
--- a/gfx/gl/SharedSurfaceIO.h
+++ b/gfx/gl/SharedSurfaceIO.h
@@ -16,36 +16,34 @@ namespace gl {
 
 class SharedSurface_IOSurface : public SharedSurface_GL
 {
 public:
     static SharedSurface_IOSurface* Create(MacIOSurface* surface, GLContext *gl, bool hasAlpha);
 
     ~SharedSurface_IOSurface();
 
-    virtual void LockProdImpl() { }
-    virtual void UnlockProdImpl() { }
+    virtual void LockProdImpl() MOZ_OVERRIDE { }
+    virtual void UnlockProdImpl() MOZ_OVERRIDE { }
 
-    virtual void Fence();
-    virtual bool WaitSync() { return true; }
+    virtual void Fence() MOZ_OVERRIDE;
+    virtual bool WaitSync() MOZ_OVERRIDE { return true; }
 
     virtual bool ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
                             GLenum format, GLenum type, GLvoid *pixels) MOZ_OVERRIDE;
 
-    virtual GLuint Texture() const
-    {
+    virtual GLuint ProdTexture() MOZ_OVERRIDE {
         return mTexture;
     }
 
-    virtual GLenum TextureTarget() const {
+    virtual GLenum ProdTextureTarget() const MOZ_OVERRIDE {
         return LOCAL_GL_TEXTURE_RECTANGLE_ARB;
     }
 
-    static SharedSurface_IOSurface* Cast(SharedSurface *surf)
-    {
+    static SharedSurface_IOSurface* Cast(SharedSurface *surf) {
         MOZ_ASSERT(surf->Type() == SharedSurfaceType::IOSurface);
         return static_cast<SharedSurface_IOSurface*>(surf);
     }
 
     MacIOSurface* GetIOSurface() { return mSurface; }
 
 private:
     SharedSurface_IOSurface(MacIOSurface* surface, GLContext* gl, const gfx::IntSize& size, bool hasAlpha);
--- a/gfx/layers/CopyableCanvasLayer.cpp
+++ b/gfx/layers/CopyableCanvasLayer.cpp
@@ -92,17 +92,17 @@ CopyableCanvasLayer::UpdateTarget(DrawTa
     PaintWithOpacity(aDestTarget, 1.0f, aMaskSurface);
     return;
   }
 
   if (mGLContext) {
     RefPtr<DataSourceSurface> readSurf;
     RefPtr<SourceSurface> resultSurf;
 
-    SharedSurface* sharedSurf = mGLContext->RequestFrame();
+    SharedSurface_GL* sharedSurf = mGLContext->RequestFrame();
     if (!sharedSurf) {
       NS_WARNING("Null frame received.");
       return;
     }
 
     IntSize readSize(sharedSurf->Size());
     SurfaceFormat format = (GetContentFlags() & CONTENT_OPAQUE)
                             ? SurfaceFormat::B8G8R8X8
@@ -187,17 +187,17 @@ CopyableCanvasLayer::DeprecatedUpdateSur
     return;
   }
 
   if (mGLContext) {
     nsRefPtr<gfxImageSurface> readSurf;
     RefPtr<DataSourceSurface> readDSurf;
     nsRefPtr<gfxASurface> resultSurf;
 
-    SharedSurface* sharedSurf = mGLContext->RequestFrame();
+    SharedSurface_GL* sharedSurf = mGLContext->RequestFrame();
     if (!sharedSurf) {
       NS_WARNING("Null frame received.");
       return;
     }
 
     IntSize readSize(sharedSurf->Size());
     gfxImageFormat format = (GetContentFlags() & CONTENT_OPAQUE)
                             ? gfxImageFormat::RGB24
@@ -345,17 +345,17 @@ CopyableCanvasLayer::DeprecatedPaintWith
   // No need to snap here; our transform is already set up to snap our rect
   aContext->Rectangle(gfxRect(0, 0, mBounds.width, mBounds.height));
   aContext->SetPattern(pat);
 
   FillWithMask(aContext, aOpacity, aMaskLayer);
   // Restore surface operator
   if (GetContentFlags() & CONTENT_OPAQUE) {
     aContext->SetOperator(savedOp);
-  }  
+  }
 
   if (mNeedsYFlip) {
     aContext->SetMatrix(m);
   }
 }
 
 DataSourceSurface*
 CopyableCanvasLayer::GetTempSurface(const IntSize& aSize,
--- a/gfx/layers/d3d10/CanvasLayerD3D10.cpp
+++ b/gfx/layers/d3d10/CanvasLayerD3D10.cpp
@@ -6,16 +6,17 @@
 #include "CanvasLayerD3D10.h"
 
 #include "../d3d9/Nv3DVUtils.h"
 #include "gfxImageSurface.h"
 #include "gfxWindowsSurface.h"
 #include "gfxWindowsPlatform.h"
 #include "SurfaceStream.h"
 #include "SharedSurfaceANGLE.h"
+#include "SharedSurfaceGL.h"
 #include "gfxContext.h"
 #include "GLContext.h"
 #include "gfxPrefs.h"
 
 using namespace mozilla::gl;
 using namespace mozilla::gfx;
 
 namespace mozilla {
@@ -73,18 +74,18 @@ CanvasLayerD3D10::Initialize(const Data&
       mTexture = static_cast<ID3D10Texture2D*>(texture);
 
       NS_ASSERTION(!aData.mGLContext,
                    "CanvasLayer can't have both DrawTarget and WebGLContext/Surface");
 
       mBounds.SetRect(0, 0, aData.mSize.width, aData.mSize.height);
       device()->CreateShaderResourceView(mTexture, nullptr, getter_AddRefs(mSRView));
       return;
-    } 
-    
+    }
+
     // XXX we should store mDrawTarget and use it directly in UpdateSurface,
     // bypassing Thebes
     mSurface = mDrawTarget->Snapshot();
   } else {
     NS_ERROR("CanvasLayer created without mSurface, mDrawTarget or mGLContext?");
   }
 
   mBounds.SetRect(0, 0, aData.mSize.width, aData.mSize.height);
@@ -113,17 +114,17 @@ CanvasLayerD3D10::UpdateSurface()
 
   if (mDrawTarget) {
     mDrawTarget->Flush();
   } else if (mIsD2DTexture) {
     return;
   }
 
   if (mGLContext) {
-    SharedSurface* surf = mGLContext->RequestFrame();
+    SharedSurface_GL* surf = mGLContext->RequestFrame();
     if (!surf)
         return;
 
     switch (surf->Type()) {
       case SharedSurfaceType::EGLSurfaceANGLE: {
         SharedSurface_ANGLEShareHandle* shareSurf = SharedSurface_ANGLEShareHandle::Cast(surf);
 
         mSRView = shareSurf->GetSRV();
--- a/gfx/layers/d3d9/CanvasLayerD3D9.cpp
+++ b/gfx/layers/d3d9/CanvasLayerD3D9.cpp
@@ -76,17 +76,17 @@ CanvasLayerD3D9::UpdateSurface()
       NS_WARNING("CanvasLayerD3D9::Updated called but no texture present and creation failed!");
       return;
     }
   }
 
   RefPtr<SourceSurface> surface;
 
   if (mGLContext) {
-    SharedSurface* surf = mGLContext->RequestFrame();
+    SharedSurface_GL* surf = mGLContext->RequestFrame();
     if (!surf)
         return;
 
     SharedSurface_Basic* shareSurf = SharedSurface_Basic::Cast(surf);
     surface = shareSurf->GetData();
   } else {
     surface = mDrawTarget->Snapshot();
   }
@@ -126,17 +126,17 @@ CanvasLayerD3D9::RenderLayer()
     return;
   }
   FireDidTransactionCallback();
 
   if (!mTexture)
     return;
 
   /*
-   * We flip the Y axis here, note we can only do this because we are in 
+   * We flip the Y axis here, note we can only do this because we are in
    * CULL_NONE mode!
    */
 
   ShaderConstantRect quad(0, 0, mBounds.width, mBounds.height);
   if (mNeedsYFlip) {
     quad.mHeight = (float)-mBounds.height;
     quad.mY = (float)mBounds.height;
   }
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -499,18 +499,18 @@ StreamTextureSourceOGL::RetrieveTextureF
 
   mSize = IntSize(sharedSurf->Size().width, sharedSurf->Size().height);
 
   DataSourceSurface* toUpload = nullptr;
   switch (sharedSurf->Type()) {
     case SharedSurfaceType::GLTextureShare: {
       SharedSurface_GLTexture* glTexSurf = SharedSurface_GLTexture::Cast(sharedSurf);
       glTexSurf->SetConsumerGL(gl());
-      mTextureHandle = glTexSurf->Texture();
-      mTextureTarget = glTexSurf->TextureTarget();
+      mTextureHandle = glTexSurf->ProdTexture();
+      mTextureTarget = glTexSurf->ProdTextureTarget();
       MOZ_ASSERT(mTextureHandle);
       mFormat = sharedSurf->HasAlpha() ? SurfaceFormat::R8G8B8A8
                                        : SurfaceFormat::R8G8B8X8;
       break;
     }
     case SharedSurfaceType::EGLImageShare: {
       SharedSurface_EGLImage* eglImageSurf =
           SharedSurface_EGLImage::Cast(sharedSurf);
@@ -519,18 +519,18 @@ StreamTextureSourceOGL::RetrieveTextureF
       MOZ_ASSERT(mTextureHandle);
       mFormat = sharedSurf->HasAlpha() ? SurfaceFormat::R8G8B8A8
                                        : SurfaceFormat::R8G8B8X8;
       break;
     }
 #ifdef XP_MACOSX
     case SharedSurfaceType::IOSurface: {
       SharedSurface_IOSurface* glTexSurf = SharedSurface_IOSurface::Cast(sharedSurf);
-      mTextureHandle = glTexSurf->Texture();
-      mTextureTarget = glTexSurf->TextureTarget();
+      mTextureHandle = glTexSurf->ProdTexture();
+      mTextureTarget = glTexSurf->ProdTextureTarget();
       MOZ_ASSERT(mTextureHandle);
       mFormat = sharedSurf->HasAlpha() ? SurfaceFormat::R8G8B8A8
                                        : SurfaceFormat::R8G8B8X8;
       break;
     }
 #endif
     case SharedSurfaceType::Basic: {
       toUpload = SharedSurface_Basic::Cast(sharedSurf)->GetData();