Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: Source/core/paint/LayerPainter.cpp

Issue 731933004: Get rid of LayerPainter::paintTransformedLayerIntoFragments(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/paint/LayerPainter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/paint/LayerPainter.h" 6 #include "core/paint/LayerPainter.h"
7 7
8 #include "core/frame/Settings.h" 8 #include "core/frame/Settings.h"
9 #include "core/page/Page.h" 9 #include "core/page/Page.h"
10 #include "core/paint/FilterPainter.h" 10 #include "core/paint/FilterPainter.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 // If this layer is totally invisible then there is nothing to paint. 64 // If this layer is totally invisible then there is nothing to paint.
65 if (!m_renderLayer.renderer()->opacity()) 65 if (!m_renderLayer.renderer()->opacity())
66 return; 66 return;
67 67
68 if (m_renderLayer.paintsWithTransparency(paintingInfo.paintBehavior)) 68 if (m_renderLayer.paintsWithTransparency(paintingInfo.paintBehavior))
69 paintFlags |= PaintLayerHaveTransparency; 69 paintFlags |= PaintLayerHaveTransparency;
70 70
71 // PaintLayerAppliedTransform is used in RenderReplica, to avoid applying th e transform twice. 71 // PaintLayerAppliedTransform is used in RenderReplica, to avoid applying th e transform twice.
72 if (m_renderLayer.paintsWithTransform(paintingInfo.paintBehavior) && !(paint Flags & PaintLayerAppliedTransform)) { 72 if (m_renderLayer.paintsWithTransform(paintingInfo.paintBehavior) && !(paint Flags & PaintLayerAppliedTransform)) {
73 // FIXME: move everything into paintLayerByApplyingTransform().
73 TransformationMatrix layerTransform = m_renderLayer.renderableTransform( paintingInfo.paintBehavior); 74 TransformationMatrix layerTransform = m_renderLayer.renderableTransform( paintingInfo.paintBehavior);
74 // If the transform can't be inverted, then don't paint anything. 75 // If the transform can't be inverted, then don't paint anything.
75 if (!layerTransform.isInvertible()) 76 if (!layerTransform.isInvertible())
76 return; 77 return;
77 78
78 if (m_renderLayer.enclosingPaginationLayer()) { 79 // If this is the "root" layer, clipping wrt. the ancestry has already b een set up, which
79 // FIXME: unify this one-off path with the code below. 80 // means that we can skip some unnecessary work (and even potentially in correct work at
80 paintTransformedLayerIntoFragments(context, paintingInfo, paintFlags ); 81 // that, if the ancestry has additional transforms).
81 return; 82 RenderLayer* parentLayer = &m_renderLayer == paintingInfo.rootLayer ? 0 : m_renderLayer.parent();
82 }
83 83
84 // Make sure the parent's clip rects have been calculated. 84 ClipRect clipRect(LayoutRect::infiniteRect());
85 ClipRect clipRect = paintingInfo.paintDirtyRect; 85 if (parentLayer) {
86 86 // Calculate the clip rectangle that the ancestors establish.
87 OwnPtr<ClipRecorder> clipRecorder;
88 if (m_renderLayer.parent()) {
89 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlag s & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, Ignore OverlayScrollbarSize); 87 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlag s & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, Ignore OverlayScrollbarSize);
90 if (shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()) == IgnoreOverflowClip) 88 if (shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()) == IgnoreOverflowClip)
91 clipRectsContext.setIgnoreOverflowClip(); 89 clipRectsContext.setIgnoreOverflowClip();
92 clipRect = m_renderLayer.clipper().backgroundClipRect(clipRectsConte xt); 90 clipRect = m_renderLayer.clipper().backgroundClipRect(clipRectsConte xt);
93 clipRect.intersect(paintingInfo.paintDirtyRect);
94
95 if (needsToClip(paintingInfo, clipRect)) {
96 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.parent()- >renderer(), context, DisplayItem::ClipLayerParent, clipRect));
97 if (clipRect.hasRadius())
98 applyRoundedRectClips(*m_renderLayer.parent(), paintingInfo, context, LayoutPoint(), paintFlags, *clipRecorder);
99 }
100 } 91 }
101 92
102 paintLayerByApplyingTransform(context, paintingInfo, paintFlags); 93 RenderLayer* paginationLayer = m_renderLayer.enclosingPaginationLayer();
94 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)
95 if (paginationLayer) {
96 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipR ects) ? UncachedClipRects : PaintingClipRects;
97 ShouldRespectOverflowClip respectOverflowClip = shouldRespectOverflo wClip(paintFlags, m_renderLayer.renderer());
98 // Calculate the transformed bounding box in the current coordinate space, to figure out
99 // which fragmentainers (e.g. columns) we need to visit.
100 LayoutRect transformedExtent = RenderLayer::transparencyClipBox(&m_r enderLayer, paginationLayer, RenderLayer::PaintingTransparencyClipBox, RenderLay er::RootOfTransparencyClipBox, paintingInfo.subPixelAccumulation, paintingInfo.p aintBehavior);
101 paginationLayer->collectFragments(fragments, paintingInfo.rootLayer, paintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOver flowClip, 0, paintingInfo.subPixelAccumulation, &transformedExtent);
102 } else {
103 // We don't need to collect any fragments in the regular way here. W e have already
104 // calculated a clip rectangle for the ancestry if it was needed, an d clipping this
105 // layer is something that can be done further down the path, when t he transform has
106 // been applied.
107 fragments.append(LayerFragment());
108 }
103 109
110 for (const auto& fragment: fragments) {
111 ClipRect clipRectForFragment(clipRect);
112 if (paginationLayer) {
113 clipRectForFragment.moveBy(fragment.paginationOffset);
114 clipRectForFragment.intersect(fragment.backgroundRect);
115 if (clipRectForFragment.isEmpty())
116 continue;
117 }
118 OwnPtr<ClipRecorder> clipRecorder;
119 if (parentLayer && needsToClip(paintingInfo, clipRectForFragment)) {
120 clipRecorder = adoptPtr(new ClipRecorder(parentLayer->renderer() , context, DisplayItem::ClipLayerParent, clipRectForFragment));
121 if (clipRectForFragment.hasRadius())
122 applyRoundedRectClips(*parentLayer, paintingInfo, context, f ragment.paginationOffset, paintFlags, *clipRecorder);
123 }
124
125 paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fra gment.paginationOffset);
126 }
104 return; 127 return;
105 } 128 }
106 129
107 paintLayerContentsAndReflection(context, paintingInfo, paintFlags); 130 paintLayerContentsAndReflection(context, paintingInfo, paintFlags);
108 } 131 }
109 132
110 class TransparencyLayerHelper { 133 class TransparencyLayerHelper {
111 public: 134 public:
112 TransparencyLayerHelper(GraphicsContext* context, RenderLayer& renderLayer, const RenderLayer* rootLayer, const LayoutRect& paintDirtyRect, const LayoutSize & subPixelAccumulation, PaintBehavior paintBehavior) 135 TransparencyLayerHelper(GraphicsContext* context, RenderLayer& renderLayer, const RenderLayer* rootLayer, const LayoutRect& paintDirtyRect, const LayoutSize & subPixelAccumulation, PaintBehavior paintBehavior)
113 : m_transparencyLayerInProgress(false) 136 : m_transparencyLayerInProgress(false)
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 { 786 {
764 if (!m_renderLayer.containsDirtyOverlayScrollbars()) 787 if (!m_renderLayer.containsDirtyOverlayScrollbars())
765 return; 788 return;
766 789
767 LayerPaintingInfo paintingInfo(&m_renderLayer, enclosingIntRect(damageRect), paintBehavior, LayoutSize(), paintingRoot); 790 LayerPaintingInfo paintingInfo(&m_renderLayer, enclosingIntRect(damageRect), paintBehavior, LayoutSize(), paintingRoot);
768 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 791 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
769 792
770 m_renderLayer.setContainsDirtyOverlayScrollbars(false); 793 m_renderLayer.setContainsDirtyOverlayScrollbars(false);
771 } 794 }
772 795
773 void LayerPainter::paintTransformedLayerIntoFragments(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
774 {
775 LayerFragments enclosingPaginationFragments;
776 LayoutPoint offsetOfPaginationLayerFromRoot;
777 LayoutRect transformedExtent = RenderLayer::transparencyClipBox(&m_renderLay er, m_renderLayer.enclosingPaginationLayer(), RenderLayer::PaintingTransparencyC lipBox, RenderLayer::RootOfTransparencyClipBox, paintingInfo.subPixelAccumulatio n, paintingInfo.paintBehavior);
778 m_renderLayer.enclosingPaginationLayer()->collectFragments(enclosingPaginati onFragments, paintingInfo.rootLayer, paintingInfo.paintDirtyRect,
779 (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : Paintin gClipRects, IgnoreOverlayScrollbarSize,
780 shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()), &offset OfPaginationLayerFromRoot, paintingInfo.subPixelAccumulation, &transformedExtent );
781
782 for (size_t i = 0; i < enclosingPaginationFragments.size(); ++i) {
783 const LayerFragment& fragment = enclosingPaginationFragments.at(i);
784
785 // Apply the page/column clip for this fragment, as well as any clips es tablished by layers in between us and
786 // the enclosing pagination layer.
787 LayoutRect clipRect = fragment.backgroundRect.rect();
788
789 // Now compute the clips within a given fragment
790 if (m_renderLayer.parent() != m_renderLayer.enclosingPaginationLayer()) {
791 m_renderLayer.enclosingPaginationLayer()->convertToLayerCoords(paint ingInfo.rootLayer, offsetOfPaginationLayerFromRoot);
792
793 ClipRectsContext clipRectsContext(m_renderLayer.enclosingPaginationL ayer(), (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : Paintin gClipRects, IgnoreOverlayScrollbarSize);
794 if (shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()) == IgnoreOverflowClip)
795 clipRectsContext.setIgnoreOverflowClip();
796 LayoutRect parentClipRect = m_renderLayer.clipper().backgroundClipRe ct(clipRectsContext).rect();
797 parentClipRect.moveBy(fragment.paginationOffset + offsetOfPagination LayerFromRoot);
798 clipRect.intersect(parentClipRect);
799 }
800
801 OwnPtr<ClipRecorder> clipRecorder;
802 if (needsToClip(paintingInfo, clipRect))
803 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), c ontext, DisplayItem::ClipLayerFragmentParent, clipRect));
804
805 paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fragmen t.paginationOffset);
806 }
807 }
808
809 } // namespace blink 796 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/LayerPainter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698