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

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

Issue 1284203004: Generate scroll/clip display item hierarchy for SPv2 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix assertion failure Created 5 years, 3 months 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 | Annotate | Revision Log
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/DeprecatedPaintLayerPainter.h" 6 #include "core/paint/DeprecatedPaintLayerPainter.h"
7 7
8 #include "core/frame/Settings.h" 8 #include "core/frame/Settings.h"
9 #include "core/layout/ClipPathOperation.h" 9 #include "core/layout/ClipPathOperation.h"
10 #include "core/layout/LayoutBlock.h" 10 #include "core/layout/LayoutBlock.h"
11 #include "core/layout/LayoutView.h" 11 #include "core/layout/LayoutView.h"
12 #include "core/layout/svg/LayoutSVGResourceClipper.h" 12 #include "core/layout/svg/LayoutSVGResourceClipper.h"
13 #include "core/page/Page.h" 13 #include "core/page/Page.h"
14 #include "core/paint/CompositingRecorder.h" 14 #include "core/paint/CompositingRecorder.h"
15 #include "core/paint/DeprecatedPaintLayer.h" 15 #include "core/paint/DeprecatedPaintLayer.h"
16 #include "core/paint/FilterPainter.h" 16 #include "core/paint/FilterPainter.h"
17 #include "core/paint/LayerClipRecorder.h" 17 #include "core/paint/LayerClipRecorder.h"
18 #include "core/paint/LayerDescendantClipRecorder.h"
18 #include "core/paint/LayerFixedPositionRecorder.h" 19 #include "core/paint/LayerFixedPositionRecorder.h"
19 #include "core/paint/PaintInfo.h" 20 #include "core/paint/PaintInfo.h"
20 #include "core/paint/SVGClipPainter.h" 21 #include "core/paint/SVGClipPainter.h"
21 #include "core/paint/ScopeRecorder.h" 22 #include "core/paint/ScopeRecorder.h"
22 #include "core/paint/ScrollRecorder.h" 23 #include "core/paint/ScrollRecorder.h"
23 #include "core/paint/ScrollableAreaPainter.h" 24 #include "core/paint/ScrollableAreaPainter.h"
24 #include "core/paint/Transform3DRecorder.h" 25 #include "core/paint/Transform3DRecorder.h"
26 #include "core/paint/TransformRecorder.h"
25 #include "platform/graphics/GraphicsLayer.h" 27 #include "platform/graphics/GraphicsLayer.h"
26 #include "platform/graphics/paint/ClipPathRecorder.h" 28 #include "platform/graphics/paint/ClipPathRecorder.h"
27 #include "platform/graphics/paint/ClipRecorder.h" 29 #include "platform/graphics/paint/ClipRecorder.h"
28 #include "platform/graphics/paint/CompositingDisplayItem.h" 30 #include "platform/graphics/paint/CompositingDisplayItem.h"
31 #include "platform/graphics/paint/FixedPositionContainerDisplayItem.h"
29 #include "platform/graphics/paint/SubsequenceRecorder.h" 32 #include "platform/graphics/paint/SubsequenceRecorder.h"
30 #include "platform/graphics/paint/Transform3DDisplayItem.h" 33 #include "platform/graphics/paint/Transform3DDisplayItem.h"
31 #include "wtf/Optional.h" 34 #include "wtf/Optional.h"
32 35
33 namespace blink { 36 namespace blink {
34 37
35 static inline bool shouldSuppressPaintingLayer(DeprecatedPaintLayer* layer) 38 static inline bool shouldSuppressPaintingLayer(DeprecatedPaintLayer* layer)
36 { 39 {
37 // Avoid painting descendants of the root layer when stylesheets haven't loa ded. This eliminates FOUC. 40 // Avoid painting descendants of the root layer when stylesheets haven't loa ded. This eliminates FOUC.
38 // It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document 41 // It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (!m_paintLayer.layoutObject()->opacity() && !m_paintLayer.layoutObject()- >hasBackdropFilter()) 87 if (!m_paintLayer.layoutObject()->opacity() && !m_paintLayer.layoutObject()- >hasBackdropFilter())
85 return; 88 return;
86 89
87 if (!needsRepaint && SubsequenceRecorder::useCachedSubsequenceIfPossible(*co ntext, m_paintLayer)) 90 if (!needsRepaint && SubsequenceRecorder::useCachedSubsequenceIfPossible(*co ntext, m_paintLayer))
88 return; 91 return;
89 SubsequenceRecorder subsequenceRecorder(*context, m_paintLayer); 92 SubsequenceRecorder subsequenceRecorder(*context, m_paintLayer);
90 93
91 if (m_paintLayer.paintsWithTransparency(paintingInfo.globalPaintFlags())) 94 if (m_paintLayer.paintsWithTransparency(paintingInfo.globalPaintFlags()))
92 paintFlags |= PaintLayerHaveTransparency; 95 paintFlags |= PaintLayerHaveTransparency;
93 96
94 LayerFixedPositionRecorder fixedPositionRecorder(*context, *m_paintLayer.lay outObject());
pdr. 2015/09/08 04:23:53 Can you pull this refactoring of LayerFixedPositio
trchen 2015/09/15 04:48:40 Done.
95
96 // PaintLayerAppliedTransform is used in LayoutReplica, to avoid applying th e transform twice. 97 // PaintLayerAppliedTransform is used in LayoutReplica, to avoid applying th e transform twice.
97 if (m_paintLayer.paintsWithTransform(paintingInfo.globalPaintFlags()) && !(p aintFlags & PaintLayerAppliedTransform)) { 98 if (m_paintLayer.paintsWithTransform(paintingInfo.globalPaintFlags()) && !(p aintFlags & PaintLayerAppliedTransform)) {
98 paintLayerWithTransform(context, paintingInfo, paintFlags); 99 paintLayerWithTransform(context, paintingInfo, paintFlags);
99 return; 100 return;
100 } 101 }
101 102
102 paintLayerContentsAndReflection(context, paintingInfo, paintFlags); 103 paintLayerContentsAndReflection(context, paintingInfo, paintFlags);
103 } 104 }
104 105
105 void DeprecatedPaintLayerPainter::paintLayerContentsAndReflection(GraphicsContex t* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintLayerFlag s paintFlags, FragmentPolicy fragmentPolicy) 106 void DeprecatedPaintLayerPainter::paintLayerContentsAndReflection(GraphicsContex t* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintLayerFlag s paintFlags, FragmentPolicy fragmentPolicy)
106 { 107 {
107 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay erDescendant()); 108 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay erDescendant());
108 109
109 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform) ; 110 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform) ;
110 111
111 // Paint the reflection first if we have one. 112 // Paint the reflection first if we have one.
112 if (m_paintLayer.reflectionInfo()) { 113 if (m_paintLayer.reflectionInfo()) {
113 ScopeRecorder scopeRecorder(*context); 114 ScopeRecorder scopeRecorder(*context);
114 m_paintLayer.reflectionInfo()->paint(context, paintingInfo, localPaintFl ags | PaintLayerPaintingReflection); 115 m_paintLayer.reflectionInfo()->paint(context, paintingInfo, localPaintFl ags | PaintLayerPaintingReflection);
115 } 116 }
116 117
117 localPaintFlags |= PaintLayerPaintingCompositingAllPhases; 118 localPaintFlags |= PaintLayerPaintingCompositingAllPhases;
118 paintLayerContents(context, paintingInfo, localPaintFlags, fragmentPolicy); 119 paintLayerContents(context, paintingInfo, localPaintFlags, fragmentPolicy);
119 } 120 }
120 121
121 class ClipPathHelper { 122 class ClipPathHelper {
122 public: 123 public:
123 ClipPathHelper(GraphicsContext* context, const DeprecatedPaintLayer& paintLa yer, const DeprecatedPaintLayerPaintingInfo& paintingInfo, LayoutRect& rootRelat iveBounds, bool& rootRelativeBoundsComputed, 124 ClipPathHelper(GraphicsContext* context, const DeprecatedPaintLayer& paintLa yer, const LayoutRect& interestRect, LayoutRect& rootRelativeBounds, bool& rootR elativeBoundsComputed,
pdr. 2015/09/08 04:23:53 Chris just landed a patch that uses DPLPI's ancest
trchen 2015/09/15 04:48:40 Done.
124 const LayoutPoint& offsetFromRoot, PaintLayerFlags paintFlags) 125 const LayoutPoint& offsetFromRoot, PaintLayerFlags paintFlags)
125 : m_resourceClipper(0), m_paintLayer(paintLayer), m_context(context) 126 : m_resourceClipper(0), m_paintLayer(paintLayer), m_context(context)
126 { 127 {
127 const ComputedStyle& style = paintLayer.layoutObject()->styleRef(); 128 const ComputedStyle& style = paintLayer.layoutObject()->styleRef();
128 129
129 // Clip-path, like border radius, must not be applied to the contents of a composited-scrolling container. 130 // Clip-path, like border radius, must not be applied to the contents of a composited-scrolling container.
130 // It must, however, still be applied to the mask layer, so that the com positor can properly mask the 131 // It must, however, still be applied to the mask layer, so that the com positor can properly mask the
131 // scrolling contents and scrollbars. 132 // scrolling contents and scrollbars.
132 if (!paintLayer.layoutObject()->hasClipPath() || (paintLayer.needsCompos itedScrolling() && !(paintFlags & PaintLayerPaintingChildClippingMaskPhase))) 133 if (!paintLayer.layoutObject()->hasClipPath() || (paintLayer.needsCompos itedScrolling() && !(paintFlags & PaintLayerPaintingChildClippingMaskPhase)))
133 return; 134 return;
(...skipping 16 matching lines...) Expand all
150 // FIXME: It doesn't work with forward or external SVG references (h ttps://bugs.webkit.org/show_bug.cgi?id=90405) 151 // FIXME: It doesn't work with forward or external SVG references (h ttps://bugs.webkit.org/show_bug.cgi?id=90405)
151 Element* element = document.getElementById(referenceClipPathOperatio n->fragment()); 152 Element* element = document.getElementById(referenceClipPathOperatio n->fragment());
152 if (isSVGClipPathElement(element) && element->layoutObject()) { 153 if (isSVGClipPathElement(element) && element->layoutObject()) {
153 if (!rootRelativeBoundsComputed) { 154 if (!rootRelativeBoundsComputed) {
154 rootRelativeBounds = paintLayer.physicalBoundingBoxIncluding ReflectionAndStackingChildren(offsetFromRoot); 155 rootRelativeBounds = paintLayer.physicalBoundingBoxIncluding ReflectionAndStackingChildren(offsetFromRoot);
155 rootRelativeBoundsComputed = true; 156 rootRelativeBoundsComputed = true;
156 } 157 }
157 158
158 m_resourceClipper = toLayoutSVGResourceClipper(toLayoutSVGResour ceContainer(element->layoutObject())); 159 m_resourceClipper = toLayoutSVGResourceClipper(toLayoutSVGResour ceContainer(element->layoutObject()));
159 if (!SVGClipPainter(*m_resourceClipper).prepareEffect(*paintLaye r.layoutObject(), FloatRect(rootRelativeBounds), 160 if (!SVGClipPainter(*m_resourceClipper).prepareEffect(*paintLaye r.layoutObject(), FloatRect(rootRelativeBounds),
160 FloatRect(paintingInfo.paintDirtyRect), context, m_clipperSt ate)) { 161 FloatRect(interestRect), context, m_clipperState)) {
161 // No need to post-apply the clipper if this failed. 162 // No need to post-apply the clipper if this failed.
162 m_resourceClipper = 0; 163 m_resourceClipper = 0;
163 } 164 }
164 } 165 }
165 } 166 }
166 } 167 }
167 168
168 ~ClipPathHelper() 169 ~ClipPathHelper()
169 { 170 {
170 if (m_resourceClipper) 171 if (m_resourceClipper)
(...skipping 28 matching lines...) Expand all
199 && ((isPaintingScrollingContent && isPaintingCompositedBackground) 200 && ((isPaintingScrollingContent && isPaintingCompositedBackground)
200 || (!isPaintingScrollingContent && isPaintingCompositedForeground)); 201 || (!isPaintingScrollingContent && isPaintingCompositedForeground));
201 bool shouldPaintContent = m_paintLayer.hasVisibleContent() && isSelfPainting Layer && !isPaintingOverlayScrollbars; 202 bool shouldPaintContent = m_paintLayer.hasVisibleContent() && isSelfPainting Layer && !isPaintingOverlayScrollbars;
202 203
203 if (paintFlags & PaintLayerPaintingRootBackgroundOnly && !m_paintLayer.layou tObject()->isLayoutView() && !m_paintLayer.layoutObject()->isDocumentElement()) 204 if (paintFlags & PaintLayerPaintingRootBackgroundOnly && !m_paintLayer.layou tObject()->isLayoutView() && !m_paintLayer.layoutObject()->isDocumentElement())
204 return; 205 return;
205 206
206 // Ensure our lists are up-to-date. 207 // Ensure our lists are up-to-date.
207 m_paintLayer.stackingNode()->updateLayerListsIfNeeded(); 208 m_paintLayer.stackingNode()->updateLayerListsIfNeeded();
208 209
209 LayoutPoint offsetFromRoot; 210 LayoutPoint offsetFromRoot = toLayoutPoint(paintingInfo.subPixelAccumulation );
210 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); 211 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
211 212 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot , DeprecatedPaintLayer::ExcludeScroll);
212 if (m_paintLayer.compositingState() == PaintsIntoOwnBacking)
pdr. 2015/09/08 04:23:53 The offsetFromRoot refactoring looks correct, but
trchen 2015/09/15 04:48:40 Done. I think paintingInfo.subPixelAccumulation wi
213 offsetFromRoot.move(m_paintLayer.subpixelAccumulation());
214 else 213 else
215 offsetFromRoot.move(paintingInfo.subPixelAccumulation); 214 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot );
216 215
217 LayoutRect rootRelativeBounds; 216 LayoutRect rootRelativeBounds;
218 bool rootRelativeBoundsComputed = false; 217 bool rootRelativeBoundsComputed = false;
219 218
219 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && !context->displayIte mList()->displayItemConstructionIsDisabled()) {
220 if (paintingInfo.rootLayer == &m_paintLayer) {
221 // A counter scroll needs to be applied in non-rootLayerScrolls mode ,
222 // because we are supposed to paint in absolute space.
223 // (i.e. Impl-side scrolling would be impossible.)
224 // With rootLayerScrolls enabled, we are in the viewport space inste ad.
225 AffineTransform counterScroll;
226 if (m_paintLayer.layoutObject()->isLayoutView()) {
227 Settings* settings = m_paintLayer.layoutObject()->document().set tings();
228 if (settings && settings->rootLayerScrolls()) {
229 IntSize scrollOffset = static_cast<LayoutView*>(m_paintLayer .layoutObject())->frameView()->scrollOffset();
230 counterScroll.translate(scrollOffset.width(), scrollOffset.h eight());
231 }
232 }
233 TransformRecorder frameScrollWorkaround(*context, *m_paintLayer.layo utObject(), counterScroll);
234
235 context->displayItemList()->createAndAppend<FixedPositionContainerDi splayItem>(*m_paintLayer.layoutObject());
236 }
237 }
238
220 // These helpers output clip and compositing operations using a RAII pattern . Stack-allocated-varibles are destructed in the reverse order of construction, 239 // These helpers output clip and compositing operations using a RAII pattern . Stack-allocated-varibles are destructed in the reverse order of construction,
221 // so they are nested properly. 240 // so they are nested properly.
222 ClipPathHelper clipPathHelper(context, m_paintLayer, paintingInfo, rootRelat iveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); 241 ClipPathHelper clipPathHelper(context, m_paintLayer, paintingInfo.paintDirty Rect, rootRelativeBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags );
223 242
224 Optional<CompositingRecorder> compositingRecorder; 243 Optional<CompositingRecorder> compositingRecorder;
225 // Blending operations must be performed only with the nearest ancestor stac king context. 244 // Blending operations must be performed only with the nearest ancestor stac king context.
226 // Note that there is no need to composite if we're painting the root. 245 // Note that there is no need to composite if we're painting the root.
227 // FIXME: this should be unified further into DeprecatedPaintLayer::paintsWi thTransparency(). 246 // FIXME: this should be unified further into DeprecatedPaintLayer::paintsWi thTransparency().
228 bool shouldCompositeForBlendMode = (!m_paintLayer.layoutObject()->isDocument Element() || m_paintLayer.layoutObject()->isSVGRoot()) && m_paintLayer.stackingN ode()->isStackingContext() && m_paintLayer.hasNonIsolatedDescendantWithBlendMode (); 247 bool shouldCompositeForBlendMode = (!m_paintLayer.layoutObject()->isDocument Element() || m_paintLayer.layoutObject()->isSVGRoot()) && m_paintLayer.stackingN ode()->isStackingContext() && m_paintLayer.hasNonIsolatedDescendantWithBlendMode ();
229 if (shouldCompositeForBlendMode || m_paintLayer.paintsWithTransparency(paint ingInfo.globalPaintFlags())) { 248 if (shouldCompositeForBlendMode || m_paintLayer.paintsWithTransparency(paint ingInfo.globalPaintFlags())) {
230 FloatRect compositingBounds = FloatRect(m_paintLayer.paintingExtent(pain tingInfo.rootLayer, paintingInfo.paintDirtyRect, paintingInfo.globalPaintFlags() )); 249 FloatRect compositingBounds = FloatRect(m_paintLayer.paintingExtent(pain tingInfo.rootLayer, paintingInfo.paintDirtyRect, paintingInfo.globalPaintFlags() ));
231 compositingRecorder.emplace(*context, *m_paintLayer.layoutObject(), 250 compositingRecorder.emplace(*context, *m_paintLayer.layoutObject(),
232 WebCoreCompositeToSkiaComposite(CompositeSourceOver, m_paintLayer.la youtObject()->style()->blendMode()), 251 WebCoreCompositeToSkiaComposite(CompositeSourceOver, m_paintLayer.la youtObject()->style()->blendMode()),
233 m_paintLayer.layoutObject()->opacity(), &compositingBounds); 252 m_paintLayer.layoutObject()->opacity(), &compositingBounds);
234 } 253 }
235 254
236 DeprecatedPaintLayerPaintingInfo localPaintingInfo(paintingInfo);
237 if (m_paintLayer.compositingState() == PaintsIntoOwnBacking)
238 localPaintingInfo.subPixelAccumulation = m_paintLayer.subpixelAccumulati on();
239
240 DeprecatedPaintLayerFragments layerFragments; 255 DeprecatedPaintLayerFragments layerFragments;
241 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) { 256 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) {
242 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment. 257 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment.
243 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects; 258 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects;
244 ShouldRespectOverflowClip respectOverflowClip = shouldRespectOverflowCli p(paintFlags, m_paintLayer.layoutObject()); 259 ShouldRespectOverflowClip respectOverflowClip = shouldRespectOverflowCli p(paintFlags, m_paintLayer.layoutObject());
245 if (fragmentPolicy == ForceSingleFragment) 260 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
246 m_paintLayer.appendSingleFragmentIgnoringPagination(layerFragments, localPaintingInfo.rootLayer, localPaintingInfo.paintDirtyRect, cacheSlot, Ignore OverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.su bPixelAccumulation); 261 // TODO(trchen): Need to handle layer fragmentation.
247 else 262 DeprecatedPaintLayerFragment fragment;
248 m_paintLayer.collectFragments(layerFragments, localPaintingInfo.root Layer, localPaintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.subPixelAccumulation); 263 fragment.layerBounds = LayoutRect(offsetFromRoot, LayoutSize(m_paint Layer.size()));
264 fragment.backgroundRect = LayoutRect::infiniteRect();
265 fragment.foregroundRect = LayoutRect::infiniteRect();
266 fragment.outlineRect = LayoutRect::infiniteRect();
267 layerFragments.append(fragment);
268 } else if (fragmentPolicy == ForceSingleFragment) {
269 m_paintLayer.appendSingleFragmentIgnoringPagination(layerFragments, paintingInfo.rootLayer, paintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScr ollbarSize, respectOverflowClip, &offsetFromRoot, paintingInfo.subPixelAccumulat ion);
270 } else {
271 m_paintLayer.collectFragments(layerFragments, paintingInfo.rootLayer , paintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOve rflowClip, &offsetFromRoot, paintingInfo.subPixelAccumulation);
272 }
273
249 if (shouldPaintContent) 274 if (shouldPaintContent)
250 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(layerFra gments, localPaintingInfo, paintFlags, offsetFromRoot); 275 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(layerFra gments, paintingInfo, paintFlags, offsetFromRoot);
251 } 276 }
252 277
253 bool selectionOnly = localPaintingInfo.globalPaintFlags() & GlobalPaintSelec tionOnly; 278 bool selectionOnly = paintingInfo.globalPaintFlags() & GlobalPaintSelectionO nly;
254 // If this layer's layoutObject is a child of the paintingRoot, we paint unc onditionally, which 279 // If this layer's layoutObject is a child of the paintingRoot, we paint unc onditionally, which
255 // is done by passing a nil paintingRoot down to our layoutObject (as if no paintingRoot was ever set). 280 // is done by passing a nil paintingRoot down to our layoutObject (as if no paintingRoot was ever set).
256 // Else, our layout tree may or may not contain the painting root, so we pas s that root along 281 // Else, our layout tree may or may not contain the painting root, so we pas s that root along
257 // so it will be tested against as we descend through the layoutObjects. 282 // so it will be tested against as we descend through the layoutObjects.
258 LayoutObject* paintingRootForLayoutObject = 0; 283 LayoutObject* paintingRootForLayoutObject = 0;
259 if (localPaintingInfo.paintingRoot && !m_paintLayer.layoutObject()->isDescen dantOf(localPaintingInfo.paintingRoot)) 284 if (paintingInfo.paintingRoot && !m_paintLayer.layoutObject()->isDescendantO f(paintingInfo.paintingRoot))
260 paintingRootForLayoutObject = localPaintingInfo.paintingRoot; 285 paintingRootForLayoutObject = paintingInfo.paintingRoot;
261 286
262 { // Begin block for the lifetime of any filter. 287 { // Begin block for the lifetime of any filter.
288 // FilterPainter may mutate paintingInfo.
289 DeprecatedPaintLayerPaintingInfo localPaintingInfo(paintingInfo);
290 localPaintingInfo.clipToDirtyRect = true;
pdr. 2015/09/08 04:23:53 This violate's the comment above clipToDirtyRect b
trchen 2015/09/15 04:48:40 IMO clipToDirtyRect is not inherited and shouldn't
263 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, layer Fragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect, localPainti ngInfo, paintFlags, 291 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, layer Fragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect, localPainti ngInfo, paintFlags,
264 rootRelativeBounds, rootRelativeBoundsComputed); 292 rootRelativeBounds, rootRelativeBoundsComputed);
265 293
266 bool shouldPaintBackground = isPaintingCompositedBackground && shouldPai ntContent && !selectionOnly; 294 bool shouldPaintBackground = isPaintingCompositedBackground && shouldPai ntContent && !selectionOnly;
267 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintin gOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackgr ound); 295 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintin gOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackgr ound);
268 bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPa intContent; 296 bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPa intContent;
269 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForegr ound; 297 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForegr ound;
270 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars; 298 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars;
271 299
272 if (shouldPaintBackground) { 300 if (shouldPaintBackground) {
273 paintBackgroundForFragments(layerFragments, context, paintingInfo.pa intDirtyRect, 301 paintBackgroundForFragments(layerFragments, context, localPaintingIn fo.paintDirtyRect,
274 localPaintingInfo, paintingRootForLayoutObject, paintFlags); 302 localPaintingInfo, paintingRootForLayoutObject, paintFlags);
275 } 303 }
276 304
277 if (shouldPaintNegZOrderList) 305 if (shouldPaintNegZOrderList)
278 paintChildren(NegativeZOrderChildren, context, paintingInfo, paintFl ags); 306 paintChildren(NegativeZOrderChildren, context, localPaintingInfo, pa intFlags);
279 307
280 if (shouldPaintOwnContents) { 308 if (shouldPaintOwnContents) {
281 paintForegroundForFragments(layerFragments, context, paintingInfo.pa intDirtyRect, 309 paintForegroundForFragments(layerFragments, context, localPaintingIn fo.paintDirtyRect,
282 localPaintingInfo, paintingRootForLayoutObject, selectionOnly, p aintFlags); 310 localPaintingInfo, paintingRootForLayoutObject, selectionOnly, p aintFlags);
283 } 311 }
284 312
285 if (shouldPaintOutline) 313 if (shouldPaintOutline)
286 paintOutlineForFragments(layerFragments, context, localPaintingInfo, paintingRootForLayoutObject, paintFlags); 314 paintOutlineForFragments(layerFragments, context, localPaintingInfo, paintingRootForLayoutObject, paintFlags);
287 315
288 if (shouldPaintNormalFlowAndPosZOrderLists) 316 if (shouldPaintNormalFlowAndPosZOrderLists)
289 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, paintingInfo, paintFlags); 317 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, localPaintingInfo, paintFlags);
290 318
291 if (shouldPaintOverlayScrollbars) 319 if (shouldPaintOverlayScrollbars)
292 paintOverflowControlsForFragments(layerFragments, context, localPain tingInfo, paintFlags); 320 paintOverflowControlsForFragments(layerFragments, context, localPain tingInfo, paintFlags);
293 } // FilterPainter block 321 } // FilterPainter block
294 322
295 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && !selectionOn ly; 323 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && !selectionOn ly;
296 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping MaskPhase) && shouldPaintContent && !selectionOnly; 324 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping MaskPhase) && shouldPaintContent && !selectionOnly;
297 325
298 if (shouldPaintMask) 326 if (shouldPaintMask)
299 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti ngRootForLayoutObject, paintFlags); 327 paintMaskForFragments(layerFragments, context, paintingInfo, paintingRoo tForLayoutObject, paintFlags);
300 if (shouldPaintClippingMask) { 328 if (shouldPaintClippingMask) {
301 // Paint the border radius mask for the fragments. 329 // Paint the border radius mask for the fragments.
302 paintChildClippingMaskForFragments(layerFragments, context, localPaintin gInfo, paintingRootForLayoutObject, paintFlags); 330 paintChildClippingMaskForFragments(layerFragments, context, paintingInfo , paintingRootForLayoutObject, paintFlags);
303 } 331 }
304 } 332 }
305 333
306 bool DeprecatedPaintLayerPainter::needsToClip(const DeprecatedPaintLayerPainting Info& localPaintingInfo, const ClipRect& clipRect) 334 bool DeprecatedPaintLayerPainter::needsToClip(const DeprecatedPaintLayerPainting Info& localPaintingInfo, const ClipRect& clipRect)
307 { 335 {
336 // With SPv2 a layer clips its descendants so a layer never clips itself.
337 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
338 return false;
308 return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRa dius(); 339 return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRa dius();
309 } 340 }
310 341
311 bool DeprecatedPaintLayerPainter::atLeastOneFragmentIntersectsDamageRect(Depreca tedPaintLayerFragments& fragments, const DeprecatedPaintLayerPaintingInfo& local PaintingInfo, PaintLayerFlags localPaintFlags, const LayoutPoint& offsetFromRoot ) 342 bool DeprecatedPaintLayerPainter::atLeastOneFragmentIntersectsDamageRect(Depreca tedPaintLayerFragments& fragments, const DeprecatedPaintLayerPaintingInfo& local PaintingInfo, PaintLayerFlags localPaintFlags, const LayoutPoint& offsetFromRoot )
312 { 343 {
313 if (m_paintLayer.enclosingPaginationLayer()) 344 if (m_paintLayer.enclosingPaginationLayer())
314 return true; // The fragments created have already been found to interse ct with the damage rect. 345 return true; // The fragments created have already been found to interse ct with the damage rect.
315 346
316 if (&m_paintLayer == localPaintingInfo.rootLayer && (localPaintFlags & Paint LayerPaintingOverflowContents)) 347 if (&m_paintLayer == localPaintingInfo.rootLayer && (localPaintFlags & Paint LayerPaintingOverflowContents))
317 return true; 348 return true;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 445
415 void DeprecatedPaintLayerPainter::paintChildren(unsigned childrenToVisit, Graphi csContext* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintL ayerFlags paintFlags) 446 void DeprecatedPaintLayerPainter::paintChildren(unsigned childrenToVisit, Graphi csContext* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintL ayerFlags paintFlags)
416 { 447 {
417 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) 448 if (!m_paintLayer.hasSelfPaintingLayerDescendant())
418 return; 449 return;
419 450
420 #if ENABLE(ASSERT) 451 #if ENABLE(ASSERT)
421 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode()); 452 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode());
422 #endif 453 #endif
423 454
455 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
456 paintChildrenWithFullScrollClipChain(childrenToVisit, context, paintingI nfo, paintFlags);
457 return;
458 }
459
424 IntSize scrollOffsetAccumulation = paintingInfo.scrollOffsetAccumulation; 460 IntSize scrollOffsetAccumulation = paintingInfo.scrollOffsetAccumulation;
425 if (m_paintLayer.layoutObject()->hasOverflowClip()) 461 if (m_paintLayer.layoutObject()->hasOverflowClip())
426 scrollOffsetAccumulation += m_paintLayer.layoutBox()->scrolledContentOff set(); 462 scrollOffsetAccumulation += m_paintLayer.layoutBox()->scrolledContentOff set();
427 463
428 DeprecatedPaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode (), childrenToVisit); 464 DeprecatedPaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode (), childrenToVisit);
429 while (DeprecatedPaintLayerStackingNode* child = iterator.next()) { 465 while (DeprecatedPaintLayerStackingNode* child = iterator.next()) {
430 DeprecatedPaintLayerPainter childPainter(*child->layer()); 466 DeprecatedPaintLayerPainter childPainter(*child->layer());
431 // If this Layer should paint into its own backing or a grouped backing, that will be done via CompositedDeprecatedPaintLayerMapping::paintContents() 467 // If this Layer should paint into its own backing or a grouped backing, that will be done via CompositedDeprecatedPaintLayerMapping::paintContents()
432 // and CompositedDeprecatedPaintLayerMapping::doPaintTask(). 468 // and CompositedDeprecatedPaintLayerMapping::doPaintTask().
433 if (!childPainter.shouldPaintLayerInSoftwareMode(paintingInfo.globalPain tFlags(), paintFlags)) 469 if (!childPainter.shouldPaintLayerInSoftwareMode(paintingInfo.globalPain tFlags(), paintFlags))
434 continue; 470 continue;
435 471
436 DeprecatedPaintLayerPaintingInfo childPaintingInfo = paintingInfo; 472 DeprecatedPaintLayerPaintingInfo childPaintingInfo = paintingInfo;
437 childPaintingInfo.scrollOffsetAccumulation = scrollOffsetAccumulation; 473 childPaintingInfo.scrollOffsetAccumulation = scrollOffsetAccumulation;
438 // Rare case: accumulate scroll offset of non-stacking-context ancestors up to m_paintLayer. 474 // Rare case: accumulate scroll offset of non-stacking-context ancestors up to m_paintLayer.
439 for (DeprecatedPaintLayer* parentLayer = child->layer()->parent(); paren tLayer != &m_paintLayer; parentLayer = parentLayer->parent()) { 475 for (DeprecatedPaintLayer* parentLayer = child->layer()->parent(); paren tLayer != &m_paintLayer; parentLayer = parentLayer->parent()) {
440 if (parentLayer->layoutObject()->hasOverflowClip()) 476 if (parentLayer->layoutObject()->hasOverflowClip())
441 childPaintingInfo.scrollOffsetAccumulation += parentLayer->layou tBox()->scrolledContentOffset(); 477 childPaintingInfo.scrollOffsetAccumulation += parentLayer->layou tBox()->scrolledContentOffset();
442 } 478 }
443 479
444 childPainter.paintLayer(context, childPaintingInfo, paintFlags); 480 childPainter.paintLayer(context, childPaintingInfo, paintFlags);
445 } 481 }
446 } 482 }
447 483
484 static void recursivelyScrollAndPaintChildLayer(Vector<DeprecatedPaintLayer*>& c lippingAncestors, DeprecatedPaintLayer& child, GraphicsContext& context, const D eprecatedPaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
485 {
486 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
487 if (clippingAncestors.isEmpty()) {
488 DeprecatedPaintLayerPainter(child).paintLayer(&context, paintingInfo, pa intFlags);
489 return;
490 }
491 DeprecatedPaintLayer* layer = clippingAncestors.last();
492 clippingAncestors.removeLast();
493
494 ASSERT(layer->layoutObject()->hasOverflowClip() && layer->layoutObject()->is Box());
495 LayoutPoint paintOffset = toLayoutPoint(paintingInfo.subPixelAccumulation);
496 // TODO(trchen): Hey this is slow. We should be able to calculate this on tr aversal.
pdr. 2015/09/08 04:23:53 Would it be difficult to go ahead and compute all
trchen 2015/09/15 04:48:40 Done.
497 layer->convertToLayerCoords(paintingInfo.rootLayer, paintOffset, DeprecatedP aintLayer::ExcludeScroll);
498 LayerDescendantClipRecorder clipRecorder(context, *layer->layoutBox(), paint Offset);
499
500 IntSize scrollOffset = layer->layoutBox()->scrolledContentOffset();
501 Optional<ScrollRecorder> scrollRecorder;
502 if (layer->scrollsOverflow() || !scrollOffset.isZero())
503 scrollRecorder.emplace(context, *layer->layoutObject(), PaintPhaseBlockB ackground, scrollOffset);
504 recursivelyScrollAndPaintChildLayer(clippingAncestors, child, context, paint ingInfo, paintFlags);
505 }
506
507 // TODO(trchen): Measure performance of this and implement display item de-dupin g if needed.
508 // For the pessimistic case this function will generate O(n^2) of clip/scroll pa irs, for example:
509 // <div style="overflow:scroll;"> * repeat 100 times
510 // <div style="position:relative;"></div> * repeat 100 times
511 // We will need to generate 100 clip/scroll pairs for each of the in-flow positi oned children.
512 void DeprecatedPaintLayerPainter::paintChildrenWithFullScrollClipChain(unsigned childrenToVisit, GraphicsContext* context, const DeprecatedPaintLayerPaintingInf o& paintingInfo, PaintLayerFlags paintFlags)
513 {
514 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
515
516 DeprecatedPaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode (), childrenToVisit);
517 while (DeprecatedPaintLayerStackingNode* childNode = iterator.next()) {
518 DeprecatedPaintLayer* child = childNode->layer();
519 EPosition childPosition = child->layoutObject()->style()->position();
520 if (childPosition == FixedPosition) {
521 ASSERT(paintingInfo.rootLayer == child->enclosingPositionedAncestor( ));
522 // TODO(trchen): Handle the insanity with reflection + fixed positio n.
523 LayerFixedPositionRecorder fixedPositionRecorder(*context, *child->l ayoutObject(), *paintingInfo.rootLayer->layoutObject());
524 DeprecatedPaintLayerPainter(*child).paintLayer(context, paintingInfo , paintFlags);
525 continue;
526 }
527
528 Vector<DeprecatedPaintLayer*> clippingAncestors;
529 DeprecatedPaintLayer* currentLayer = child;
pdr. 2015/09/08 04:23:53 Can you break this out into computeClippingLayersB
trchen 2015/09/15 04:48:40 Done.
530 while (currentLayer && currentLayer != &m_paintLayer) {
531 EPosition position = currentLayer->layoutObject()->style()->position ();
532 ASSERT(position != FixedPosition);
533
534 DeprecatedPaintLayer* container = nullptr;
535 if (position == AbsolutePosition) {
536 bool ranPastThisLayer;
537 container = currentLayer->enclosingPositionedAncestor(&m_paintLa yer, &ranPastThisLayer);
538 if (ranPastThisLayer)
539 break;
540 } else {
541 container = currentLayer->parent();
542 }
543 if (!container)
544 break;
545
546 if (container->layoutObject()->hasOverflowClip())
547 clippingAncestors.append(container);
548
549 currentLayer = container;
550 }
551
552 recursivelyScrollAndPaintChildLayer(clippingAncestors, *child, *context, paintingInfo, paintFlags);
553 }
554 }
555
448 // FIXME: inline this. 556 // FIXME: inline this.
449 static bool paintForFixedRootBackground(const DeprecatedPaintLayer* layer, Paint LayerFlags paintFlags) 557 static bool paintForFixedRootBackground(const DeprecatedPaintLayer* layer, Paint LayerFlags paintFlags)
450 { 558 {
451 return layer->layoutObject()->isDocumentElement() && (paintFlags & PaintLaye rPaintingRootBackgroundOnly); 559 return layer->layoutObject()->isDocumentElement() && (paintFlags & PaintLaye rPaintingRootBackgroundOnly);
452 } 560 }
453 561
454 bool DeprecatedPaintLayerPainter::shouldPaintLayerInSoftwareMode(const GlobalPai ntFlags globalPaintFlags, PaintLayerFlags paintFlags) 562 bool DeprecatedPaintLayerPainter::shouldPaintLayerInSoftwareMode(const GlobalPai ntFlags globalPaintFlags, PaintLayerFlags paintFlags)
455 { 563 {
456 DisableCompositingQueryAsserts disabler; 564 DisableCompositingQueryAsserts disabler;
457 565
(...skipping 17 matching lines...) Expand all
475 clipRecorder.emplace(*context, *m_paintLayer.layoutObject(), Display Item::ClipLayerOverflowControls, fragment.backgroundRect, &localPaintingInfo, fr agment.paginationOffset, paintFlags); 583 clipRecorder.emplace(*context, *m_paintLayer.layoutObject(), Display Item::ClipLayerOverflowControls, fragment.backgroundRect, &localPaintingInfo, fr agment.paginationOffset, paintFlags);
476 if (DeprecatedPaintLayerScrollableArea* scrollableArea = m_paintLayer.sc rollableArea()) 584 if (DeprecatedPaintLayerScrollableArea* scrollableArea = m_paintLayer.sc rollableArea())
477 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context , roundedIntPoint(toPoint(fragment.layerBounds.location() - m_paintLayer.layoutB oxLocation())), pixelSnappedIntRect(fragment.backgroundRect.rect()), true); 585 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context , roundedIntPoint(toPoint(fragment.layerBounds.location() - m_paintLayer.layoutB oxLocation())), pixelSnappedIntRect(fragment.backgroundRect.rect()), true);
478 } 586 }
479 } 587 }
480 588
481 void DeprecatedPaintLayerPainter::paintFragmentWithPhase(PaintPhase phase, const DeprecatedPaintLayerFragment& fragment, GraphicsContext* context, const ClipRec t& clipRect, const DeprecatedPaintLayerPaintingInfo& paintingInfo, LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags, ClipState clipState) 589 void DeprecatedPaintLayerPainter::paintFragmentWithPhase(PaintPhase phase, const DeprecatedPaintLayerFragment& fragment, GraphicsContext* context, const ClipRec t& clipRect, const DeprecatedPaintLayerPaintingInfo& paintingInfo, LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags, ClipState clipState)
482 { 590 {
483 ASSERT(m_paintLayer.isSelfPaintingLayer()); 591 ASSERT(m_paintLayer.isSelfPaintingLayer());
484 592
593 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
594 PaintInfo paintInfo(context, enclosingIntRect(paintingInfo.paintDirtyRec t), phase, paintingInfo.globalPaintFlags(), paintFlags, paintingRootForLayoutObj ect, paintingInfo.rootLayer->layoutObject());
595 LayoutPoint paintOffset = toPoint(fragment.layerBounds.location() - m_pa intLayer.layoutBoxLocation());
596 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset);
597 return;
598 }
599
485 Optional<LayerClipRecorder> clipRecorder; 600 Optional<LayerClipRecorder> clipRecorder;
486 if (clipState != HasClipped && paintingInfo.clipToDirtyRect && needsToClip(p aintingInfo, clipRect)) { 601 if (clipState != HasClipped && paintingInfo.clipToDirtyRect && needsToClip(p aintingInfo, clipRect)) {
487 DisplayItem::Type clipType = DisplayItem::paintPhaseToClipLayerFragmentT ype(phase); 602 DisplayItem::Type clipType = DisplayItem::paintPhaseToClipLayerFragmentT ype(phase);
488 LayerClipRecorder::BorderRadiusClippingRule clippingRule; 603 LayerClipRecorder::BorderRadiusClippingRule clippingRule;
489 switch (phase) { 604 switch (phase) {
490 case PaintPhaseBlockBackground: // Background painting will handle clipp ing to self. 605 case PaintPhaseBlockBackground: // Background painting will handle clipp ing to self.
491 case PaintPhaseSelfOutline: 606 case PaintPhaseSelfOutline:
492 case PaintPhaseMask: // Mask painting will handle clipping to self. 607 case PaintPhaseMask: // Mask painting will handle clipping to self.
493 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius; 608 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius;
494 break; 609 break;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 if (!m_paintLayer.containsDirtyOverlayScrollbars()) 725 if (!m_paintLayer.containsDirtyOverlayScrollbars())
611 return; 726 return;
612 727
613 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl osingIntRect(damageRect)), paintFlags, LayoutSize(), paintingRoot); 728 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl osingIntRect(damageRect)), paintFlags, LayoutSize(), paintingRoot);
614 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 729 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
615 730
616 m_paintLayer.setContainsDirtyOverlayScrollbars(false); 731 m_paintLayer.setContainsDirtyOverlayScrollbars(false);
617 } 732 }
618 733
619 } // namespace blink 734 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698