Chromium Code Reviews| Index: Source/core/paint/LayerPainter.cpp |
| diff --git a/Source/core/paint/LayerPainter.cpp b/Source/core/paint/LayerPainter.cpp |
| index 7decbdab8ef7ead87009d1268579061095fb7688..45a7b62d7c9d6decf0f0fa56026a26857db78294 100644 |
| --- a/Source/core/paint/LayerPainter.cpp |
| +++ b/Source/core/paint/LayerPainter.cpp |
| @@ -70,37 +70,60 @@ void LayerPainter::paintLayer(GraphicsContext* context, const LayerPaintingInfo& |
| // PaintLayerAppliedTransform is used in RenderReplica, to avoid applying the transform twice. |
| if (m_renderLayer.paintsWithTransform(paintingInfo.paintBehavior) && !(paintFlags & PaintLayerAppliedTransform)) { |
| + // FIXME: move everything into paintLayerByApplyingTransform(). |
| TransformationMatrix layerTransform = m_renderLayer.renderableTransform(paintingInfo.paintBehavior); |
| // If the transform can't be inverted, then don't paint anything. |
| if (!layerTransform.isInvertible()) |
| return; |
| - if (m_renderLayer.enclosingPaginationLayer()) { |
| - // FIXME: unify this one-off path with the code below. |
| - paintTransformedLayerIntoFragments(context, paintingInfo, paintFlags); |
| - return; |
| - } |
| - |
| - // Make sure the parent's clip rects have been calculated. |
| - ClipRect clipRect = paintingInfo.paintDirtyRect; |
| + // If this is the "root" layer, clipping wrt. the ancestry has already been set up, which |
| + // means that we can skip some unnecessary work (and even potentially incorrect work at |
| + // that, if the ancestry has additional transforms). |
| + RenderLayer* parentLayer = &m_renderLayer == paintingInfo.rootLayer ? 0 : m_renderLayer.parent(); |
| - OwnPtr<ClipRecorder> clipRecorder; |
| - if (m_renderLayer.parent()) { |
| + ClipRect clipRect(LayoutRect::infiniteRect()); |
| + if (parentLayer) { |
| + // Calculate the clip rectangle that the ancestors establish. |
| ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, IgnoreOverlayScrollbarSize); |
| if (shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()) == IgnoreOverflowClip) |
| clipRectsContext.setIgnoreOverflowClip(); |
| clipRect = m_renderLayer.clipper().backgroundClipRect(clipRectsContext); |
| - clipRect.intersect(paintingInfo.paintDirtyRect); |
| + } |
| - if (needsToClip(paintingInfo, clipRect)) { |
| - clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.parent()->renderer(), context, DisplayItem::ClipLayerParent, clipRect)); |
| - if (clipRect.hasRadius()) |
| - applyRoundedRectClips(*m_renderLayer.parent(), paintingInfo, context, LayoutPoint(), paintFlags, *clipRecorder); |
| - } |
| + RenderLayer* paginationLayer = m_renderLayer.enclosingPaginationLayer(); |
| + LayerFragments fragments; |
|
chrishtr
2014/11/17 23:27:49
Factor all this code into a new method paintFragme
mstensho (USE GERRIT)
2014/11/18 08:43:58
What I was going to do next (see the first FIXME)
|
| + if (paginationLayer) { |
| + ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects; |
| + ShouldRespectOverflowClip respectOverflowClip = shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()); |
| + // Calculate the transformed bounding box in the current coordinate space, to figure out |
| + // which fragmentainers (e.g. columns) we need to visit. |
| + LayoutRect transformedExtent = RenderLayer::transparencyClipBox(&m_renderLayer, paginationLayer, RenderLayer::PaintingTransparencyClipBox, RenderLayer::RootOfTransparencyClipBox, paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior); |
| + paginationLayer->collectFragments(fragments, paintingInfo.rootLayer, paintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, 0, paintingInfo.subPixelAccumulation, &transformedExtent); |
| + } else { |
| + // We don't need to collect any fragments in the regular way here. We have already |
| + // calculated a clip rectangle for the ancestry if it was needed, and clipping this |
| + // layer is something that can be done further down the path, when the transform has |
| + // been applied. |
| + fragments.append(LayerFragment()); |
| } |
| - paintLayerByApplyingTransform(context, paintingInfo, paintFlags); |
| + for (const auto& fragment: fragments) { |
| + ClipRect clipRectForFragment(clipRect); |
| + if (paginationLayer) { |
| + clipRectForFragment.moveBy(fragment.paginationOffset); |
| + clipRectForFragment.intersect(fragment.backgroundRect); |
| + if (clipRectForFragment.isEmpty()) |
| + continue; |
| + } |
| + OwnPtr<ClipRecorder> clipRecorder; |
| + if (parentLayer && needsToClip(paintingInfo, clipRectForFragment)) { |
| + clipRecorder = adoptPtr(new ClipRecorder(parentLayer->renderer(), context, DisplayItem::ClipLayerParent, clipRectForFragment)); |
| + if (clipRectForFragment.hasRadius()) |
| + applyRoundedRectClips(*parentLayer, paintingInfo, context, fragment.paginationOffset, paintFlags, *clipRecorder); |
| + } |
| + paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fragment.paginationOffset); |
| + } |
| return; |
| } |
| @@ -770,40 +793,4 @@ void LayerPainter::paintOverlayScrollbars(GraphicsContext* context, const Layout |
| m_renderLayer.setContainsDirtyOverlayScrollbars(false); |
| } |
| -void LayerPainter::paintTransformedLayerIntoFragments(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) |
| -{ |
| - LayerFragments enclosingPaginationFragments; |
| - LayoutPoint offsetOfPaginationLayerFromRoot; |
| - LayoutRect transformedExtent = RenderLayer::transparencyClipBox(&m_renderLayer, m_renderLayer.enclosingPaginationLayer(), RenderLayer::PaintingTransparencyClipBox, RenderLayer::RootOfTransparencyClipBox, paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior); |
| - m_renderLayer.enclosingPaginationLayer()->collectFragments(enclosingPaginationFragments, paintingInfo.rootLayer, paintingInfo.paintDirtyRect, |
| - (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, IgnoreOverlayScrollbarSize, |
| - shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()), &offsetOfPaginationLayerFromRoot, paintingInfo.subPixelAccumulation, &transformedExtent); |
| - |
| - for (size_t i = 0; i < enclosingPaginationFragments.size(); ++i) { |
| - const LayerFragment& fragment = enclosingPaginationFragments.at(i); |
| - |
| - // Apply the page/column clip for this fragment, as well as any clips established by layers in between us and |
| - // the enclosing pagination layer. |
| - LayoutRect clipRect = fragment.backgroundRect.rect(); |
| - |
| - // Now compute the clips within a given fragment |
| - if (m_renderLayer.parent() != m_renderLayer.enclosingPaginationLayer()) { |
| - m_renderLayer.enclosingPaginationLayer()->convertToLayerCoords(paintingInfo.rootLayer, offsetOfPaginationLayerFromRoot); |
| - |
| - ClipRectsContext clipRectsContext(m_renderLayer.enclosingPaginationLayer(), (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, IgnoreOverlayScrollbarSize); |
| - if (shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()) == IgnoreOverflowClip) |
| - clipRectsContext.setIgnoreOverflowClip(); |
| - LayoutRect parentClipRect = m_renderLayer.clipper().backgroundClipRect(clipRectsContext).rect(); |
| - parentClipRect.moveBy(fragment.paginationOffset + offsetOfPaginationLayerFromRoot); |
| - clipRect.intersect(parentClipRect); |
| - } |
| - |
| - OwnPtr<ClipRecorder> clipRecorder; |
| - if (needsToClip(paintingInfo, clipRect)) |
| - clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), context, DisplayItem::ClipLayerFragmentParent, clipRect)); |
| - |
| - paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fragment.paginationOffset); |
| - } |
| -} |
| - |
| } // namespace blink |