Bug 1339625 - Force clear Texture r=kats
authorsotaro <sotaro.ikeda.g@gmail.com>
Fri, 17 Feb 2017 21:00:16 +0900
changeset 372605 264c1c5ac2c57e8988f67a31eaec4c222738eae8
parent 372604 c5761d8f5d23b6997201ca844f0eac1aed6585f0
child 372606 da0b368c3bd7872d0f60b967c02a42e769ac6e5f
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1339625
milestone54.0a1
Bug 1339625 - Force clear Texture r=kats
gfx/layers/composite/CompositableHost.cpp
gfx/layers/wr/WebRenderBridgeParent.cpp
gfx/layers/wr/WebRenderImageHost.cpp
gfx/layers/wr/WebRenderImageHost.h
--- a/gfx/layers/composite/CompositableHost.cpp
+++ b/gfx/layers/composite/CompositableHost.cpp
@@ -132,19 +132,24 @@ CompositableHost::Create(const TextureIn
   case CompositableType::IMAGE:
     if (gfxVars::UseWebRender()) {
       result = new WebRenderImageHost(aTextureInfo);
     } else {
       result = new ImageHost(aTextureInfo);
     }
     break;
   case CompositableType::CONTENT_SINGLE:
-    result = new ContentHostSingleBuffered(aTextureInfo);
+    if (gfxVars::UseWebRender()) {
+      result = new WebRenderImageHost(aTextureInfo);
+    } else {
+      result = new ContentHostSingleBuffered(aTextureInfo);
+    }
     break;
   case CompositableType::CONTENT_DOUBLE:
+    MOZ_ASSERT(!gfxVars::UseWebRender());
     result = new ContentHostDoubleBuffered(aTextureInfo);
     break;
   default:
     NS_ERROR("Unknown CompositableType");
   }
   return result.forget();
 }
 
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -323,16 +323,20 @@ WebRenderBridgeParent::ProcessWebrenderC
 
         wr::ImageKey key;
         auto slice = Range<uint8_t>(map.mData, validRect.height * map.mStride);
         key = mApi->AddImageBuffer(validRect.Size(), map.mStride, SurfaceFormat::B8G8R8A8, slice);
 
         builder.PushImage(op.bounds(), op.clip(), op.mask().ptrOr(nullptr), op.filter(), key);
         keysToDelete.push_back(key);
         dSurf->Unmap();
+        // XXX workaround for releasing Readlock. See Bug 1339625
+        if(host->GetType() == CompositableType::CONTENT_SINGLE) {
+          host->CleanupResources();
+        }
         break;
       }
       case WebRenderCommand::TOpDPPushIframe: {
         const OpDPPushIframe& op = cmd.get_OpDPPushIframe();
         builder.PushIFrame(op.bounds(), op.clip(), op.pipelineId());
         break;
       }
       case WebRenderCommand::TCompositableOperation: {
--- a/gfx/layers/wr/WebRenderImageHost.cpp
+++ b/gfx/layers/wr/WebRenderImageHost.cpp
@@ -61,18 +61,28 @@ WebRenderImageHost::UseTextureHost(const
     img.mTextureHost->Updated();
   }
 
   mImages.SwapElements(newImages);
   newImages.Clear();
 }
 
 void
+WebRenderImageHost::UseComponentAlphaTextures(TextureHost* aTextureOnBlack,
+                                              TextureHost* aTextureOnWhite)
+{
+  MOZ_ASSERT_UNREACHABLE("unexpected to be called");
+}
+
+void
 WebRenderImageHost::CleanupResources()
 {
+  nsTArray<TimedImage> newImages;
+  mImages.SwapElements(newImages);
+  newImages.Clear();
 }
 
 void
 WebRenderImageHost::RemoveTextureHost(TextureHost* aTexture)
 {
   CompositableHost::RemoveTextureHost(aTexture);
 
   for (int32_t i = mImages.Length() - 1; i >= 0; --i) {
--- a/gfx/layers/wr/WebRenderImageHost.h
+++ b/gfx/layers/wr/WebRenderImageHost.h
@@ -29,17 +29,18 @@ public:
                          float aOpacity,
                          const gfx::Matrix4x4& aTransform,
                          const gfx::SamplingFilter aSamplingFilter,
                          const gfx::IntRect& aClipRect,
                          const nsIntRegion* aVisibleRegion = nullptr,
                          const Maybe<gfx::Polygon>& aGeometry = Nothing()) override;
 
   virtual void UseTextureHost(const nsTArray<TimedTexture>& aTextures) override;
-
+  virtual void UseComponentAlphaTextures(TextureHost* aTextureOnBlack,
+                                         TextureHost* aTextureOnWhite) override;
   virtual void RemoveTextureHost(TextureHost* aTexture) override;
 
   virtual TextureHost* GetAsTextureHost(gfx::IntRect* aPictureRect = nullptr) override;
 
   virtual void Attach(Layer* aLayer,
                       Compositor* aCompositor,
                       AttachFlags aFlags = NO_FLAGS) override;