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

Side by Side Diff: third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp

Issue 2793993003: Make GeometryMapper fully static (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "core/paint/PrePaintTreeWalk.h" 5 #include "core/paint/PrePaintTreeWalk.h"
6 6
7 #include "core/dom/DocumentLifecycle.h" 7 #include "core/dom/DocumentLifecycle.h"
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" 10 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h"
11 #include "core/layout/LayoutPart.h" 11 #include "core/layout/LayoutPart.h"
12 #include "core/layout/LayoutView.h" 12 #include "core/layout/LayoutView.h"
13 #include "core/paint/PaintLayer.h" 13 #include "core/paint/PaintLayer.h"
14 #include "platform/graphics/paint/GeometryMapper.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 struct PrePaintTreeWalkContext { 18 struct PrePaintTreeWalkContext {
18 PrePaintTreeWalkContext(GeometryMapper& geometryMapper) 19 PrePaintTreeWalkContext()
19 : treeBuilderContext( 20 : treeBuilderContext(
20 WTF::wrapUnique(new PaintPropertyTreeBuilderContext)), 21 WTF::wrapUnique(new PaintPropertyTreeBuilderContext)),
21 paintInvalidatorContext(*treeBuilderContext, geometryMapper), 22 paintInvalidatorContext(*treeBuilderContext),
22 ancestorOverflowPaintLayer(nullptr), 23 ancestorOverflowPaintLayer(nullptr),
23 ancestorTransformedOrRootPaintLayer(nullptr) {} 24 ancestorTransformedOrRootPaintLayer(nullptr) {}
24 PrePaintTreeWalkContext(const PrePaintTreeWalkContext& parentContext) 25 PrePaintTreeWalkContext(const PrePaintTreeWalkContext& parentContext)
25 : treeBuilderContext(WTF::wrapUnique(new PaintPropertyTreeBuilderContext( 26 : treeBuilderContext(WTF::wrapUnique(new PaintPropertyTreeBuilderContext(
26 *parentContext.treeBuilderContext))), 27 *parentContext.treeBuilderContext))),
27 paintInvalidatorContext(*treeBuilderContext, 28 paintInvalidatorContext(*treeBuilderContext,
28 parentContext.paintInvalidatorContext), 29 parentContext.paintInvalidatorContext),
29 ancestorOverflowPaintLayer(parentContext.ancestorOverflowPaintLayer), 30 ancestorOverflowPaintLayer(parentContext.ancestorOverflowPaintLayer),
30 ancestorTransformedOrRootPaintLayer( 31 ancestorTransformedOrRootPaintLayer(
31 parentContext.ancestorTransformedOrRootPaintLayer) {} 32 parentContext.ancestorTransformedOrRootPaintLayer) {}
32 33
33 // PaintPropertyTreeBuilderContext is large and can lead to stack overflows 34 // PaintPropertyTreeBuilderContext is large and can lead to stack overflows
34 // when recursion is deep so this context object is allocated on the heap. 35 // when recursion is deep so this context object is allocated on the heap.
35 // See: https://crbug.com/698653. 36 // See: https://crbug.com/698653.
36 std::unique_ptr<PaintPropertyTreeBuilderContext> treeBuilderContext; 37 std::unique_ptr<PaintPropertyTreeBuilderContext> treeBuilderContext;
37 38
38 PaintInvalidatorContext paintInvalidatorContext; 39 PaintInvalidatorContext paintInvalidatorContext;
39 40
40 // The ancestor in the PaintLayer tree which has overflow clip, or 41 // The ancestor in the PaintLayer tree which has overflow clip, or
41 // is the root layer. Note that it is tree ancestor, not containing 42 // is the root layer. Note that it is tree ancestor, not containing
42 // block or stacking ancestor. 43 // block or stacking ancestor.
43 PaintLayer* ancestorOverflowPaintLayer; 44 PaintLayer* ancestorOverflowPaintLayer;
44 PaintLayer* ancestorTransformedOrRootPaintLayer; 45 PaintLayer* ancestorTransformedOrRootPaintLayer;
45 }; 46 };
46 47
47 void PrePaintTreeWalk::walk(FrameView& rootFrame) { 48 void PrePaintTreeWalk::walk(FrameView& rootFrame) {
48 DCHECK(rootFrame.frame().document()->lifecycle().state() == 49 DCHECK(rootFrame.frame().document()->lifecycle().state() ==
49 DocumentLifecycle::InPrePaint); 50 DocumentLifecycle::InPrePaint);
50 51
51 PrePaintTreeWalkContext initialContext(m_geometryMapper); 52 PrePaintTreeWalkContext initialContext;
52 initialContext.ancestorTransformedOrRootPaintLayer = 53 initialContext.ancestorTransformedOrRootPaintLayer =
53 rootFrame.layoutView()->layer(); 54 rootFrame.layoutView()->layer();
54 55
55 // GeometryMapper depends on paint properties. 56 // GeometryMapper caches depend on paint properties.
56 if (rootFrame.needsPaintPropertyUpdate() || 57 if (rootFrame.needsPaintPropertyUpdate() ||
57 (rootFrame.layoutView() && 58 (rootFrame.layoutView() &&
58 !shouldEndWalkBefore(*rootFrame.layoutView(), initialContext))) 59 !shouldEndWalkBefore(*rootFrame.layoutView(), initialContext)))
59 m_geometryMapper.clearCache(); 60 GeometryMapper::clearCache();
60 61
61 walk(rootFrame, initialContext); 62 walk(rootFrame, initialContext);
62 m_paintInvalidator.processPendingDelayedPaintInvalidations(); 63 m_paintInvalidator.processPendingDelayedPaintInvalidations();
63 } 64 }
64 65
65 void PrePaintTreeWalk::walk(FrameView& frameView, 66 void PrePaintTreeWalk::walk(FrameView& frameView,
66 const PrePaintTreeWalkContext& parentContext) { 67 const PrePaintTreeWalkContext& parentContext) {
67 if (frameView.shouldThrottleRendering()) { 68 if (frameView.shouldThrottleRendering()) {
68 // Skip the throttled frame. Will update it when it becomes unthrottled. 69 // Skip the throttled frame. Will update it when it becomes unthrottled.
69 return; 70 return;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // Only return a non-infinite clip if clips differ, or the "ancestor" state is 131 // Only return a non-infinite clip if clips differ, or the "ancestor" state is
131 // actually an ancestor clip. This ensures no accuracy issues due to 132 // actually an ancestor clip. This ensures no accuracy issues due to
132 // transforms applied to infinite rects. 133 // transforms applied to infinite rects.
133 if (isAncestorOfOrEqualTo(context.clip, ancestorState.clip())) 134 if (isAncestorOfOrEqualTo(context.clip, ancestorState.clip()))
134 clipRect = FloatClipRect(); 135 clipRect = FloatClipRect();
135 136
136 hasClip = true; 137 hasClip = true;
137 PropertyTreeState localState(context.transform, context.clip, effect); 138 PropertyTreeState localState(context.transform, context.clip, effect);
138 139
139 clipRect = 140 clipRect =
140 m_geometryMapper.sourceToDestinationClipRect(localState, ancestorState); 141 GeometryMapper::sourceToDestinationClipRect(localState, ancestorState);
141 clipRect.moveBy(-FloatPoint(ancestorPaintOffset)); 142 clipRect.moveBy(-FloatPoint(ancestorPaintOffset));
142 } 143 }
143 144
144 void PrePaintTreeWalk::invalidatePaintLayerOptimizationsIfNeeded( 145 void PrePaintTreeWalk::invalidatePaintLayerOptimizationsIfNeeded(
145 const LayoutObject& object, 146 const LayoutObject& object,
146 PrePaintTreeWalkContext& context) { 147 PrePaintTreeWalkContext& context) {
147 if (!object.hasLayer()) 148 if (!object.hasLayer())
148 return; 149 return;
149 150
150 PaintLayer& paintLayer = *toLayoutBoxModelObject(object).layer(); 151 PaintLayer& paintLayer = *toLayoutBoxModelObject(object).layer();
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 roundedIntPoint(context.treeBuilderContext->current.paintOffset); 281 roundedIntPoint(context.treeBuilderContext->current.paintOffset);
281 walk(*toFrameView(frameViewBase), context); 282 walk(*toFrameView(frameViewBase), context);
282 } 283 }
283 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). 284 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281).
284 } 285 }
285 286
286 object.getMutableForPainting().clearPaintFlags(); 287 object.getMutableForPainting().clearPaintFlags();
287 } 288 }
288 289
289 } // namespace blink 290 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698