Backed out 6 changesets (bug 900133, bug 881634, bug 893302) for build bustage
authorWes Kocher <wkocher@mozilla.com>
Fri, 02 Aug 2013 20:35:39 -0700
changeset 153573 5695cebb5c12a6bda4927efe48fdeb51568fd8d0
parent 153572 b27b567e0bdc82a95311b7f69f3c8a05c20429ef
child 153574 ce984b387db8cbd7d21712dbea231696ac3e6e2b
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)
bugs900133, 881634, 893302
milestone25.0a1
backs out49632bc14e27b72322a2f62453bd27cf1f5de7c5
036780fccc893db9b35d08b78b6621ceb00d736d
b8db58f5e209bc5cee999f827c07fff31cc3875a
67c3e4204e442e5d0e14b52c4397bb290e2a10ae
a857a4246dd988ee8273e1f99a0c0d6d50cb6c59
e0e2e27af6c130aa0dbbcef50b20787c11519507
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 6 changesets (bug 900133, bug 881634, bug 893302) for build bustage Backed out changeset 49632bc14e27 (bug 900133) Backed out changeset 036780fccc89 (bug 900133) Backed out changeset b8db58f5e209 (bug 893302) Backed out changeset 67c3e4204e44 (bug 893302) Backed out changeset a857a4246dd9 (bug 900133) Backed out changeset e0e2e27af6c1 (bug 881634)
gfx/2d/DrawTargetSkia.cpp
gfx/2d/DrawTargetSkia.h
gfx/2d/SourceSurfaceSkia.cpp
gfx/2d/SourceSurfaceSkia.h
gfx/layers/CompositorTypes.h
gfx/layers/client/CanvasClient.cpp
gfx/layers/client/CanvasClient.h
gfx/layers/client/ClientCanvasLayer.cpp
gfx/layers/client/ClientCanvasLayer.h
gfx/layers/client/ClientImageLayer.cpp
gfx/layers/client/CompositableClient.cpp
gfx/layers/client/CompositableClient.h
gfx/layers/client/ImageClient.cpp
gfx/layers/client/ImageClient.h
gfx/layers/client/TextureClient.cpp
gfx/layers/client/TextureClient.h
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/TextureHost.h
gfx/layers/ipc/ShadowLayers.cpp
gfx/layers/opengl/TextureClientOGL.h
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -71,41 +71,39 @@ public:
 
   std::vector<SkColor> mColors;
   std::vector<SkScalar> mPositions;
   int mCount;
   ExtendMode mExtendMode;
 };
 
 DrawTargetSkia::DrawTargetSkia()
-  : mSnapshot(nullptr)
 {
 #ifdef ANDROID
   mSoftClipping = false;
 #else
   mSoftClipping = true;
 #endif
 }
 
 DrawTargetSkia::~DrawTargetSkia()
 {
+  MOZ_ASSERT(mSnapshots.size() == 0);
 }
 
 TemporaryRef<SourceSurface>
 DrawTargetSkia::Snapshot()
 {
-  RefPtr<SourceSurfaceSkia> snapshot = mSnapshot;
-  if (!snapshot) {
-    snapshot = new SourceSurfaceSkia();
-    mSnapshot = snapshot;
-    if (!snapshot->InitFromCanvas(mCanvas.get(), mFormat, this))
-      return nullptr;
-  }
+  RefPtr<SourceSurfaceSkia> source = new SourceSurfaceSkia();
 
-  return snapshot;
+  if (!source->InitFromCanvas(mCanvas.get(), mFormat, this))
+    return nullptr;
+
+  AppendSnapshot(source);
+  return source;
 }
 
 void SetPaintPattern(SkPaint& aPaint, const Pattern& aPattern, Float aAlpha = 1.0)
 {
   switch (aPattern.GetType()) {
     case PATTERN_COLOR: {
       Color color = static_cast<const ColorPattern&>(aPattern).mColor;
       aPaint.setColor(ColorToSkColor(color, aAlpha));
@@ -770,24 +768,37 @@ DrawTargetSkia::CreateGradientStops(Grad
     stops[i] = aStops[i];
   }
   std::stable_sort(stops.begin(), stops.end());
   
   return new GradientStopsSkia(stops, aNumStops, aExtendMode);
 }
 
 void
-DrawTargetSkia::MarkChanged()
+DrawTargetSkia::AppendSnapshot(SourceSurfaceSkia* aSnapshot)
 {
-  if (mSnapshot) {
-    mSnapshot->DrawTargetWillChange();
-    mSnapshot = nullptr;
+  mSnapshots.push_back(aSnapshot);
+}
+
+void
+DrawTargetSkia::RemoveSnapshot(SourceSurfaceSkia* aSnapshot)
+{
+  std::vector<SourceSurfaceSkia*>::iterator iter = std::find(mSnapshots.begin(), mSnapshots.end(), aSnapshot);
+  if (iter != mSnapshots.end()) {
+    mSnapshots.erase(iter);
   }
 }
 
 void
-DrawTargetSkia::SnapshotDestroyed()
+DrawTargetSkia::MarkChanged()
 {
-  mSnapshot = nullptr;
+  if (mSnapshots.size()) {
+    for (std::vector<SourceSurfaceSkia*>::iterator iter = mSnapshots.begin();
+         iter != mSnapshots.end(); iter++) {
+      (*iter)->DrawTargetWillChange();
+    }
+    // All snapshots will now have copied data.
+    mSnapshots.clear();
+  }
 }
 
 }
 }
--- a/gfx/2d/DrawTargetSkia.h
+++ b/gfx/2d/DrawTargetSkia.h
@@ -109,17 +109,18 @@ public:
   operator std::string() const {
     std::stringstream stream;
     stream << "DrawTargetSkia(" << this << ")";
     return stream.str();
   }
 
 private:
   friend class SourceSurfaceSkia;
-  void SnapshotDestroyed();
+  void AppendSnapshot(SourceSurfaceSkia* aSnapshot);
+  void RemoveSnapshot(SourceSurfaceSkia* aSnapshot);
 
   void MarkChanged();
 
 #ifdef USE_SKIA_GPU
   /*
    * These members have inter-dependencies, but do not keep each other alive, so
    * destruction order is very important here: mGrContext uses mGrGLInterface, and
    * through it, uses mGLContext, so it is important that they be declared in the
@@ -127,14 +128,14 @@ private:
    */
   RefPtr<GenericRefCountedBase> mGLContext;
   SkRefPtr<GrGLInterface> mGrGLInterface;
   SkRefPtr<GrContext> mGrContext;
 #endif
 
   IntSize mSize;
   SkRefPtr<SkCanvas> mCanvas;
-  SourceSurfaceSkia* mSnapshot;
+  std::vector<SourceSurfaceSkia*> mSnapshots;
   bool mSoftClipping;
 };
 
 }
 }
--- a/gfx/2d/SourceSurfaceSkia.cpp
+++ b/gfx/2d/SourceSurfaceSkia.cpp
@@ -17,20 +17,17 @@ namespace gfx {
 SourceSurfaceSkia::SourceSurfaceSkia()
   : mDrawTarget(nullptr), mLocked(false)
 {
 }
 
 SourceSurfaceSkia::~SourceSurfaceSkia()
 {
   MaybeUnlock();
-  if (mDrawTarget) {
-    mDrawTarget->SnapshotDestroyed();
-    mDrawTarget = nullptr;
-  }
+  MarkIndependent();
 }
 
 IntSize
 SourceSurfaceSkia::GetSize() const
 {
   return mSize;
 }
 
@@ -107,16 +104,25 @@ SourceSurfaceSkia::DrawTargetWillChange(
     mDrawTarget = nullptr;
     SkBitmap temp = mBitmap;
     mBitmap.reset();
     temp.copyTo(&mBitmap, temp.getConfig());
   }
 }
 
 void
+SourceSurfaceSkia::MarkIndependent()
+{
+  if (mDrawTarget) {
+    mDrawTarget->RemoveSnapshot(this);
+    mDrawTarget = nullptr;
+  }
+}
+
+void
 SourceSurfaceSkia::MaybeUnlock()
 {
   if (mLocked) {
     mBitmap.unlockPixels();
     mLocked = false;
   }
 }
 
--- a/gfx/2d/SourceSurfaceSkia.h
+++ b/gfx/2d/SourceSurfaceSkia.h
@@ -40,16 +40,18 @@ public:
   virtual unsigned char *GetData();
 
   virtual int32_t Stride() { return mStride; }
 
 private:
   friend class DrawTargetSkia;
 
   void DrawTargetWillChange();
+  void DrawTargetDestroyed();
+  void MarkIndependent();
   void MaybeUnlock();
 
   SkBitmap mBitmap;
   SurfaceFormat mFormat;
   IntSize mSize;
   int32_t mStride;
   RefPtr<DrawTargetSkia> mDrawTarget;
   bool mLocked;
--- a/gfx/layers/CompositorTypes.h
+++ b/gfx/layers/CompositorTypes.h
@@ -62,40 +62,21 @@ const TextureFlags TEXTURE_COPY_PREVIOUS
 // be a choice from another part of gecko that wants to keep the data alive
 // for some reason. The default behaviour is to deallocate on the host side.
 const TextureFlags TEXTURE_DEALLOCATE_CLIENT  = 1 << 25;
 const TextureFlags TEXTURE_DEALLOCATE_HOST    = 1 << 26;
 // After being shared ith the compositor side, an immutable texture is never
 // modified, it can only be read. It is safe to not Lock/Unlock immutable
 // textures.
 const TextureFlags TEXTURE_IMMUTABLE          = 1 << 27;
-// The contents of the texture must be uploaded or copied immediately
-// during the transaction, because the producer may want to write
-// to it again.
-const TextureFlags TEXTURE_IMMEDIATE_UPLOAD   = 1 << 28;
-// The texture is going to be used as part of a double
-// buffered pair, and so we can guarantee that the producer/consumer
-// won't be racing to access its contents.
-const TextureFlags TEXTURE_DOUBLE_BUFFERED    = 1 << 29;
 
 // the default flags
 const TextureFlags TEXTURE_FLAGS_DEFAULT = TEXTURE_DEALLOCATE_HOST
                                          | TEXTURE_FRONT;
 
-static inline bool
-TextureRequiresLocking(TextureFlags aFlags)
-{
-  // If we're not double buffered, or uploading
-  // within a transaction, then we need to support
-  // locking correctly.
-  return !(aFlags & (TEXTURE_IMMEDIATE_UPLOAD |
-                     TEXTURE_DOUBLE_BUFFERED |
-                     TEXTURE_IMMUTABLE));
-}
-
 /**
  * See gfx/layers/Effects.h
  */
 enum EffectTypes
 {
   EFFECT_MASK,
   EFFECT_MAX_SECONDARY, // sentinel for the count of secondary effect types
   EFFECT_BGRX,
--- a/gfx/layers/client/CanvasClient.cpp
+++ b/gfx/layers/client/CanvasClient.cpp
@@ -23,87 +23,37 @@ namespace layers {
 
 /* static */ TemporaryRef<CanvasClient>
 CanvasClient::CreateCanvasClient(CanvasClientType aType,
                                  CompositableForwarder* aForwarder,
                                  TextureFlags aFlags)
 {
   if (aType == CanvasClientGLContext &&
       aForwarder->GetCompositorBackendType() == LAYERS_OPENGL) {
-    return new DeprecatedCanvasClientSurfaceStream(aForwarder, aFlags);
-  }
-  if (gfxPlatform::GetPlatform()->UseDeprecatedTextures()) {
-    return new DeprecatedCanvasClient2D(aForwarder, aFlags);
+    return new CanvasClientSurfaceStream(aForwarder, aFlags);
   }
   return new CanvasClient2D(aForwarder, aFlags);
 }
 
 void
-CanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
-{
-  if (mBuffer &&
-      (mBuffer->IsImmutable() || mBuffer->GetSize() != aSize)) {
-    RemoveTextureClient(mBuffer);
-    mBuffer = nullptr;
-  }
-
-  if (!mBuffer) {
-    bool isOpaque = (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE);
-    gfxASurface::gfxContentType contentType = isOpaque
-                                                ? gfxASurface::CONTENT_COLOR
-                                                : gfxASurface::CONTENT_COLOR_ALPHA;
-    gfxASurface::gfxImageFormat format
-      = gfxPlatform::GetPlatform()->OptimalFormatForContent(contentType);
-    mBuffer = CreateBufferTextureClient(gfx::ImageFormatToSurfaceFormat(format));
-    MOZ_ASSERT(mBuffer->AsTextureClientSurface());
-    mBuffer->AsTextureClientSurface()->AllocateForSurface(aSize);
-
-    AddTextureClient(mBuffer);
-  }
-
-  if (!mBuffer->Lock(OPEN_READ_WRITE)) {
-    return;
-  }
-
-  nsRefPtr<gfxASurface> surface = mBuffer->AsTextureClientSurface()->GetAsSurface();
-  if (surface) {
-    aLayer->UpdateSurface(surface);
-  }
-
-  mBuffer->Unlock();
-
-  if (surface) {
-    GetForwarder()->UpdatedTexture(this, mBuffer, nullptr);
-    GetForwarder()->UseTexture(this, mBuffer);
-  }
-}
-
-TemporaryRef<BufferTextureClient>
-CanvasClient2D::CreateBufferTextureClient(gfx::SurfaceFormat aFormat)
-{
-  return CompositableClient::CreateBufferTextureClient(aFormat,
-                                                       mTextureInfo.mTextureFlags);
-}
-
-void
-DeprecatedCanvasClient2D::Updated()
+CanvasClient::Updated()
 {
   mForwarder->UpdateTexture(this, 1, mDeprecatedTextureClient->GetDescriptor());
 }
 
 
-DeprecatedCanvasClient2D::DeprecatedCanvasClient2D(CompositableForwarder* aFwd,
-                                                   TextureFlags aFlags)
+CanvasClient2D::CanvasClient2D(CompositableForwarder* aFwd,
+                               TextureFlags aFlags)
 : CanvasClient(aFwd, aFlags)
 {
   mTextureInfo.mCompositableType = BUFFER_IMAGE_SINGLE;
 }
 
 void
-DeprecatedCanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
+CanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
 {
   if (!mDeprecatedTextureClient) {
     mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_CONTENT);
     MOZ_ASSERT(mDeprecatedTextureClient, "Failed to create texture client");
   }
 
   bool isOpaque = (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE);
   gfxASurface::gfxContentType contentType = isOpaque
@@ -112,35 +62,35 @@ DeprecatedCanvasClient2D::Update(gfx::In
   mDeprecatedTextureClient->EnsureAllocated(aSize, contentType);
 
   gfxASurface* surface = mDeprecatedTextureClient->LockSurface();
   aLayer->UpdateSurface(surface);
   mDeprecatedTextureClient->Unlock();
 }
 
 void
-DeprecatedCanvasClientSurfaceStream::Updated()
+CanvasClientSurfaceStream::Updated()
 {
   if (mNeedsUpdate) {
     mForwarder->UpdateTextureNoSwap(this, 1, mDeprecatedTextureClient->GetDescriptor());
     mNeedsUpdate = false;
   }
 }
 
 
-DeprecatedCanvasClientSurfaceStream::DeprecatedCanvasClientSurfaceStream(CompositableForwarder* aFwd,
-                                                                         TextureFlags aFlags)
+CanvasClientSurfaceStream::CanvasClientSurfaceStream(CompositableForwarder* aFwd,
+                                                     TextureFlags aFlags)
 : CanvasClient(aFwd, aFlags)
 , mNeedsUpdate(false)
 {
   mTextureInfo.mCompositableType = BUFFER_IMAGE_SINGLE;
 }
 
 void
-DeprecatedCanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
+CanvasClientSurfaceStream::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");
 
--- a/gfx/layers/client/CanvasClient.h
+++ b/gfx/layers/client/CanvasClient.h
@@ -39,103 +39,59 @@ public:
   {
     mTextureInfo.mTextureFlags = aFlags;
   }
 
   virtual ~CanvasClient() {}
 
   virtual void Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer) = 0;
 
-  virtual void Updated() { }
+  virtual void Updated();
 
+  virtual void SetDescriptorFromReply(TextureIdentifier aTextureId,
+                                      const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE
+  {
+    mDeprecatedTextureClient->SetDescriptorFromReply(aDescriptor);
+  }
 protected:
+  RefPtr<DeprecatedTextureClient> mDeprecatedTextureClient;
   TextureInfo mTextureInfo;
 };
 
 // Used for 2D canvases and WebGL canvas on non-GL systems where readback is requried.
 class CanvasClient2D : public CanvasClient
 {
 public:
   CanvasClient2D(CompositableForwarder* aLayerForwarder,
-                 TextureFlags aFlags)
-    : CanvasClient(aLayerForwarder, aFlags)
+                 TextureFlags aFlags);
+
+  TextureInfo GetTextureInfo() const MOZ_OVERRIDE
   {
-  }
-
-  TextureInfo GetTextureInfo() const
-  {
-    return TextureInfo(COMPOSITABLE_IMAGE);
+    return mTextureInfo;
   }
 
-  virtual void Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer) MOZ_OVERRIDE;
-
-  virtual void AddTextureClient(TextureClient* aTexture) MOZ_OVERRIDE
-  {
-    MOZ_ASSERT((mTextureInfo.mTextureFlags & aTexture->GetFlags()) == mTextureInfo.mTextureFlags);
-    CompositableClient::AddTextureClient(aTexture);
-  }
+  virtual void Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer);
+};
 
-  virtual TemporaryRef<BufferTextureClient>
-  CreateBufferTextureClient(gfx::SurfaceFormat aFormat) MOZ_OVERRIDE;
-
-  virtual void Detach() MOZ_OVERRIDE
-  {
-    mBuffer = nullptr;
-  }
-
-private:
-  RefPtr<TextureClient> mBuffer;
-};
-class DeprecatedCanvasClient2D : public CanvasClient
+// Used for GL canvases where we don't need to do any readback, i.e., with a
+// GL backend.
+class CanvasClientSurfaceStream : public CanvasClient
 {
 public:
-  DeprecatedCanvasClient2D(CompositableForwarder* aLayerForwarder,
-                           TextureFlags aFlags);
+  CanvasClientSurfaceStream(CompositableForwarder* aFwd,
+                            TextureFlags aFlags);
 
   TextureInfo GetTextureInfo() const MOZ_OVERRIDE
   {
     return mTextureInfo;
   }
 
   virtual void Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer);
   virtual void Updated() MOZ_OVERRIDE;
 
-  virtual void SetDescriptorFromReply(TextureIdentifier aTextureId,
-                                      const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE
-  {
-    mDeprecatedTextureClient->SetDescriptorFromReply(aDescriptor);
-  }
-
 private:
-  RefPtr<DeprecatedTextureClient> mDeprecatedTextureClient;
-};
-
-// Used for GL canvases where we don't need to do any readback, i.e., with a
-// GL backend.
-class DeprecatedCanvasClientSurfaceStream : public CanvasClient
-{
-public:
-  DeprecatedCanvasClientSurfaceStream(CompositableForwarder* aFwd,
-                                      TextureFlags aFlags);
-
-  TextureInfo GetTextureInfo() const MOZ_OVERRIDE
-  {
-    return mTextureInfo;
-  }
-
-  virtual void Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer);
-  virtual void Updated() MOZ_OVERRIDE;
-
-  virtual void SetDescriptorFromReply(TextureIdentifier aTextureId,
-                                      const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE
-  {
-    mDeprecatedTextureClient->SetDescriptorFromReply(aDescriptor);
-  }
-
-private:
-  RefPtr<DeprecatedTextureClient> mDeprecatedTextureClient;
   bool mNeedsUpdate;
 };
 
 }
 }
 
 #endif
--- a/gfx/layers/client/ClientCanvasLayer.cpp
+++ b/gfx/layers/client/ClientCanvasLayer.cpp
@@ -76,17 +76,17 @@ ClientCanvasLayer::RenderLayer()
     return;
   }
 
   if (GetMaskLayer()) {
     ToClientLayer(GetMaskLayer())->RenderLayer();
   }
   
   if (!mCanvasClient) {
-    TextureFlags flags = TEXTURE_IMMEDIATE_UPLOAD;
+    TextureFlags flags = 0;
     if (mNeedsYFlip) {
       flags |= NeedsYFlip;
     }
 
     bool isCrossProcess = !(XRE_GetProcessType() == GeckoProcessType_Default);
     //Append TEXTURE_DEALLOCATE_CLIENT flag for streaming buffer under OOPC case
     if (isCrossProcess && mGLContext) {
       GLScreenBuffer* screen = mGLContext->Screen();
@@ -107,17 +107,16 @@ ClientCanvasLayer::RenderLayer()
   
   FirePreTransactionCallback();
   mCanvasClient->Update(gfx::IntSize(mBounds.width, mBounds.height), this);
 
   FireDidTransactionCallback();
 
   ClientManager()->Hold(this);
   mCanvasClient->Updated();
-  mCanvasClient->OnTransaction();
 }
 
 already_AddRefed<CanvasLayer>
 ClientLayerManager::CreateCanvasLayer()
 {
   NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
   nsRefPtr<ClientCanvasLayer> layer =
     new ClientCanvasLayer(this);
--- a/gfx/layers/client/ClientCanvasLayer.h
+++ b/gfx/layers/client/ClientCanvasLayer.h
@@ -81,16 +81,15 @@ protected:
     if (mGLContext) {
       return CanvasClient::CanvasClientGLContext;
     }
     return CanvasClient::CanvasClientSurface;
   }
 
   RefPtr<CanvasClient> mCanvasClient;
 
-  friend class DeprecatedCanvasClient2D;
   friend class CanvasClient2D;
-  friend class DeprecatedCanvasClientSurfaceStream;
+  friend class CanvasClientSurfaceStream;
 };
 }
 }
 
 #endif
--- a/gfx/layers/client/ClientImageLayer.cpp
+++ b/gfx/layers/client/ClientImageLayer.cpp
@@ -140,19 +140,16 @@ ClientImageLayer::RenderLayer()
     if (HasShadow() && !mContainer->IsAsync()) {
       mImageClient->Connect();
       ClientManager()->Attach(mImageClient, this);
     }
     if (!mImageClient->UpdateImage(mContainer, GetContentFlags())) {
       return;
     }
   }
-  if (mImageClient) {
-    mImageClient->OnTransaction();
-  }
   ClientManager()->Hold(this);
 }
 
 already_AddRefed<ImageLayer>
 ClientLayerManager::CreateImageLayer()
 {
   NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
   nsRefPtr<ClientImageLayer> layer =
--- a/gfx/layers/client/CompositableClient.cpp
+++ b/gfx/layers/client/CompositableClient.cpp
@@ -142,32 +142,26 @@ CompositableClient::CreateDeprecatedText
   MOZ_ASSERT(result->SupportsType(aDeprecatedTextureClientType),
              "Created the wrong texture client?");
   result->SetFlags(GetTextureInfo().mTextureFlags);
 
   return result.forget();
 }
 
 TemporaryRef<BufferTextureClient>
-CompositableClient::CreateBufferTextureClient(gfx::SurfaceFormat aFormat,
-                                              uint32_t aTextureFlags)
+CompositableClient::CreateBufferTextureClient(gfx::SurfaceFormat aFormat)
 {
   if (gfxPlatform::GetPlatform()->PreferMemoryOverShmem()) {
-    RefPtr<BufferTextureClient> result = new MemoryTextureClient(this, aFormat, aTextureFlags);
+    RefPtr<BufferTextureClient> result = new MemoryTextureClient(this, aFormat);
     return result.forget();
   }
-  RefPtr<BufferTextureClient> result = new ShmemTextureClient(this, aFormat, aTextureFlags);
+  RefPtr<BufferTextureClient> result = new ShmemTextureClient(this, aFormat);
   return result.forget();
 }
 
-TemporaryRef<BufferTextureClient>
-CompositableClient::CreateBufferTextureClient(gfx::SurfaceFormat aFormat)
-{
-  return CreateBufferTextureClient(aFormat, TEXTURE_FLAGS_DEFAULT);
-}
 
 void
 CompositableClient::AddTextureClient(TextureClient* aClient)
 {
   ++mNextTextureID;
   // 0 is always an invalid ID
   if (mNextTextureID == 0) {
     ++mNextTextureID;
--- a/gfx/layers/client/CompositableClient.h
+++ b/gfx/layers/client/CompositableClient.h
@@ -72,19 +72,16 @@ public:
   virtual TextureInfo GetTextureInfo() const = 0;
 
   LayersBackend GetCompositorBackendType() const;
 
   TemporaryRef<DeprecatedTextureClient>
   CreateDeprecatedTextureClient(DeprecatedTextureClientType aDeprecatedTextureClientType);
 
   TemporaryRef<BufferTextureClient>
-  CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags);
-
-  virtual TemporaryRef<BufferTextureClient>
   CreateBufferTextureClient(gfx::SurfaceFormat aFormat);
 
   virtual void SetDescriptorFromReply(TextureIdentifier aTextureId,
                                       const SurfaceDescriptor& aDescriptor)
   {
     MOZ_CRASH("If you want to call this, you should have implemented it");
   }
 
--- a/gfx/layers/client/ImageClient.cpp
+++ b/gfx/layers/client/ImageClient.cpp
@@ -141,28 +141,26 @@ ImageClientSingle::UpdateImage(ImageCont
       MOZ_ASSERT(false);
       return false;
     }
 
   } else {
     nsRefPtr<gfxASurface> surface = image->GetAsSurface();
     MOZ_ASSERT(surface);
 
-    gfx::IntSize size = gfx::IntSize(image->GetSize().width, image->GetSize().height);
-
-    if (mFrontBuffer &&
-        (mFrontBuffer->IsImmutable() || mFrontBuffer->GetSize() != size)) {
+    if (mFrontBuffer && mFrontBuffer->IsImmutable()) {
       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;
@@ -192,26 +190,20 @@ ImageClientBuffered::UpdateImage(ImageCo
   mFrontBuffer = mBackBuffer;
   mBackBuffer = temp;
   return ImageClientSingle::UpdateImage(aContainer, aContentFlags);
 }
 
 void
 ImageClientSingle::AddTextureClient(TextureClient* aTexture)
 {
-  MOZ_ASSERT((mTextureFlags & aTexture->GetFlags()) == mTextureFlags);
+  aTexture->AddFlags(mTextureFlags);
   CompositableClient::AddTextureClient(aTexture);
 }
 
-TemporaryRef<BufferTextureClient>
-ImageClientSingle::CreateBufferTextureClient(gfx::SurfaceFormat aFormat)
-{
-  return CompositableClient::CreateBufferTextureClient(aFormat, mTextureFlags);
-}
-
 void
 ImageClientSingle::Detach()
 {
   mFrontBuffer = nullptr;
 }
 
 void
 ImageClientBuffered::Detach()
--- a/gfx/layers/client/ImageClient.h
+++ b/gfx/layers/client/ImageClient.h
@@ -72,19 +72,16 @@ public:
                     CompositableType aType);
 
   virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags);
 
   virtual void Detach() MOZ_OVERRIDE;
 
   virtual void AddTextureClient(TextureClient* aTexture) MOZ_OVERRIDE;
 
-  virtual TemporaryRef<BufferTextureClient>
-  CreateBufferTextureClient(gfx::SurfaceFormat aFormat) MOZ_OVERRIDE;
-
   virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE;
 protected:
   RefPtr<TextureClient> mFrontBuffer;
   // Some layers may want to enforce some flags to all their textures
   // (like disallowing tiling)
   TextureFlags mTextureFlags;
 };
 
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -83,19 +83,18 @@ ShmemTextureClient::GetBuffer() const
 
 size_t
 ShmemTextureClient::GetBufferSize() const
 {
   return mShmem.Size<uint8_t>();
 }
 
 ShmemTextureClient::ShmemTextureClient(CompositableClient* aCompositable,
-                                       gfx::SurfaceFormat aFormat,
-                                       TextureFlags aFlags)
-  : BufferTextureClient(aCompositable, aFormat, aFlags)
+                                       gfx::SurfaceFormat aFormat)
+  : BufferTextureClient(aCompositable, aFormat)
   , mAllocated(false)
 {
   MOZ_COUNT_CTOR(ShmemTextureClient);
 }
 
 ShmemTextureClient::~ShmemTextureClient()
 {
   MOZ_COUNT_DTOR(ShmemTextureClient);
@@ -121,20 +120,18 @@ bool
 MemoryTextureClient::Allocate(uint32_t aSize)
 {
   MOZ_ASSERT(!mBuffer);
   mBuffer = new uint8_t[aSize];
   mBufSize = aSize;
   return true;
 }
 
-MemoryTextureClient::MemoryTextureClient(CompositableClient* aCompositable,
-                                         gfx::SurfaceFormat aFormat,
-                                         TextureFlags aFlags)
-  : BufferTextureClient(aCompositable, aFormat, aFlags)
+MemoryTextureClient::MemoryTextureClient(CompositableClient* aCompositable, gfx::SurfaceFormat aFormat)
+  : BufferTextureClient(aCompositable, aFormat)
   , mBuffer(nullptr)
   , mBufSize(0)
 {
   MOZ_COUNT_CTOR(MemoryTextureClient);
 }
 
 MemoryTextureClient::~MemoryTextureClient()
 {
@@ -142,19 +139,18 @@ MemoryTextureClient::~MemoryTextureClien
   if (ShouldDeallocateInDestructor()) {
     // if the buffer has never been shared we must deallocate it or ir would
     // leak.
     delete mBuffer;
   }
 }
 
 BufferTextureClient::BufferTextureClient(CompositableClient* aCompositable,
-                                         gfx::SurfaceFormat aFormat,
-                                         TextureFlags aFlags)
-  : TextureClient(aFlags)
+                                         gfx::SurfaceFormat aFormat)
+  : TextureClient()
   , mCompositable(aCompositable)
   , mFormat(aFormat)
 {}
 
 BufferTextureClient::~BufferTextureClient()
 {}
 
 bool
@@ -171,51 +167,31 @@ BufferTextureClient::UpdateSurface(gfxAS
   if (!surf) {
     return false;
   }
 
   nsRefPtr<gfxContext> tmpCtx = new gfxContext(surf.get());
   tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
   tmpCtx->DrawSurface(aSurface, gfxSize(serializer.GetSize().width,
                                         serializer.GetSize().height));
-
-  if (TextureRequiresLocking(aFlags)) {
-    // We don't have support for proper locking yet, so we'll
-    // have to be immutable instead.
-    MarkImmutable();
-  }
   return true;
 }
 
-already_AddRefed<gfxASurface>
-BufferTextureClient::GetAsSurface()
-{
-  ImageDataSerializer serializer(GetBuffer());
-  if (!serializer.IsValid()) {
-    return nullptr;
-  }
-
-  RefPtr<gfxImageSurface> surf = serializer.GetAsThebesSurface();
-  nsRefPtr<gfxASurface> result = surf.get();
-  return result.forget();
-}
-
 bool
 BufferTextureClient::AllocateForSurface(gfx::IntSize aSize)
 {
   MOZ_ASSERT(mFormat != gfx::FORMAT_YUV, "This textureClient cannot use YCbCr data");
 
   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());
@@ -225,37 +201,30 @@ BufferTextureClient::UpdateYCbCr(const P
   MOZ_ASSERT(serializer.IsValid());
   if (!serializer.CopyData(aData.mYChannel, aData.mCbChannel, aData.mCrChannel,
                            aData.mYSize, aData.mYStride,
                            aData.mCbCrSize, aData.mCbCrStride,
                            aData.mYSkip, aData.mCbSkip)) {
     NS_WARNING("Failed to copy image data!");
     return false;
   }
-
-  if (TextureRequiresLocking(aFlags)) {
-    // We don't have support for proper locking yet, so we'll
-    // have to be immutable instead.
-    MarkImmutable();
-  }
   return true;
 }
 
 bool
 BufferTextureClient::AllocateForYCbCr(gfx::IntSize aYSize, gfx::IntSize aCbCrSize)
 {
   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
@@ -39,17 +39,16 @@ class CompositableClient;
 
 /**
  * Interface for TextureClients that can be updated using a gfxASurface.
  */
 class TextureClientSurface
 {
 public:
   virtual bool UpdateSurface(gfxASurface* aSurface) = 0;
-  virtual already_AddRefed<gfxASurface> GetAsSurface() = 0;
   virtual bool AllocateForSurface(gfx::IntSize aSize) = 0;
 };
 
 /**
  * Interface for TextureClients that can be updated using YCbCr data.
  */
 class TextureClientYCbCr
 {
@@ -120,113 +119,116 @@ 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)
+  {
+    MOZ_ASSERT(!IsSharedWithCompositor());
+    // make sure we don't deallocate on both client and host;
+    MOZ_ASSERT(!(aFlags & TEXTURE_DEALLOCATE_CLIENT && aFlags & TEXTURE_DEALLOCATE_HOST));
+    if (aFlags & TEXTURE_DEALLOCATE_CLIENT) {
+      mFlags &= ~TEXTURE_DEALLOCATE_HOST;
+    } else if (aFlags & TEXTURE_DEALLOCATE_HOST) {
+      mFlags &= ~TEXTURE_DEALLOCATE_CLIENT;
+    }
+    mFlags |= aFlags;
+  }
+
+  void RemoveFlags(TextureFlags  aFlags)
+  {
+    MOZ_ASSERT(!IsSharedWithCompositor());
+    mFlags &= (~aFlags);
+  }
 
   TextureFlags GetFlags() const { return mFlags; }
 
   /**
    * After being shared ith the compositor side, an immutable texture is never
    * modified, it can only be read. It is safe to not Lock/Unlock immutable
    * textures.
    */
   bool IsImmutable() const { return mFlags & TEXTURE_IMMUTABLE; }
 
   void MarkImmutable() { AddFlags(TEXTURE_IMMUTABLE); }
 
   bool IsSharedWithCompositor() const { return GetID() != 0; }
 
   bool ShouldDeallocateInDestructor() const;
 protected:
-  void AddFlags(TextureFlags  aFlags)
-  {
-    MOZ_ASSERT(!IsSharedWithCompositor());
-    // make sure we don't deallocate on both client and host;
-    MOZ_ASSERT(!(aFlags & TEXTURE_DEALLOCATE_CLIENT && aFlags & TEXTURE_DEALLOCATE_HOST));
-    if (aFlags & TEXTURE_DEALLOCATE_CLIENT) {
-      mFlags &= ~TEXTURE_DEALLOCATE_HOST;
-    } else if (aFlags & TEXTURE_DEALLOCATE_HOST) {
-      mFlags &= ~TEXTURE_DEALLOCATE_CLIENT;
-    }
-    mFlags |= aFlags;
-  }
-
   uint64_t mID;
   RefPtr<TextureClient> mNextSibling;
   TextureFlags mFlags;
 };
 
 /**
  * TextureClient that wraps a random access buffer such as a Shmem or raw memory.
  * This class must be inherited to implement the memory allocation and access bits.
  * (see ShmemTextureClient and MemoryTextureClient)
  */
 class BufferTextureClient : public TextureClient
                           , public TextureClientSurface
                           , TextureClientYCbCr
 {
 public:
-  BufferTextureClient(CompositableClient* aCompositable, gfx::SurfaceFormat aFormat,
-                      TextureFlags aFlags);
+  BufferTextureClient(CompositableClient* aCompositable, gfx::SurfaceFormat aFormat);
 
   virtual ~BufferTextureClient();
 
   virtual bool IsAllocated() const = 0;
 
   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 already_AddRefed<gfxASurface> GetAsSurface() MOZ_OVERRIDE;
-
   virtual bool AllocateForSurface(gfx::IntSize aSize) MOZ_OVERRIDE;
 
   // TextureClientYCbCr
 
   virtual TextureClientYCbCr* AsTextureClientYCbCr() MOZ_OVERRIDE { return this; }
 
   virtual bool UpdateYCbCr(const PlanarYCbCrImage::Data& aData) MOZ_OVERRIDE;
 
   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
 {
 public:
-  ShmemTextureClient(CompositableClient* aCompositable, gfx::SurfaceFormat aFormat,
-                     TextureFlags aFlags);
+  ShmemTextureClient(CompositableClient* aCompositable, gfx::SurfaceFormat aFormat);
 
   ~ShmemTextureClient();
 
   virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE;
 
   virtual bool Allocate(uint32_t aSize) MOZ_OVERRIDE;
 
   virtual uint8_t* GetBuffer() const MOZ_OVERRIDE;
@@ -248,18 +250,17 @@ protected:
 /**
  * TextureClient that wraps raw memory.
  * The corresponding texture on the host side is MemoryTextureHost.
  * Can obviously not be used in a cross process setup.
  */
 class MemoryTextureClient : public BufferTextureClient
 {
 public:
-  MemoryTextureClient(CompositableClient* aCompositable, gfx::SurfaceFormat aFormat,
-                      TextureFlags aFlags);
+  MemoryTextureClient(CompositableClient* aCompositable, gfx::SurfaceFormat aFormat);
 
   ~MemoryTextureClient();
 
   virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE;
 
   virtual bool Allocate(uint32_t aSize) MOZ_OVERRIDE;
 
   virtual uint8_t* GetBuffer() const MOZ_OVERRIDE { return mBuffer; }
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -224,19 +224,16 @@ BufferTextureHost::Updated(const nsIntRe
 {
   ++mUpdateSerial;
   if (aRegion) {
     mPartialUpdate = true;
     mMaybeUpdatedRegion = *aRegion;
   } else {
     mPartialUpdate = false;
   }
-  if (GetFlags() & TEXTURE_IMMEDIATE_UPLOAD) {
-    MaybeUpload(mPartialUpdate ? &mMaybeUpdatedRegion : nullptr);
-  }
 }
 
 void
 BufferTextureHost::SetCompositor(Compositor* aCompositor)
 {
   if (mCompositor == aCompositor) {
     return;
   }
@@ -266,18 +263,21 @@ BufferTextureHost::Unlock()
 {
   mLocked = false;
 }
 
 NewTextureSource*
 BufferTextureHost::GetTextureSources()
 {
   MOZ_ASSERT(mLocked, "should never be called while not locked");
-  if (!MaybeUpload(mPartialUpdate ? &mMaybeUpdatedRegion : nullptr)) {
+  if (!mFirstSource || mUpdateSerial != mFirstSource->GetUpdateSerial()) {
+    if (!Upload(mPartialUpdate ? &mMaybeUpdatedRegion : nullptr)) {
       return nullptr;
+    }
+    mFirstSource->SetUpdateSerial(mUpdateSerial);
   }
   return mFirstSource;
 }
 
 gfx::SurfaceFormat
 BufferTextureHost::GetFormat() const
 {
   // mFormat is the format of the data that we share with the content process.
@@ -289,29 +289,16 @@ BufferTextureHost::GetFormat() const
     mCompositor &&
     !mCompositor->SupportsEffect(EFFECT_YCBCR)) {
     return gfx::FORMAT_R8G8B8X8;
   }
   return mFormat;
 }
 
 bool
-BufferTextureHost::MaybeUpload(nsIntRegion *aRegion)
-{
-  if (mFirstSource && mFirstSource->GetUpdateSerial() == mUpdateSerial) {
-    return true;
-  }
-  if (!Upload(aRegion)) {
-    return false;
-  }
-  mFirstSource->SetUpdateSerial(mUpdateSerial);
-  return true;
-}
-
-bool
 BufferTextureHost::Upload(nsIntRegion *aRegion)
 {
   if (mFormat == gfx::FORMAT_UNKNOWN) {
     NS_WARNING("BufferTextureHost: unsupported format!");
     return false;
   } else if (mFormat == gfx::FORMAT_YUV) {
     YCbCrImageDataDeserializer yuvDeserializer(GetBuffer());
     MOZ_ASSERT(yuvDeserializer.IsValid());
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -444,17 +444,16 @@ public:
   virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
 
   virtual already_AddRefed<gfxImageSurface> GetAsSurface() MOZ_OVERRIDE;
 
   virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; }
 
 protected:
   bool Upload(nsIntRegion *aRegion = nullptr);
-  bool MaybeUpload(nsIntRegion *aRegion = nullptr);
 
   Compositor* mCompositor;
   RefPtr<DataTextureSource> mFirstSource;
   nsIntRegion mMaybeUpdatedRegion;
   gfx::IntSize mSize;
   // format of the data that is shared with the content process.
   gfx::SurfaceFormat mFormat;
   uint32_t mUpdateSerial;
--- a/gfx/layers/ipc/ShadowLayers.cpp
+++ b/gfx/layers/ipc/ShadowLayers.cpp
@@ -402,26 +402,19 @@ ShadowLayerForwarder::RemoveTexture(Comp
 
 void
 ShadowLayerForwarder::UpdatedTexture(CompositableClient* aCompositable,
                                      TextureClient* aTexture,
                                      nsIntRegion* aRegion)
 {
   MaybeRegion region = aRegion ? MaybeRegion(*aRegion)
                                : MaybeRegion(null_t());
-  if (aTexture->GetFlags() & TEXTURE_IMMEDIATE_UPLOAD) {
-    mTxn->AddPaint(OpUpdateTexture(nullptr, aCompositable->GetIPDLActor(),
-                                   aTexture->GetID(),
-                                   region));
-  } else {
-    mTxn->AddNoSwapPaint(OpUpdateTexture(nullptr, aCompositable->GetIPDLActor(),
-                                         aTexture->GetID(),
-                                         region));
-
-  }
+  mTxn->AddEdit(OpUpdateTexture(nullptr, aCompositable->GetIPDLActor(),
+                                aTexture->GetID(),
+                                region));
 }
 
 void
 ShadowLayerForwarder::UseTexture(CompositableClient* aCompositable,
                                  TextureClient* aTexture)
 {
   mTxn->AddEdit(OpUseTexture(nullptr, aCompositable->GetIPDLActor(),
                              aTexture->GetID()));
--- 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);
 
-  virtual gfx::IntSize GetSize() const { return mSize; }
+  gfx::IntSize GetSize() const { return mSize; }
 
 protected:
   gfx::IntSize mSize;
   gl::SharedTextureHandle mHandle;
   bool mIsCrossProcess;
   bool mInverted;
 };