Backed out changeset 9a5f4bbd4fcb (bug 900188) to see if it fixes the OSX crashtest and reftest asserts.
authorRyan VanderMeulen <ryanvm@gmail.com>
Fri, 02 Aug 2013 00:45:09 -0400
changeset 153354 f38eafe79c95b4c549d6847fba8f1ee95492595d
parent 153353 18b2dd40f9a0f854bfb4bec8593bd65888bd4028
child 153355 5e1009e4b1e1b77c88ac1db43c158660107289f8
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs900188
milestone25.0a1
backs out9a5f4bbd4fcb22379cb2fe7f50a4326f0ca9fdf8
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
Backed out changeset 9a5f4bbd4fcb (bug 900188) to see if it fixes the OSX crashtest and reftest asserts. CLOSED TREE
gfx/layers/client/CanvasClient.cpp
gfx/layers/client/CanvasClient.h
gfx/layers/client/ClientCanvasLayer.cpp
gfx/layers/client/ClientCanvasLayer.h
gfx/layers/opengl/TextureHostOGL.cpp
gfx/layers/opengl/TextureHostOGL.h
--- a/gfx/layers/client/CanvasClient.cpp
+++ b/gfx/layers/client/CanvasClient.cpp
@@ -17,25 +17,30 @@
 #endif
 
 using namespace mozilla::gl;
 
 namespace mozilla {
 namespace layers {
 
 /* static */ TemporaryRef<CanvasClient>
-CanvasClient::CreateCanvasClient(CanvasClientType aType,
+CanvasClient::CreateCanvasClient(CompositableType aCompositableHostType,
                                  CompositableForwarder* aForwarder,
                                  TextureFlags aFlags)
 {
-  if (aType == CanvasClientGLContext &&
-      aForwarder->GetCompositorBackendType() == LAYERS_OPENGL) {
-    return new CanvasClientSurfaceStream(aForwarder, aFlags);
+  if (aCompositableHostType == BUFFER_IMAGE_SINGLE) {
+    return new CanvasClient2D(aForwarder, aFlags);
   }
-  return new CanvasClient2D(aForwarder, aFlags);
+  if (aCompositableHostType == BUFFER_IMAGE_BUFFERED) {
+    if (aForwarder->GetCompositorBackendType() == LAYERS_OPENGL) {
+      return new CanvasClientWebGL(aForwarder, aFlags);
+    }
+    return new CanvasClient2D(aForwarder, aFlags);
+  }
+  return nullptr;
 }
 
 void
 CanvasClient::Updated()
 {
   mForwarder->UpdateTexture(this, 1, mDeprecatedTextureClient->GetDescriptor());
 }
 
@@ -62,42 +67,38 @@ CanvasClient2D::Update(gfx::IntSize aSiz
   mDeprecatedTextureClient->EnsureAllocated(aSize, contentType);
 
   gfxASurface* surface = mDeprecatedTextureClient->LockSurface();
   aLayer->UpdateSurface(surface);
   mDeprecatedTextureClient->Unlock();
 }
 
 void
-CanvasClientSurfaceStream::Updated()
+CanvasClientWebGL::Updated()
 {
-  if (mNeedsUpdate) {
-    mForwarder->UpdateTextureNoSwap(this, 1, mDeprecatedTextureClient->GetDescriptor());
-    mNeedsUpdate = false;
-  }
+  mForwarder->UpdateTextureNoSwap(this, 1, mDeprecatedTextureClient->GetDescriptor());
 }
 
 
-CanvasClientSurfaceStream::CanvasClientSurfaceStream(CompositableForwarder* aFwd,
-                                                     TextureFlags aFlags)
+CanvasClientWebGL::CanvasClientWebGL(CompositableForwarder* aFwd,
+                                     TextureFlags aFlags)
 : CanvasClient(aFwd, aFlags)
-, mNeedsUpdate(false)
 {
-  mTextureInfo.mCompositableType = BUFFER_IMAGE_SINGLE;
+  mTextureInfo.mCompositableType = BUFFER_IMAGE_BUFFERED;
 }
 
 void
-CanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
+CanvasClientWebGL::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
 {
   if (!mDeprecatedTextureClient) {
     mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_STREAM_GL);
     MOZ_ASSERT(mDeprecatedTextureClient, "Failed to create texture client");
   }
 
-  NS_ASSERTION(aLayer->mGLContext, "CanvasClientSurfaceStream should only be used with GL canvases");
+  NS_ASSERTION(aLayer->mGLContext, "CanvasClientWebGL should only be used with GL canvases");
 
   // the content type won't be used
   mDeprecatedTextureClient->EnsureAllocated(aSize, gfxASurface::CONTENT_COLOR);
 
   GLScreenBuffer* screen = aLayer->mGLContext->Screen();
   SurfaceStream* stream = screen->Stream();
 
   bool isCrossProcess = !(XRE_GetProcessType() == GeckoProcessType_Default);
@@ -116,30 +117,24 @@ CanvasClientSurfaceStream::Update(gfx::I
     }
 
     SharedSurface_Gralloc* grallocSurf = SharedSurface_Gralloc::Cast(surf);
     mDeprecatedTextureClient->SetDescriptor(grallocSurf->GetDescriptor());
 #else
     printf_stderr("isCrossProcess, but not MOZ_WIDGET_GONK! Someone needs to write some code!");
     MOZ_ASSERT(false);
 #endif
-    mNeedsUpdate = true;
   } else {
     SurfaceStreamHandle handle = stream->GetShareHandle();
-    SurfaceDescriptor *desc = mDeprecatedTextureClient->GetDescriptor();
-    if (desc->type() != SurfaceDescriptor::TSurfaceStreamDescriptor ||
-        desc->get_SurfaceStreamDescriptor().handle() != handle) {
-      *desc = SurfaceStreamDescriptor(handle, false);
+    mDeprecatedTextureClient->SetDescriptor(SurfaceStreamDescriptor(handle, false));
 
-      // Bug 894405
-      //
-      // Ref this so the SurfaceStream doesn't disappear unexpectedly. The
-      // Compositor will need to unref it when finished.
-      aLayer->mGLContext->AddRef();
-      mNeedsUpdate = true;
-    }
+    // Bug 894405
+    //
+    // Ref this so the SurfaceStream doesn't disappear unexpectedly. The
+    // Compositor will need to unref it when finished.
+    aLayer->mGLContext->AddRef();
   }
 
   aLayer->Painted();
 }
 
 }
 }
--- a/gfx/layers/client/CanvasClient.h
+++ b/gfx/layers/client/CanvasClient.h
@@ -21,21 +21,17 @@ class ClientCanvasLayer;
 class CanvasClient : public CompositableClient
 {
 public:
   /**
    * Creates, configures, and returns a new canvas client. If necessary, a
    * message will be sent to the compositor to create a corresponding image
    * host.
    */
-  enum CanvasClientType {
-    CanvasClientSurface,
-    CanvasClientGLContext,
-  };
-  static TemporaryRef<CanvasClient> CreateCanvasClient(CanvasClientType aType,
+  static TemporaryRef<CanvasClient> CreateCanvasClient(CompositableType aImageHostType,
                                                        CompositableForwarder* aFwd,
                                                        TextureFlags aFlags);
 
   CanvasClient(CompositableForwarder* aFwd, TextureFlags aFlags)
     : CompositableClient(aFwd)
   {
     mTextureInfo.mTextureFlags = aFlags;
   }
@@ -68,30 +64,27 @@ public:
     return mTextureInfo;
   }
 
   virtual void Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer);
 };
 
 // Used for GL canvases where we don't need to do any readback, i.e., with a
 // GL backend.
-class CanvasClientSurfaceStream : public CanvasClient
+class CanvasClientWebGL : public CanvasClient
 {
 public:
-  CanvasClientSurfaceStream(CompositableForwarder* aFwd,
-                            TextureFlags aFlags);
+  CanvasClientWebGL(CompositableForwarder* aFwd,
+                    TextureFlags aFlags);
 
   TextureInfo GetTextureInfo() const MOZ_OVERRIDE
   {
     return mTextureInfo;
   }
 
   virtual void Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer);
   virtual void Updated() MOZ_OVERRIDE;
-
-private:
-  bool mNeedsUpdate;
 };
 
 }
 }
 
 #endif
--- a/gfx/layers/client/ClientCanvasLayer.cpp
+++ b/gfx/layers/client/ClientCanvasLayer.cpp
@@ -89,17 +89,17 @@ ClientCanvasLayer::RenderLayer()
     bool isCrossProcess = !(XRE_GetProcessType() == GeckoProcessType_Default);
     //Append TEXTURE_DEALLOCATE_CLIENT flag for streaming buffer under OOPC case
     if (isCrossProcess && mGLContext) {
       GLScreenBuffer* screen = mGLContext->Screen();
       if (screen && screen->Stream()) {
         flags |= TEXTURE_DEALLOCATE_CLIENT;
       }
     }
-    mCanvasClient = CanvasClient::CreateCanvasClient(GetCanvasClientType(),
+    mCanvasClient = CanvasClient::CreateCanvasClient(GetCompositableClientType(),
                                                      ClientManager(), flags);
     if (!mCanvasClient) {
       return;
     }
     if (HasShadow()) {
       mCanvasClient->Connect();
       ClientManager()->Attach(mCanvasClient, this);
     }
--- a/gfx/layers/client/ClientCanvasLayer.h
+++ b/gfx/layers/client/ClientCanvasLayer.h
@@ -20,17 +20,16 @@ namespace mozilla {
 namespace layers {
 
 class CanvasClient2D;
 class CanvasClientWebGL;
 
 class ClientCanvasLayer : public CopyableCanvasLayer,
                           public ClientLayer
 {
-  typedef CanvasClient::CanvasClientType CanvasClientType;
 public:
   ClientCanvasLayer(ClientLayerManager* aLayerManager) :
     CopyableCanvasLayer(aLayerManager, static_cast<ClientLayer*>(this))
   {
     MOZ_COUNT_CTOR(ClientCanvasLayer);
   }
   virtual ~ClientCanvasLayer()
   {
@@ -71,25 +70,25 @@ public:
     return mCanvasClient;
   }
 protected:
   ClientLayerManager* ClientManager()
   {
     return static_cast<ClientLayerManager*>(mManager);
   }
   
-  CanvasClientType GetCanvasClientType()
+  CompositableType GetCompositableClientType()
   {
     if (mGLContext) {
-      return CanvasClient::CanvasClientGLContext;
+      return BUFFER_IMAGE_BUFFERED;
     }
-    return CanvasClient::CanvasClientSurface;
+    return BUFFER_IMAGE_SINGLE;
   }
 
   RefPtr<CanvasClient> mCanvasClient;
 
   friend class CanvasClient2D;
-  friend class CanvasClientSurfaceStream;
+  friend class CanvasClientWebGL;
 };
 }
 }
 
 #endif
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -587,48 +587,59 @@ SurfaceStreamHostOGL::DeleteTextures()
     mGL->MakeCurrent();
     mGL->fDeleteTextures(1, &mUploadTexture);
     mUploadTexture = 0;
     mTextureHandle = 0;
   }
 }
 
 void
-SurfaceStreamHostOGL::UpdateImpl(const SurfaceDescriptor& aImage,
-                                 nsIntRegion* aRegion,
-                                 nsIntPoint* aOffset)
+SurfaceStreamHostOGL::SwapTexturesImpl(const SurfaceDescriptor& aImage,
+                                       nsIntRegion* aRegion)
 {
   MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TSurfaceStreamDescriptor,
              "Invalid descriptor");
 
-  // Bug 894405
-  //
-  // The SurfaceStream's GLContext was refed before being passed up to us, so
-  // we need to ensure it gets unrefed when we are finished.
-  const SurfaceStreamDescriptor& streamDesc =
-      aImage.get_SurfaceStreamDescriptor();
+  mStreamGL = nullptr;
 
-  mStream = SurfaceStream::FromHandle(streamDesc.handle());
-  MOZ_ASSERT(mStream);
-  mStreamGL = dont_AddRef(mStream->GLContext());
+  if (aImage.type() == SurfaceDescriptor::TSurfaceStreamDescriptor) {
+    // Bug 894405
+    //
+    // The SurfaceStream's GLContext was refed before being passed up to us, so
+    // we need to ensure it gets unrefed when we are finished.
+    const SurfaceStreamDescriptor& streamDesc =
+        aImage.get_SurfaceStreamDescriptor();
+
+    SurfaceStream* surfStream = SurfaceStream::FromHandle(streamDesc.handle());
+    if (surfStream) {
+      mStreamGL = dont_AddRef(surfStream->GLContext());
+    }
+  } 
 }
 
 void
 SurfaceStreamHostOGL::Unlock()
 {
   // We don't know what this is unless we're locked
   mFormat = gfx::FORMAT_UNKNOWN;
 }
 
 bool
 SurfaceStreamHostOGL::Lock()
 {
   mGL->MakeCurrent();
+  SurfaceStream* surfStream = nullptr;
+  SharedSurface* sharedSurf = nullptr;
+  const SurfaceStreamDescriptor& streamDesc =
+    mBuffer->get_SurfaceStreamDescriptor();
 
-  SharedSurface* sharedSurf = mStream->SwapConsumer();
+  surfStream = SurfaceStream::FromHandle(streamDesc.handle());
+  MOZ_ASSERT(surfStream);
+
+  sharedSurf = surfStream->SwapConsumer();
   if (!sharedSurf) {
     // We don't have a valid surf to show yet.
     return false;
   }
 
   mGL->MakeCurrent();
 
   mSize = IntSize(sharedSurf->Size().width, sharedSurf->Size().height);
--- a/gfx/layers/opengl/TextureHostOGL.h
+++ b/gfx/layers/opengl/TextureHostOGL.h
@@ -647,16 +647,17 @@ class SurfaceStreamHostOGL : public Depr
 public:
   typedef gfxASurface::gfxContentType ContentType;
   typedef mozilla::gl::GLContext GLContext;
   typedef mozilla::gl::TextureImage TextureImage;
 
   virtual ~SurfaceStreamHostOGL()
   {
     DeleteTextures();
+    *mBuffer = SurfaceDescriptor();
   }
 
   virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
 
   virtual GLuint GetTextureHandle()
   {
     return mTextureHandle;
   }
@@ -666,19 +667,18 @@ public:
     return DeprecatedTextureHost::GetFormat();
   }
 
   virtual TextureSourceOGL* AsSourceOGL() MOZ_OVERRIDE { return this; }
 
   bool IsValid() const MOZ_OVERRIDE { return true; }
 
   // override from DeprecatedTextureHost
-  virtual void UpdateImpl(const SurfaceDescriptor& aImage,
-                          nsIntRegion* aRegion,
-                          nsIntPoint* aOffset);
+  virtual void SwapTexturesImpl(const SurfaceDescriptor& aImage,
+                                nsIntRegion* aRegion = nullptr) MOZ_OVERRIDE;
   virtual bool Lock() MOZ_OVERRIDE;
   virtual void Unlock() MOZ_OVERRIDE;
 
   virtual GLenum GetWrapMode() const MOZ_OVERRIDE {
     return mWrapMode;
   }
   virtual void SetWrapMode(GLenum aMode) {
     mWrapMode = aMode;
@@ -715,30 +715,28 @@ public:
 #endif
 
   SurfaceStreamHostOGL()
     : mGL(nullptr)
     , mTextureHandle(0)
     , mTextureTarget(LOCAL_GL_TEXTURE_2D)
     , mUploadTexture(0)
     , mWrapMode(LOCAL_GL_CLAMP_TO_EDGE)
-    , mStream(nullptr)
   {}
 
 protected:
   void DeleteTextures();
 
   gfx::IntSize mSize;
   nsRefPtr<GLContext> mGL;
   GLuint mTextureHandle;
   GLenum mTextureTarget;
   GLuint mUploadTexture;
   GLenum mWrapMode;
   nsRefPtr<GLContext> mStreamGL;
-  gfx::SurfaceStream *mStream;
 };
 
 class TiledDeprecatedTextureHostOGL : public DeprecatedTextureHost
                           , public TextureSourceOGL
 {
 public:
   TiledDeprecatedTextureHostOGL()
     : mTextureHandle(0)