Respect SYNC_DECODE when deciding to use Webrender for nsDisplayBackgroundImage. (bug 1439960, r=mstange)
authorRyan Hunt <rhunt@eqrion.net>
Tue, 20 Mar 2018 13:42:05 -0500
changeset 462863 19ad67bba5910fa7265dce46031768586315c74f
parent 462862 62432cc896eefa5fda52fdf00b7390cf1f2318cd
child 462864 16af2a73adc79c11bc55c9283ba063461147c027
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1439960
milestone61.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
Respect SYNC_DECODE when deciding to use Webrender for nsDisplayBackgroundImage. (bug 1439960, r=mstange) Previously CreateWebrenderCommands would use GetLayerState to determine whether to use Webrender or take the fallback path. GetLayerState would then under some cases call CanOptimizeToImageLayer() which would get the image container using the appropriate flags for sync decoding. Now nsDisplayBackgroundImage only uses CanCreateWebrenderCommands, which doesn't pass the correct flags to image container, leading to reftest failures in some cases. This commit fixes that. MozReview-Commit-ID: KlslXVHlRi5
gfx/layers/ipc/APZInputBridgeChild.cpp
gfx/layers/mlgpu/FrameBuilder.cpp
layout/painting/nsCSSRendering.cpp
layout/painting/nsCSSRendering.h
layout/painting/nsDisplayList.cpp
layout/painting/nsDisplayList.h
--- a/gfx/layers/ipc/APZInputBridgeChild.cpp
+++ b/gfx/layers/ipc/APZInputBridgeChild.cpp
@@ -1,16 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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 "mozilla/layers/APZInputBridgeChild.h"
 
+#include "InputData.h" // for InputData, etc
+
 namespace mozilla {
 namespace layers {
 
 APZInputBridgeChild::APZInputBridgeChild()
   : mDestroyed(false)
 {
   MOZ_ASSERT(XRE_IsParentProcess());
   MOZ_ASSERT(NS_IsMainThread());
--- a/gfx/layers/mlgpu/FrameBuilder.cpp
+++ b/gfx/layers/mlgpu/FrameBuilder.cpp
@@ -8,16 +8,17 @@
 #include "ContainerLayerMLGPU.h"
 #include "GeckoProfiler.h"              // for profiler_*
 #include "LayerMLGPU.h"
 #include "LayerManagerMLGPU.h"
 #include "MaskOperation.h"
 #include "MLGDevice.h"                  // for MLGSwapChain
 #include "RenderPassMLGPU.h"
 #include "RenderViewMLGPU.h"
+#include "mozilla/gfx/Logging.h"
 #include "mozilla/gfx/Polygon.h"
 #include "mozilla/layers/BSPTree.h"
 #include "mozilla/layers/LayersHelpers.h"
 
 namespace mozilla {
 namespace layers {
 
 using namespace mlg;
@@ -146,17 +147,17 @@ FrameBuilder::ProcessContainerLayer(Cont
                                     RenderViewMLGPU* aView,
                                     const RenderTargetIntRect& aClipRect,
                                     Maybe<gfx::Polygon>& aGeometry)
 {
   LayerMLGPU* layer = aContainer->AsHostLayer()->AsLayerMLGPU();
 
   // Diagnostic information for bug 1387467.
   if (!layer) {
-    gfxDevCrash(LogReason::InvalidLayerType) <<
+    gfxDevCrash(gfx::LogReason::InvalidLayerType) <<
       "Layer type is invalid: " << aContainer->Name();
     return false;
   }
 
   // We don't want to traverse containers twice, so we only traverse them if
   // they haven't been prepared yet.
   bool isFirstVisit = !layer->IsPrepared();
   if (isFirstVisit && !layer->PrepareToRender(this, aClipRect)) {
@@ -175,17 +176,17 @@ FrameBuilder::ProcessContainerLayer(Cont
   }
 
   // If this is the first visit of the container this frame, and the
   // container has an unpainted area, we traverse the container. Note that
   // RefLayers do not have intermediate surfaces so this is guaranteed
   // to be a full-fledged ContainerLayerMLGPU.
   ContainerLayerMLGPU* viewContainer = layer->AsContainerLayerMLGPU();
   if (!viewContainer) {
-    gfxDevCrash(LogReason::InvalidLayerType) <<
+    gfxDevCrash(gfx::LogReason::InvalidLayerType) <<
       "Container layer type is invalid: " << aContainer->Name();
     return false;
   }
 
   if (isFirstVisit && !viewContainer->GetInvalidRect().IsEmpty()) {
     // The RenderView constructor automatically attaches itself to the parent.
     RefPtr<RenderViewMLGPU> view = new RenderViewMLGPU(this, viewContainer, aView);
     ProcessChildList(aContainer, view, aClipRect, Nothing());
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -2048,17 +2048,18 @@ nsCSSRendering::PaintStyleImageLayer(con
   return PaintStyleImageLayerWithSC(aParams, aRenderingCtx, sc, *aParams.frame->StyleBorder());
 }
 
 bool
 nsCSSRendering::CanBuildWebRenderDisplayItemsForStyleImageLayer(LayerManager* aManager,
                                                                 nsPresContext& aPresCtx,
                                                                 nsIFrame *aFrame,
                                                                 const nsStyleBackground* aBackgroundStyle,
-                                                                int32_t aLayer)
+                                                                int32_t aLayer,
+                                                                uint32_t aPaintFlags)
 {
   if (!aBackgroundStyle) {
     return false;
   }
 
   MOZ_ASSERT(aFrame &&
              aLayer >= 0 &&
              (uint32_t)aLayer < aBackgroundStyle->mImage.mLayers.Length());
@@ -2081,19 +2082,24 @@ nsCSSRendering::CanBuildWebRenderDisplay
       return false;
     }
 
     imgRequestProxy* requestProxy = styleImage->GetImageData();
     if (!requestProxy) {
       return false;
     }
 
+    uint32_t imageFlags = imgIContainer::FLAG_NONE;
+    if (aPaintFlags & nsCSSRendering::PAINTBG_SYNC_DECODE_IMAGES) {
+      imageFlags |= imgIContainer::FLAG_SYNC_DECODE;
+    }
+
     nsCOMPtr<imgIContainer> srcImage;
     requestProxy->GetImage(getter_AddRefs(srcImage));
-    if (!srcImage || !srcImage->IsImageContainerAvailable(aManager, imgIContainer::FLAG_NONE)) {
+    if (!srcImage || !srcImage->IsImageContainerAvailable(aManager, imageFlags)) {
       return false;
     }
 
     return true;
   }
 
   if (styleImage->GetType() == eStyleImageType_Gradient) {
     return true;
--- a/layout/painting/nsCSSRendering.h
+++ b/layout/painting/nsCSSRendering.h
@@ -526,17 +526,18 @@ struct nsCSSRendering {
                                                gfxContext& aRenderingCtx,
                                                nsStyleContext *mBackgroundSC,
                                                const nsStyleBorder& aBorder);
 
   static bool CanBuildWebRenderDisplayItemsForStyleImageLayer(LayerManager* aManager,
                                                               nsPresContext& aPresCtx,
                                                               nsIFrame *aFrame,
                                                               const nsStyleBackground* aBackgroundStyle,
-                                                              int32_t aLayer);
+                                                              int32_t aLayer,
+                                                              uint32_t aPaintFlags);
   static ImgDrawResult BuildWebRenderDisplayItemsForStyleImageLayer(const PaintBGParams& aParams,
                                                                  mozilla::wr::DisplayListBuilder& aBuilder,
                                                                  mozilla::wr::IpcResourceUpdateQueue& aResources,
                                                                  const mozilla::layers::StackingContextHelper& aSc,
                                                                  mozilla::layers::WebRenderLayerManager* aManager,
                                                                  nsDisplayItem* aItem);
 
   static ImgDrawResult BuildWebRenderDisplayItemsForStyleImageLayerWithSC(const PaintBGParams& aParams,
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -4081,41 +4081,43 @@ nsDisplayBackgroundImage::BuildLayer(nsD
   }
   RefPtr<ImageContainer> imageContainer = GetContainer(aManager, aBuilder);
   layer->SetContainer(imageContainer);
   ConfigureLayer(layer, aParameters);
   return layer.forget();
 }
 
 bool
-nsDisplayBackgroundImage::CanBuildWebRenderDisplayItems(LayerManager* aManager)
-{
+nsDisplayBackgroundImage::CanBuildWebRenderDisplayItems(LayerManager* aManager, nsDisplayListBuilder* aDisplayListBuilder)
+{
+  if (aDisplayListBuilder) {
+    mImageFlags = aDisplayListBuilder->GetBackgroundPaintFlags();
+  }
+
   return mBackgroundStyle->mImage.mLayers[mLayer].mClip != StyleGeometryBox::Text &&
          nsCSSRendering::CanBuildWebRenderDisplayItemsForStyleImageLayer(aManager,
                                                                          *StyleFrame()->PresContext(),
                                                                          StyleFrame(),
                                                                          mBackgroundStyle,
-                                                                         mLayer);
+                                                                         mLayer,
+                                                                         mImageFlags);
 }
 
 bool
 nsDisplayBackgroundImage::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
                                                   mozilla::wr::IpcResourceUpdateQueue& aResources,
                                                   const StackingContextHelper& aSc,
                                                   WebRenderLayerManager* aManager,
                                                   nsDisplayListBuilder* aDisplayListBuilder)
 {
   ContainerLayerParameters parameter;
-  if (!CanBuildWebRenderDisplayItems(aManager)) {
+  if (!CanBuildWebRenderDisplayItems(aManager, aDisplayListBuilder)) {
     return false;
   }
 
-  if (aDisplayListBuilder) {
-    mImageFlags = aDisplayListBuilder->GetBackgroundPaintFlags();
-  }
   CheckForBorderItem(this, mImageFlags);
   nsCSSRendering::PaintBGParams params =
     nsCSSRendering::PaintBGParams::ForSingleLayer(*StyleFrame()->PresContext(),
                                                   mVisibleRect, mBackgroundRect,
                                                   StyleFrame(), mImageFlags, mLayer,
                                                   CompositionOp::OP_OVER);
   params.bgClipRect = &mBounds;
   ImgDrawResult result =
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -3979,17 +3979,17 @@ public:
     }
     nsDisplayItem::RemoveFrame(aFrame);
   }
 
 protected:
   typedef class mozilla::layers::ImageContainer ImageContainer;
   typedef class mozilla::layers::ImageLayer ImageLayer;
 
-  bool CanBuildWebRenderDisplayItems(LayerManager* aManager);
+  bool CanBuildWebRenderDisplayItems(LayerManager* aManager, nsDisplayListBuilder* aBuilder);
   nsRect GetBoundsInternal(nsDisplayListBuilder* aBuilder,
                            nsIFrame* aFrameForBounds = nullptr);
 
   void PaintInternal(nsDisplayListBuilder* aBuilder, gfxContext* aCtx,
                      const nsRect& aBounds, nsRect* aClipRect);
 
   // Determine whether we want to be separated into our own layer, independent
   // of whether this item can actually be layerized.