Commit f218841e authored by wangxianzhu's avatar wangxianzhu Committed by Commit bot

Let only the root layer paint root background

When the viewport has fixed background, we may create a dedicated
GraphicsLayer (CompositedLayerMapping::m_backgroundLayer) for the
root background. Previously we used PaintLayerPaintingRootBackgroundOnly
and PaintLayerPaintingCompositingForegroundPhase flags when painting
the layer. The second flag was necessary before we refactored viewport
background painting into ViewPainter, because we needed the layout
objects of the document element or the body element to paint the
viewport background.

Now we need only the root layer to paint root background.

BUG=595839
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2294313002
Cr-Commit-Position: refs/heads/master@{#415694}
parent 4012b3ba
...@@ -2464,7 +2464,7 @@ void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G ...@@ -2464,7 +2464,7 @@ void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G
paintLayerFlags |= PaintLayerPaintingCompositingScrollingPhase; paintLayerFlags |= PaintLayerPaintingCompositingScrollingPhase;
if (graphicsLayer == m_backgroundLayer.get()) if (graphicsLayer == m_backgroundLayer.get())
paintLayerFlags |= (PaintLayerPaintingRootBackgroundOnly | PaintLayerPaintingCompositingForegroundPhase); // Need PaintLayerPaintingCompositingForegroundPhase to walk child layers. paintLayerFlags |= PaintLayerPaintingRootBackgroundOnly;
else if (compositor()->fixedRootBackgroundLayer() && m_owningLayer.isRootLayer()) else if (compositor()->fixedRootBackgroundLayer() && m_owningLayer.isRootLayer())
paintLayerFlags |= PaintLayerPaintingSkipRootBackground; paintLayerFlags |= PaintLayerPaintingSkipRootBackground;
......
...@@ -203,7 +203,7 @@ PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContents(GraphicsCon ...@@ -203,7 +203,7 @@ PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContents(GraphicsCon
PaintResult result = FullyPainted; PaintResult result = FullyPainted;
if (paintFlags & PaintLayerPaintingRootBackgroundOnly && !m_paintLayer.layoutObject()->isLayoutView() && !m_paintLayer.layoutObject()->isDocumentElement()) if (paintFlags & PaintLayerPaintingRootBackgroundOnly && !m_paintLayer.layoutObject()->isLayoutView())
return result; return result;
if (m_paintLayer.layoutObject()->view()->frame() && m_paintLayer.layoutObject()->view()->frame()->shouldThrottleRendering()) if (m_paintLayer.layoutObject()->view()->frame() && m_paintLayer.layoutObject()->view()->frame()->shouldThrottleRendering())
...@@ -564,20 +564,13 @@ PaintLayerPainter::PaintResult PaintLayerPainter::paintChildren(unsigned childre ...@@ -564,20 +564,13 @@ PaintLayerPainter::PaintResult PaintLayerPainter::paintChildren(unsigned childre
return result; return result;
} }
// FIXME: inline this.
static bool paintForFixedRootBackground(const PaintLayer* layer, PaintLayerFlags paintFlags)
{
return layer->layoutObject()->isDocumentElement() && (paintFlags & PaintLayerPaintingRootBackgroundOnly);
}
bool PaintLayerPainter::shouldPaintLayerInSoftwareMode(const GlobalPaintFlags globalPaintFlags, PaintLayerFlags paintFlags) bool PaintLayerPainter::shouldPaintLayerInSoftwareMode(const GlobalPaintFlags globalPaintFlags, PaintLayerFlags paintFlags)
{ {
DisableCompositingQueryAsserts disabler; DisableCompositingQueryAsserts disabler;
return m_paintLayer.compositingState() == NotComposited return m_paintLayer.compositingState() == NotComposited
|| (globalPaintFlags & GlobalPaintFlattenCompositingLayers) || (globalPaintFlags & GlobalPaintFlattenCompositingLayers)
|| ((paintFlags & PaintLayerPaintingReflection) && !m_paintLayer.has3DTransform()) || ((paintFlags & PaintLayerPaintingReflection) && !m_paintLayer.has3DTransform());
|| paintForFixedRootBackground(&m_paintLayer, paintFlags);
} }
void PaintLayerPainter::paintOverflowControlsForFragments(const PaintLayerFragments& layerFragments, GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags) void PaintLayerPainter::paintOverflowControlsForFragments(const PaintLayerFragments& layerFragments, GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags)
...@@ -677,6 +670,8 @@ void PaintLayerPainter::paintForegroundForFragments(const PaintLayerFragments& l ...@@ -677,6 +670,8 @@ void PaintLayerPainter::paintForegroundForFragments(const PaintLayerFragments& l
GraphicsContext& context, const LayoutRect& transparencyPaintDirtyRect, GraphicsContext& context, const LayoutRect& transparencyPaintDirtyRect,
const PaintLayerPaintingInfo& localPaintingInfo, bool selectionOnly, PaintLayerFlags paintFlags) const PaintLayerPaintingInfo& localPaintingInfo, bool selectionOnly, PaintLayerFlags paintFlags)
{ {
DCHECK(!(paintFlags & PaintLayerPaintingRootBackgroundOnly));
// Optimize clipping for the single fragment case. // Optimize clipping for the single fragment case.
bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty(); bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty();
ClipState clipState = HasNotClipped; ClipState clipState = HasNotClipped;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment