Remove all but one of the PaintLayerFlags.

Only PaintLayerPaintingOverlayScrollbars is actually ever set
to a different value in different codepaths.

-PaintLayerHaveTransparency can just be replaced with
isTransparent() calls.
-PaintLayerPaintingCompositingScrollingPhase is unused.
-PaintLayerPaintingCompositingAllPhases is always set,
which means that the other three compositing ones are
also always set.

The third bullet more clearly falls out when you see that
the only caller of paintLayerContents is
paintLayerContentsAndReflection, which sets
PaintLayerPaintingCompositingAllPhases on the paint flags.
Get rid of paintLayerContentsAndReflection since we no
longer have reflections.

The rest of the changes are all just propagating the now
always false or true booleans in paintLayerContents.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/778883002
This commit is contained in:
Ojan Vafai 2014-12-04 12:12:05 -08:00
parent 260c29f783
commit 405dedb984
3 changed files with 29 additions and 81 deletions

View File

@ -52,16 +52,9 @@ namespace blink {
class RenderLayer;
// FIXME(sky): Get rid of this bitmasking and just use a regular enum.
enum PaintLayerFlag {
PaintLayerHaveTransparency = 1,
// FIXME(sky): This is unused. Remove it.
PaintLayerUncachedClipRects = 1 << 2,
PaintLayerPaintingOverlayScrollbars = 1 << 4,
PaintLayerPaintingCompositingBackgroundPhase = 1 << 5,
PaintLayerPaintingCompositingForegroundPhase = 1 << 6,
PaintLayerPaintingCompositingMaskPhase = 1 << 7,
PaintLayerPaintingCompositingScrollingPhase = 1 << 8,
PaintLayerPaintingCompositingAllPhases = (PaintLayerPaintingCompositingBackgroundPhase | PaintLayerPaintingCompositingForegroundPhase | PaintLayerPaintingCompositingMaskPhase)
PaintLayerPaintingOverlayScrollbars = 1,
};
typedef unsigned PaintLayerFlags;

View File

@ -626,14 +626,14 @@ LayoutRect RenderLayer::paintingExtent(const RenderLayer* rootLayer, const Layou
void RenderLayer::beginTransparencyLayers(GraphicsContext* context, const RenderLayer* rootLayer, const LayoutRect& paintDirtyRect, const LayoutSize& subPixelAccumulation, PaintBehavior paintBehavior)
{
if (paintsWithTransparency(paintBehavior) && m_usedTransparency)
if (isTransparent() && m_usedTransparency)
return;
RenderLayer* ancestor = transparentPaintingAncestor();
if (ancestor)
ancestor->beginTransparencyLayers(context, rootLayer, paintDirtyRect, subPixelAccumulation, paintBehavior);
if (paintsWithTransparency(paintBehavior)) {
if (isTransparent()) {
m_usedTransparency = true;
context->save();
LayoutRect clipRect = paintingExtent(rootLayer, paintDirtyRect, subPixelAccumulation, paintBehavior);
@ -959,9 +959,6 @@ void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo&
if (!renderer()->opacity())
return;
if (paintsWithTransparency(paintingInfo.paintBehavior))
paintFlags |= PaintLayerHaveTransparency;
if (paintsWithTransform(paintingInfo.paintBehavior)) {
TransformationMatrix layerTransform = renderableTransform(paintingInfo.paintBehavior);
// If the transform can't be inverted, then don't paint anything.
@ -970,7 +967,7 @@ void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo&
// If we have a transparency layer enclosing us and we are the root of a transform, then we need to establish the transparency
// layer from the parent now, assuming there is a parent
if (paintFlags & PaintLayerHaveTransparency) {
if (isTransparent()) {
if (parent())
parent()->beginTransparencyLayers(context, paintingInfo.rootLayer, paintingInfo.paintDirtyRect, paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior);
else
@ -980,7 +977,7 @@ void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo&
// Make sure the parent's clip rects have been calculated.
ClipRect clipRect = paintingInfo.paintDirtyRect;
if (parent()) {
ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects);
ClipRectsContext clipRectsContext(paintingInfo.rootLayer, PaintingClipRects);
clipRect = clipper().backgroundClipRect(clipRectsContext);
clipRect.intersect(paintingInfo.paintDirtyRect);
@ -997,44 +994,18 @@ void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo&
return;
}
paintLayerContentsAndReflection(context, paintingInfo, paintFlags);
}
void RenderLayer::paintLayerContentsAndReflection(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
{
ASSERT(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant());
PaintLayerFlags localPaintFlags = paintFlags | PaintLayerPaintingCompositingAllPhases;
paintLayerContents(context, paintingInfo, localPaintFlags);
paintLayerContents(context, paintingInfo, paintFlags);
}
void RenderLayer::paintLayerContents(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
{
ASSERT(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant());
bool haveTransparency = paintFlags & PaintLayerHaveTransparency;
bool isSelfPaintingLayer = this->isSelfPaintingLayer();
bool isPaintingOverlayScrollbars = paintFlags & PaintLayerPaintingOverlayScrollbars;
bool isPaintingScrollingContent = paintFlags & PaintLayerPaintingCompositingScrollingPhase;
bool isPaintingCompositedForeground = paintFlags & PaintLayerPaintingCompositingForegroundPhase;
bool isPaintingCompositedBackground = paintFlags & PaintLayerPaintingCompositingBackgroundPhase;
// Outline always needs to be painted even if we have no visible content. Also,
// the outline is painted in the background phase during composited scrolling.
// If it were painted in the foreground phase, it would move with the scrolled
// content. When not composited scrolling, the outline is painted in the
// foreground phase. Since scrolled contents are moved by paint invalidation in this
// case, the outline won't get 'dragged along'.
bool shouldPaintOutline = isSelfPaintingLayer && !isPaintingOverlayScrollbars
&& ((isPaintingScrollingContent && isPaintingCompositedBackground)
|| (!isPaintingScrollingContent && isPaintingCompositedForeground));
bool shouldPaintContent = isSelfPaintingLayer && !isPaintingOverlayScrollbars;
float deviceScaleFactor = blink::deviceScaleFactor(renderer()->frame());
context->setDeviceScaleFactor(deviceScaleFactor);
GraphicsContext* transparencyLayerContext = context;
// Ensure our lists are up-to-date.
m_stackingNode->updateLayerListsIfNeeded();
LayoutPoint offsetFromRoot;
@ -1072,14 +1043,16 @@ void RenderLayer::paintLayerContents(GraphicsContext* context, const LayerPainti
FilterEffectRendererHelper filterPainter(filterRenderer() && paintsWithFilters());
LayerFragments layerFragments;
if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) {
// Collect the fragments. This will compute the clip rectangles and paint offsets for each layer fragment, as well as whether or not the content of each
// fragment should paint.
collectFragments(layerFragments, localPaintingInfo.rootLayer, localPaintingInfo.paintDirtyRect,
(paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects,
&offsetFromRoot, localPaintingInfo.subPixelAccumulation);
updatePaintingInfoForFragments(layerFragments, localPaintingInfo, paintFlags, shouldPaintContent, &offsetFromRoot);
}
// Collect the fragments. This will compute the clip rectangles and paint offsets for each layer fragment, as well as whether or not the content of each
// fragment should paint.
collectFragments(layerFragments, localPaintingInfo.rootLayer, localPaintingInfo.paintDirtyRect,
PaintingClipRects, &offsetFromRoot, localPaintingInfo.subPixelAccumulation);
bool isPaintingOverlayScrollbars = paintFlags & PaintLayerPaintingOverlayScrollbars;
bool shouldPaintContent = isSelfPaintingLayer() && !isPaintingOverlayScrollbars;
updatePaintingInfoForFragments(layerFragments, localPaintingInfo, paintFlags, shouldPaintContent, &offsetFromRoot);
bool haveTransparency = isTransparent();
if (filterPainter.haveFilterEffect()) {
ASSERT(this->filterInfo());
@ -1138,36 +1111,25 @@ void RenderLayer::paintLayerContents(GraphicsContext* context, const LayerPainti
ASSERT(!(localPaintingInfo.paintBehavior & PaintBehaviorForceBlackText));
bool shouldPaintBackground = isPaintingCompositedBackground && shouldPaintContent;
bool shouldPaintNegZOrderList = !isPaintingScrollingContent && isPaintingCompositedBackground;
bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPaintContent;
bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForeground;
bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars;
bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && renderer()->hasMask();
// FIXME(sky): Get rid of PaintBehavior argument now that it's always Normal.
PaintBehavior paintBehavior = PaintBehaviorNormal;
if (shouldPaintBackground) {
if (shouldPaintContent) {
paintBackgroundForFragments(layerFragments, context, transparencyLayerContext, paintingInfo.paintDirtyRect, haveTransparency,
localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags);
}
if (shouldPaintNegZOrderList)
paintChildren(NegativeZOrderChildren, context, paintingInfo, paintFlags);
paintChildren(NegativeZOrderChildren, context, paintingInfo, paintFlags);
if (shouldPaintOwnContents) {
if (shouldPaintContent) {
paintForegroundForFragments(layerFragments, context, transparencyLayerContext, paintingInfo.paintDirtyRect, haveTransparency,
localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags);
}
if (shouldPaintOutline)
paintOutlineForFragments(layerFragments, context, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags);
paintOutlineForFragments(layerFragments, context, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags);
paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, paintingInfo, paintFlags);
if (shouldPaintNormalFlowAndPosZOrderLists)
paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, paintingInfo, paintFlags);
if (shouldPaintOverlayScrollbars)
if (isPaintingOverlayScrollbars)
paintOverflowControlsForFragments(layerFragments, context, localPaintingInfo, paintFlags);
if (filterPainter.hasStartedFilterEffect()) {
@ -1184,7 +1146,7 @@ void RenderLayer::paintLayerContents(GraphicsContext* context, const LayerPainti
// Make sure that we now use the original transparency context.
ASSERT(transparencyLayerContext == context);
if (shouldPaintMask)
if (shouldPaintContent && renderer()->hasMask())
paintMaskForFragments(layerFragments, context, localPaintingInfo, paintingRootForRenderer, paintFlags);
// End our transparency layer
@ -1217,7 +1179,7 @@ void RenderLayer::paintLayerByApplyingTransform(GraphicsContext* context, const
// Now do a paint with the root layer shifted to be us.
LayerPaintingInfo transformedPaintingInfo(this, enclosingIntRect(transform.inverse().mapRect(paintingInfo.paintDirtyRect)), paintingInfo.paintBehavior,
adjustedSubPixelAccumulation, paintingInfo.paintingRoot);
paintLayerContentsAndReflection(context, transformedPaintingInfo, paintFlags);
paintLayerContents(context, transformedPaintingInfo, paintFlags);
}
void RenderLayer::paintChildren(unsigned childrenToVisit, GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
@ -1968,7 +1930,7 @@ bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect)
if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant())
return false;
if (paintsWithTransparency(PaintBehaviorNormal))
if (isTransparent())
return false;
if (paintsWithFilters() && renderer()->style()->filter().hasFilterThatAffectsOpacity())

View File

@ -256,12 +256,6 @@ public:
// Computes the bounding paint invalidation rect for |renderObject|, in the coordinate space of |paintInvalidationContainer|'s GraphicsLayer backing.
static LayoutRect computePaintInvalidationRect(const RenderObject*, const RenderLayer* paintInvalidationContainer, const PaintInvalidationState* = 0);
bool paintsWithTransparency(PaintBehavior paintBehavior) const
{
// FIXME(sky): Remove
return isTransparent();
}
bool paintsWithTransform(PaintBehavior) const;
// Returns true if background phase is painted opaque in the given rect.
@ -421,9 +415,6 @@ public:
void updateSelfPaintingLayer();
// paintLayerContents() assumes that the caller will clip to the bounds of the painting dirty rect if necessary.
void paintLayerContents(GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags);
RenderLayer* enclosingTransformedAncestor() const;
LayoutPoint computeOffsetFromTransformedAncestor() const;
@ -460,7 +451,9 @@ private:
LayoutPoint renderBoxLocation() const { return renderer()->isBox() ? toRenderBox(renderer())->location() : LayoutPoint(); }
void paintLayerContentsAndReflection(GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags);
// paintLayerContents() assumes that the caller will clip to the bounds of the painting dirty rect if necessary.
void paintLayerContents(GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags);
void paintLayerByApplyingTransform(GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags, const LayoutPoint& translationOffset = LayoutPoint());
void paintChildren(unsigned childrenToVisit, GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags);