Bug 1204895 - Add fence handling to AutoRemoveTexture on gonk r=nical
authorSotaro Ikeda <sikeda@mozilla.com>
Thu, 17 Sep 2015 07:22:41 -0700
changeset 263060 94a7ca13ffa023d7fa5ef4728e6ef0d92ee2ad2e
parent 263059 310477a8720f081626b19e895ad01c2239bdb336
child 263061 f436921d97f7a8986b2455ba9cdf2d0e4001f15b
push id65193
push usersikeda@mozilla.com
push dateThu, 17 Sep 2015 14:22:48 +0000
treeherdermozilla-inbound@94a7ca13ffa0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1204895
milestone43.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 1204895 - Add fence handling to AutoRemoveTexture on gonk r=nical
gfx/layers/client/CompositableClient.cpp
gfx/layers/client/CompositableClient.h
gfx/layers/client/ImageClient.cpp
--- a/gfx/layers/client/CompositableClient.cpp
+++ b/gfx/layers/client/CompositableClient.cpp
@@ -265,10 +265,31 @@ CompositableClient::DumpTextureClient(st
   }
   RefPtr<gfx::DataSourceSurface> dSurf = aTexture->GetAsSurface();
   if (!dSurf) {
     return;
   }
   aStream << gfxUtils::GetAsLZ4Base64Str(dSurf).get();
 }
 
+AutoRemoveTexture::~AutoRemoveTexture()
+{
+#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
+  if (mCompositable && mTexture && mCompositable->GetForwarder()) {
+    // remove old buffer from CompositableHost
+    RefPtr<AsyncTransactionWaiter> waiter = new AsyncTransactionWaiter();
+    RefPtr<AsyncTransactionTracker> tracker =
+        new RemoveTextureFromCompositableTracker(waiter);
+    // Hold TextureClient until transaction complete.
+    tracker->SetTextureClient(mTexture);
+    mTexture->SetRemoveFromCompositableWaiter(waiter);
+    // RemoveTextureFromCompositableAsync() expects CompositorChild's presence.
+    mCompositable->GetForwarder()->RemoveTextureFromCompositableAsync(tracker, mCompositable, mTexture);
+  }
+#else
+  if (mCompositable && mTexture) {
+    mCompositable->RemoveTexture(mTexture);
+  }
+#endif
+}
+
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/client/CompositableClient.h
+++ b/gfx/layers/client/CompositableClient.h
@@ -243,22 +243,17 @@ protected:
 struct AutoRemoveTexture
 {
   explicit AutoRemoveTexture(CompositableClient* aCompositable,
                              TextureClient* aTexture = nullptr)
     : mTexture(aTexture)
     , mCompositable(aCompositable)
   {}
 
-  ~AutoRemoveTexture()
-  {
-    if (mCompositable && mTexture) {
-      mCompositable->RemoveTexture(mTexture);
-    }
-  }
+  ~AutoRemoveTexture();
 
   RefPtr<TextureClient> mTexture;
 private:
   CompositableClient* mCompositable;
 };
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/client/ImageClient.cpp
+++ b/gfx/layers/client/ImageClient.cpp
@@ -355,17 +355,16 @@ ImageClientOverlay::UpdateImage(ImageCon
     return false;
   }
 
   if (mLastUpdateGenerationCounter == (uint32_t)image->GetSerial()) {
     return true;
   }
   mLastUpdateGenerationCounter = (uint32_t)image->GetSerial();
 
-  AutoRemoveTexture autoRemoveTexture(this);
   if (image->GetFormat() == ImageFormat::OVERLAY_IMAGE) {
     OverlayImage* overlayImage = static_cast<OverlayImage*>(image);
     uint32_t overlayId = overlayImage->GetOverlayId();
     gfx::IntSize size = overlayImage->GetSize();
 
     OverlaySource source;
     source.handle() = OverlayHandle(overlayId);
     source.size() = size;