Bug 900133 - Recreate the TextureClient for an ImageClient if the image size changes. r=nical
☠☠ backed out by 5695cebb5c12 ☠ ☠
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 02 Aug 2013 22:59:26 -0400
changeset 153565 a857a4246dd988ee8273e1f99a0c0d6d50cb6c59
parent 153564 e0e2e27af6c130aa0dbbcef50b20787c11519507
child 153566 67c3e4204e442e5d0e14b52c4397bb290e2a10ae
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)
reviewersnical
bugs900133
milestone25.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 900133 - Recreate the TextureClient for an ImageClient if the image size changes. r=nical
gfx/layers/client/ImageClient.cpp
gfx/layers/client/TextureClient.cpp
gfx/layers/client/TextureClient.h
gfx/layers/opengl/TextureClientOGL.h
--- a/gfx/layers/client/ImageClient.cpp
+++ b/gfx/layers/client/ImageClient.cpp
@@ -141,26 +141,28 @@ ImageClientSingle::UpdateImage(ImageCont
       MOZ_ASSERT(false);
       return false;
     }
 
   } else {
     nsRefPtr<gfxASurface> surface = image->GetAsSurface();
     MOZ_ASSERT(surface);
 
-    if (mFrontBuffer && mFrontBuffer->IsImmutable()) {
+    gfx::IntSize size = gfx::IntSize(image->GetSize().width, image->GetSize().height);
+
+    if (mFrontBuffer &&
+        (mFrontBuffer->IsImmutable() || mFrontBuffer->GetSize() != size)) {
       RemoveTextureClient(mFrontBuffer);
       mFrontBuffer = nullptr;
     }
 
     if (!mFrontBuffer) {
       gfxASurface::gfxImageFormat format
         = gfxPlatform::GetPlatform()->OptimalFormatForContent(surface->GetContentType());
       mFrontBuffer = CreateBufferTextureClient(gfx::ImageFormatToSurfaceFormat(format));
-      gfx::IntSize size = gfx::IntSize(image->GetSize().width, image->GetSize().height);
       MOZ_ASSERT(mFrontBuffer->AsTextureClientSurface());
       mFrontBuffer->AsTextureClientSurface()->AllocateForSurface(size);
 
       AddTextureClient(mFrontBuffer);
     }
 
     if (!mFrontBuffer->Lock(OPEN_READ_WRITE)) {
       return false;
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -182,16 +182,17 @@ BufferTextureClient::AllocateForSurface(
 
   int bufSize
     = ImageDataSerializer::ComputeMinBufferSize(aSize, mFormat);
   if (!Allocate(bufSize)) {
     return false;
   }
   ImageDataSerializer serializer(GetBuffer());
   serializer.InitializeBufferInfo(aSize, mFormat);
+  mSize = aSize;
   return true;
 }
 
 bool
 BufferTextureClient::UpdateYCbCr(const PlanarYCbCrImage::Data& aData)
 {
   MOZ_ASSERT(mFormat == gfx::FORMAT_YUV, "This textureClient can only use YCbCr data");
   MOZ_ASSERT(!IsImmutable());
@@ -215,16 +216,17 @@ BufferTextureClient::AllocateForYCbCr(gf
   size_t bufSize = YCbCrImageDataSerializer::ComputeMinBufferSize(aYSize,
                                                                   aCbCrSize);
   if (!Allocate(bufSize)) {
     return false;
   }
   YCbCrImageDataSerializer serializer(GetBuffer());
   serializer.InitializeBufferInfo(aYSize,
                                   aCbCrSize);
+  mSize = aYSize;
   return true;
 }
 
 
 
 
 
 
--- a/gfx/layers/client/TextureClient.h
+++ b/gfx/layers/client/TextureClient.h
@@ -119,16 +119,18 @@ public:
   {
     return mNextSibling;
   }
 
   virtual bool IsAllocated() const = 0;
 
   virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor) = 0;
 
+  virtual gfx::IntSize GetSize() const = 0;
+
   void SetFlags(TextureFlags aFlags)
   {
     MOZ_ASSERT(!IsSharedWithCompositor());
     mFlags = aFlags;
   }
 
   void AddFlags(TextureFlags  aFlags)
   {
@@ -188,16 +190,18 @@ public:
   virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor) = 0;
 
   virtual bool Allocate(uint32_t aSize) = 0;
 
   virtual uint8_t* GetBuffer() const = 0;
 
   virtual size_t GetBufferSize() const = 0;
 
+  virtual gfx::IntSize GetSize() const { return mSize; }
+
   // TextureClientSurface
 
   virtual TextureClientSurface* AsTextureClientSurface() MOZ_OVERRIDE { return this; }
 
   virtual bool UpdateSurface(gfxASurface* aSurface) MOZ_OVERRIDE;
 
   virtual bool AllocateForSurface(gfx::IntSize aSize) MOZ_OVERRIDE;
 
@@ -209,16 +213,17 @@ public:
 
   virtual bool AllocateForYCbCr(gfx::IntSize aYSize, gfx::IntSize aCbCrSize) MOZ_OVERRIDE;
 
   gfx::SurfaceFormat GetFormat() const { return mFormat; }
 
 protected:
   CompositableClient* mCompositable;
   gfx::SurfaceFormat mFormat;
+  gfx::IntSize mSize;
 };
 
 /**
  * TextureClient that wraps shared memory.
  * the corresponding texture on the host side is ShmemTextureHost.
  */
 class ShmemTextureClient : public BufferTextureClient
 {
--- a/gfx/layers/opengl/TextureClientOGL.h
+++ b/gfx/layers/opengl/TextureClientOGL.h
@@ -34,17 +34,17 @@ public:
 
   virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE;
 
   void InitWith(gl::SharedTextureHandle aHandle,
                 gfx::IntSize aSize,
                 bool aIsCrossProcess = false,
                 bool aInverted = false);
 
-  gfx::IntSize GetSize() const { return mSize; }
+  virtual gfx::IntSize GetSize() const { return mSize; }
 
 protected:
   gfx::IntSize mSize;
   gl::SharedTextureHandle mHandle;
   bool mIsCrossProcess;
   bool mInverted;
 };