OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/PaintInvalidator.h" | 5 #include "core/paint/PaintInvalidator.h" |
6 | 6 |
7 #include "core/editing/FrameSelection.h" | 7 #include "core/editing/FrameSelection.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/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
11 #include "core/layout/LayoutObject.h" | 11 #include "core/layout/LayoutObject.h" |
12 #include "core/layout/LayoutTable.h" | 12 #include "core/layout/LayoutTable.h" |
13 #include "core/layout/svg/SVGLayoutSupport.h" | 13 #include "core/layout/svg/SVGLayoutSupport.h" |
14 #include "core/paint/ObjectPaintProperties.h" | |
14 #include "core/paint/PaintLayer.h" | 15 #include "core/paint/PaintLayer.h" |
15 #include "core/paint/PaintLayerScrollableArea.h" | 16 #include "core/paint/PaintLayerScrollableArea.h" |
17 #include "core/paint/PaintPropertyTreeBuilder.h" | |
18 #include "core/paint/PaintPropertyTreePrinter.h" | |
chrishtr
2016/08/12 18:20:53
Remove
Xianzhu
2016/08/12 18:37:51
Done.
(BTW do you know how to make the functions
| |
19 #include "platform/graphics/paint/GeometryMapper.h" | |
16 | 20 |
17 namespace blink { | 21 namespace blink { |
18 | 22 |
19 void PaintInvalidatorContext::mapLocalRectToPaintInvalidationBacking(const Layou tObject& object, LayoutRect& rect) const | 23 static LayoutRect mapLocalRectToPaintInvalidationBacking(const LayoutObject& obj ect, const FloatRect& localRect, const PaintInvalidatorContext& context) |
20 { | 24 { |
21 // TODO(wangxianzhu): For now this is the same as the slow path in PaintInva lidationState.cpp | 25 // TODO(wkorman): The flip below is required because visual rects are |
22 // (slowMapToVisualRectInAncestorSpace()). Should implement this with Geomet ryMapper. | 26 // currently in "physical coordinates with flipped block-flow direction" |
27 // (see LayoutBoxModelObject.h) but we need them to be in physical | |
28 // coordinates. | |
29 FloatRect rect = localRect; | |
23 if (object.isBox()) | 30 if (object.isBox()) |
24 toLayoutBox(object).flipForWritingMode(rect); | 31 toLayoutBox(object).flipForWritingMode(rect); |
25 | 32 |
26 if (object.isLayoutView()) | 33 LayoutRect result; |
27 toLayoutView(object).mapToVisualRectInAncestorSpace(paintInvalidationCon tainer, rect, InputIsInFrameCoordinates, DefaultVisualRectFlags); | 34 if (object == context.paintInvalidationContainer) { |
28 else | 35 result = LayoutRect(rect); |
29 object.mapToVisualRectInAncestorSpace(paintInvalidationContainer, rect); | 36 } else { |
37 rect.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset)); | |
38 | |
39 bool success = false; | |
40 PropertyTreeState currentTreeState(context.treeBuilderContext.current.tr ansform, context.treeBuilderContext.current.clip, context.treeBuilderContext.cur rentEffect); | |
41 const PropertyTreeState& containerTreeState = context.paintInvalidationC ontainer->objectPaintProperties()->localBorderBoxProperties()->propertyTreeState ; | |
42 result = LayoutRect(GeometryMapper().mapToVisualRectInDestinationSpace(r ect, currentTreeState, containerTreeState, success)); | |
chrishtr
2016/08/12 18:20:53
This does use GeometryMapper, but it's not efficie
Xianzhu
2016/08/12 18:37:51
Oh I didn't think this is an intermediate step. Wh
chrishtr
2016/08/12 18:40:28
All of the caching in GeometryMapper is stored as
Xianzhu
2016/08/12 19:16:29
Done.
| |
43 DCHECK(success); | |
44 } | |
45 | |
46 if (context.paintInvalidationContainer->layer()->groupedMapping()) | |
47 PaintLayer::mapRectInPaintInvalidationContainerToBacking(*context.paintI nvalidationContainer, result); | |
48 return result; | |
49 } | |
50 | |
51 void PaintInvalidatorContext::mapLocalRectToPaintInvalidationBacking(const Layou tObject& object, LayoutRect& rect) const | |
52 { | |
53 rect = blink::mapLocalRectToPaintInvalidationBacking(object, FloatRect(rect) , *this); | |
chrishtr
2016/08/12 18:20:53
What's the point of not inlining blink::mapLocalRe
Xianzhu
2016/08/12 18:37:51
Two reasons:
1. This method is for non-SVG path o
chrishtr
2016/08/12 18:40:28
ok
| |
30 } | 54 } |
31 | 55 |
32 static LayoutRect computePaintInvalidationRectInBacking(const LayoutObject& obje ct, const PaintInvalidatorContext& context) | 56 static LayoutRect computePaintInvalidationRectInBacking(const LayoutObject& obje ct, const PaintInvalidatorContext& context) |
33 { | 57 { |
34 if (object.isSVG() && !object.isSVGRoot()) { | 58 FloatRect localRect; |
35 // TODO(wangxianzhu): For now this is the same as the slow path in Paint InvalidationState.cpp | 59 if (object.isSVG() && !object.isSVGRoot()) |
36 // (PaintInvalidationState::computePaintInvalidationRectInBackingForSVG( )). Should implement this with GeometryMapper. | 60 localRect = SVGLayoutSupport::localOverflowRectForPaintInvalidation(obje ct); |
37 LayoutRect rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidat ion(object, *context.paintInvalidationContainer); | 61 else |
38 if (context.paintInvalidationContainer->layer()->groupedMapping()) | 62 localRect = FloatRect(object.localOverflowRectForPaintInvalidation()); |
39 PaintLayer::mapRectInPaintInvalidationContainerToBacking(*context.pa intInvalidationContainer, rect); | |
40 return rect; | |
41 } | |
42 | 63 |
43 LayoutRect rect = object.localOverflowRectForPaintInvalidation(); | 64 return mapLocalRectToPaintInvalidationBacking(object, localRect, context); |
44 context.mapLocalRectToPaintInvalidationBacking(object, rect); | |
45 return rect; | |
46 } | 65 } |
47 | 66 |
48 static LayoutPoint computeLocationFromPaintInvalidationBacking(const LayoutObjec t& object, const PaintInvalidatorContext& context) | 67 static LayoutPoint computeLocationFromPaintInvalidationBacking(const LayoutObjec t& object, const PaintInvalidatorContext& context) |
49 { | 68 { |
50 // TODO(wangxianzhu): For now this is the same as the slow path in PaintInva lidationState.cpp | |
51 // (slowLocalToAncestorPoint()). Should implement this with GeometryMapper. | |
52 FloatPoint point; | 69 FloatPoint point; |
53 if (object != context.paintInvalidationContainer) { | 70 if (object != context.paintInvalidationContainer) { |
54 if (object.isLayoutView()) { | 71 point.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset)) ; |
55 point = toLayoutView(object).localToAncestorPoint(point, context.pai ntInvalidationContainer, TraverseDocumentBoundaries | InputIsInFrameCoordinates) ; | 72 |
56 } else { | 73 bool success = false; |
57 point = object.localToAncestorPoint(point, context.paintInvalidation Container, TraverseDocumentBoundaries); | 74 PropertyTreeState currentTreeState(context.treeBuilderContext.current.tr ansform, context.treeBuilderContext.current.clip, context.treeBuilderContext.cur rentEffect); |
58 // Paint invalidation does not include scroll of paintInvalidationCo ntainer. | 75 const PropertyTreeState& containerTreeState = context.paintInvalidationC ontainer->objectPaintProperties()->localBorderBoxProperties()->propertyTreeState ; |
59 if (context.paintInvalidationContainer->isBox()) { | 76 point = GeometryMapper().mapRectToDestinationSpace(FloatRect(point, Floa tSize()), currentTreeState, containerTreeState, success).location(); |
60 const LayoutBox* box = toLayoutBox(context.paintInvalidationCont ainer); | 77 DCHECK(success); |
61 if (box->hasOverflowClip()) | |
62 point.move(box->scrolledContentOffset()); | |
63 } | |
64 } | |
65 } | 78 } |
66 | 79 |
67 | |
68 if (context.paintInvalidationContainer->layer()->groupedMapping()) | 80 if (context.paintInvalidationContainer->layer()->groupedMapping()) |
69 PaintLayer::mapPointInPaintInvalidationContainerToBacking(*context.paint InvalidationContainer, point); | 81 PaintLayer::mapPointInPaintInvalidationContainerToBacking(*context.paint InvalidationContainer, point); |
70 | 82 |
71 return LayoutPoint(point); | 83 return LayoutPoint(point); |
72 } | 84 } |
73 | 85 |
74 static void updatePaintingLayer(const LayoutObject& object, PaintInvalidatorCont ext& context) | 86 static void updatePaintingLayer(const LayoutObject& object, PaintInvalidatorCont ext& context) |
75 { | 87 { |
76 if (object.hasLayer() && toLayoutBoxModelObject(object).hasSelfPaintingLayer ()) | 88 if (object.hasLayer() && toLayoutBoxModelObject(object).hasSelfPaintingLayer ()) |
77 context.paintingLayer = toLayoutBoxModelObject(object).layer(); | 89 context.paintingLayer = toLayoutBoxModelObject(object).layer(); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 object.getMutableForPainting().clearPaintInvalidationFlags(); | 227 object.getMutableForPainting().clearPaintInvalidationFlags(); |
216 } | 228 } |
217 | 229 |
218 void PaintInvalidator::processPendingDelayedPaintInvalidations() | 230 void PaintInvalidator::processPendingDelayedPaintInvalidations() |
219 { | 231 { |
220 for (auto target : m_pendingDelayedPaintInvalidations) | 232 for (auto target : m_pendingDelayedPaintInvalidations) |
221 target->getMutableForPainting().setShouldDoFullPaintInvalidation(PaintIn validationDelayedFull); | 233 target->getMutableForPainting().setShouldDoFullPaintInvalidation(PaintIn validationDelayedFull); |
222 } | 234 } |
223 | 235 |
224 } // namespace blink | 236 } // namespace blink |
OLD | NEW |