Bug 1388235 - Support fallback path for nsDisplayFilter. draft
authorMorris Tseng <mtseng@mozilla.com>
Wed, 16 Aug 2017 03:51:20 +0000
changeset 648789 a3ac332a883bb67feb86ab542313efe1f0970ec1
parent 648788 136161d1bf224f0b7c235b9cf19148b7bb68b380
child 648790 81c4908b63cd815946744298c37813bf4acb2f0c
push id74883
push userbmo:ethlin@mozilla.com
push dateFri, 18 Aug 2017 09:52:39 +0000
bugs1388235
milestone57.0a1
Bug 1388235 - Support fallback path for nsDisplayFilter.
gfx/layers/wr/WebRenderLayerManager.cpp
--- a/gfx/layers/wr/WebRenderLayerManager.cpp
+++ b/gfx/layers/wr/WebRenderLayerManager.cpp
@@ -1,24 +1,26 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WebRenderLayerManager.h"
 
+#include "BasicLayers.h"
 #include "gfxPrefs.h"
 #include "GeckoProfiler.h"
 #include "LayersLogging.h"
 #include "mozilla/gfx/DrawEventRecorder.h"
 #include "mozilla/layers/CompositorBridgeChild.h"
 #include "mozilla/layers/StackingContextHelper.h"
 #include "mozilla/layers/TextureClient.h"
 #include "mozilla/layers/WebRenderBridgeChild.h"
 #include "mozilla/layers/UpdateImageHelper.h"
+#include "nsDisplayList.h"
 #include "WebRenderCanvasLayer.h"
 #include "WebRenderCanvasRenderer.h"
 #include "WebRenderColorLayer.h"
 #include "WebRenderContainerLayer.h"
 #include "WebRenderImageLayer.h"
 #include "WebRenderPaintedLayer.h"
 #include "WebRenderPaintedLayerBlob.h"
 #include "WebRenderTextLayer.h"
@@ -387,21 +389,43 @@ PaintItemByDrawTarget(nsDisplayItem* aIt
                       nsDisplayListBuilder* aDisplayListBuilder)
 {
   MOZ_ASSERT(aDT);
 
   aDT->ClearRect(aImageRect.ToUnknownRect());
   RefPtr<gfxContext> context = gfxContext::CreateOrNull(aDT, aOffset.ToUnknownPoint());
   MOZ_ASSERT(context);
 
-  if (aItem->GetType() == DisplayItemType::TYPE_MASK) {
+  switch (aItem->GetType()) {
+  case DisplayItemType::TYPE_MASK:
     context->SetMatrix(gfxMatrix::Translation(-aOffset.x, -aOffset.y));
     static_cast<nsDisplayMask*>(aItem)->PaintMask(aDisplayListBuilder, context);
-  } else {
+    break;
+  case DisplayItemType::TYPE_FILTER:
+    {
+      RefPtr<BasicLayerManager> tempManager = new BasicLayerManager(BasicLayerManager::BLM_INACTIVE);
+      FrameLayerBuilder* layerBuilder = new FrameLayerBuilder();
+      layerBuilder->Init(aDisplayListBuilder, tempManager);
+
+      tempManager->BeginTransactionWithTarget(context);
+      ContainerLayerParameters param;
+      RefPtr<Layer> layer = aItem->BuildLayer(aDisplayListBuilder, tempManager, param);
+      if (layer) {
+        tempManager->SetRoot(layer);
+        static_cast<nsDisplayFilter*>(aItem)->PaintAsLayer(aDisplayListBuilder, context, tempManager);
+      }
+
+      if (tempManager->InTransaction()) {
+        tempManager->AbortTransaction();
+      }
+      break;
+    }
+  default:
     aItem->Paint(aDisplayListBuilder, context);
+    break;
   }
 
   if (gfxPrefs::WebRenderHighlightPaintedLayers()) {
     aDT->SetTransform(Matrix());
     aDT->FillRect(Rect(0, 0, aImageRect.Width(), aImageRect.Height()), ColorPattern(Color(1.0, 0.0, 0.0, 0.5)));
   }
   if (aItem->Frame()->PresContext()->GetPaintFlashing()) {
     aDT->SetTransform(Matrix());