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

Side by Side Diff: Source/core/paint/LayoutObjectDrawingRecorder.h

Issue 1363613002: Save previous paint offset in LayoutObject (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 #ifndef LayoutObjectDrawingRecorder_h 5 #ifndef LayoutObjectDrawingRecorder_h
6 #define LayoutObjectDrawingRecorder_h 6 #define LayoutObjectDrawingRecorder_h
7 7
8 #include "core/layout/LayoutObject.h" 8 #include "core/layout/LayoutObject.h"
9 #include "core/layout/line/InlineBox.h"
10 #include "core/paint/PaintPhase.h" 9 #include "core/paint/PaintPhase.h"
11 #include "platform/geometry/LayoutPoint.h" 10 #include "platform/geometry/LayoutPoint.h"
12 #include "platform/geometry/LayoutRect.h" 11 #include "platform/geometry/LayoutRect.h"
13 #include "platform/graphics/paint/DisplayItemCacheSkipper.h" 12 #include "platform/graphics/paint/DisplayItemCacheSkipper.h"
14 #include "platform/graphics/paint/DrawingRecorder.h" 13 #include "platform/graphics/paint/DrawingRecorder.h"
15 #include "wtf/Allocator.h" 14 #include "wtf/Allocator.h"
16 #include "wtf/Optional.h" 15 #include "wtf/Optional.h"
17 16
18 namespace blink { 17 namespace blink {
19 18
20 class GraphicsContext; 19 class GraphicsContext;
21 20
22 // Convenience wrapper of DrawingRecorder for LayoutObject painters. 21 // Convenience wrapper of DrawingRecorder for LayoutObject painters.
23 class LayoutObjectDrawingRecorder final { 22 class LayoutObjectDrawingRecorder final {
24 ALLOW_ONLY_INLINE_ALLOCATION(); 23 ALLOW_ONLY_INLINE_ALLOCATION();
25 public: 24 public:
26 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou tObject& layoutObject, DisplayItem::Type displayItemType, const LayoutPoint& pai ntOffset) 25 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou tObject& layoutObject, DisplayItem::Type displayItemType, const LayoutPoint& pai ntOffset)
27 { 26 {
28 // TODO(pdr): The paint offset cache should be stored on LayoutObject bu t is temporarily on the DisplayItemList. 27 if (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && !layo utObject.paintOffsetChanged(paintOffset))
29 if (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && !cont ext.displayItemList()->paintOffsetIsUnchanged(layoutObject.displayItemClient(), paintOffset))
30 return false; 28 return false;
31 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay edFull) 29 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay edFull)
32 return false; 30 return false;
33 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject , displayItemType); 31 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject , displayItemType);
34 } 32 }
35 33
36 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou tObject& layoutObject, PaintPhase phase, const LayoutPoint& paintOffset) 34 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou tObject& layoutObject, PaintPhase phase, const LayoutPoint& paintOffset)
37 { 35 {
38 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa intPhaseToDrawingType(phase), paintOffset); 36 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa intPhaseToDrawingType(phase), paintOffset);
39 } 37 }
40 38
41 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Inlin eBox& inlineBox, DisplayItem::Type displayItemType, const LayoutPoint& paintOffs et)
42 {
43 // TODO(pdr): The paint offset cache should be stored on LayoutObject bu t is temporarily on the DisplayItemList.
44 if (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && !cont ext.displayItemList()->paintOffsetIsUnchanged(inlineBox.displayItemClient(), pai ntOffset))
45 return false;
46 return DrawingRecorder::useCachedDrawingIfPossible(context, inlineBox, d isplayItemType);
47 }
48
49 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Inlin eBox& inlineBox, PaintPhase phase, const LayoutPoint& paintOffset)
50 {
51 return useCachedDrawingIfPossible(context, inlineBox, DisplayItem::paint PhaseToDrawingType(phase), paintOffset);
52 }
53
54 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, DisplayItem::Type displayItemType, const FloatRect& clip, const Layo utPoint& paintOffset) 39 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, DisplayItem::Type displayItemType, const FloatRect& clip, const Layo utPoint& paintOffset)
55 { 40 {
56 updatePaintOffsetIfNeeded(context.displayItemList(), layoutObject, paint Offset); 41 updatePaintOffsetIfNeeded(context.displayItemList(), layoutObject, paint Offset);
57 // We may paint a delayed-invalidation object before it's actually inval idated. 42 // We may paint a delayed-invalidation object before it's actually inval idated.
58 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay edFull) 43 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay edFull)
59 m_cacheSkipper.emplace(context); 44 m_cacheSkipper.emplace(context);
60 m_drawingRecorder.emplace(context, layoutObject, displayItemType, clip); 45 m_drawingRecorder.emplace(context, layoutObject, displayItemType, clip);
61 } 46 }
62 47
63 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, DisplayItem::Type displayItemType, const LayoutRect& clip, const Lay outPoint& paintOffset) 48 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, DisplayItem::Type displayItemType, const LayoutRect& clip, const Lay outPoint& paintOffset)
64 : LayoutObjectDrawingRecorder(context, layoutObject, displayItemType, Fl oatRect(clip), paintOffset) { } 49 : LayoutObjectDrawingRecorder(context, layoutObject, displayItemType, Fl oatRect(clip), paintOffset) { }
65 50
66 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const FloatRect& clip, const LayoutPoint& paintOff set) 51 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const FloatRect& clip, const LayoutPoint& paintOff set)
67 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), clip, paintOffset) { } 52 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), clip, paintOffset) { }
68 53
69 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const LayoutRect& clip, const LayoutPoint& paintOf fset) 54 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const LayoutRect& clip, const LayoutPoint& paintOf fset)
70 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), FloatRect(clip), paintOffset) { } 55 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), FloatRect(clip), paintOffset) { }
71 56
72 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const IntRect& clip, const LayoutPoint& paintOffse t) 57 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const IntRect& clip, const LayoutPoint& paintOffse t)
73 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), FloatRect(clip), paintOffset) { } 58 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), FloatRect(clip), paintOffset) { }
74 59
75 LayoutObjectDrawingRecorder(GraphicsContext& context, const InlineBox& inlin eBox, DisplayItem::Type displayItemType, const FloatRect& clip, const LayoutPoin t& paintOffset)
76 {
77 updatePaintOffsetIfNeeded(context.displayItemList(), inlineBox, paintOff set);
78 m_drawingRecorder.emplace(context, inlineBox, displayItemType, clip);
79 }
80
81 LayoutObjectDrawingRecorder(GraphicsContext& context, const InlineBox& inlin eBox, DisplayItem::Type displayItemType, const LayoutRect& clip, const LayoutPoi nt& paintOffset)
82 : LayoutObjectDrawingRecorder(context, inlineBox, displayItemType, Float Rect(clip), paintOffset) { }
83
84 LayoutObjectDrawingRecorder(GraphicsContext& context, const InlineBox& inlin eBox, PaintPhase phase, const LayoutRect& clip, const LayoutPoint& paintOffset)
85 : LayoutObjectDrawingRecorder(context, inlineBox, DisplayItem::paintPhas eToDrawingType(phase), FloatRect(clip), paintOffset) { }
86
87 LayoutObjectDrawingRecorder(GraphicsContext& context, const InlineBox& inlin eBox, PaintPhase phase, const IntRect& clip, const LayoutPoint& paintOffset)
88 : LayoutObjectDrawingRecorder(context, inlineBox, DisplayItem::paintPhas eToDrawingType(phase), FloatRect(clip), paintOffset) { }
89
90 #if ENABLE(ASSERT) 60 #if ENABLE(ASSERT)
91 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); } 61 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); }
92 #endif 62 #endif
93 63
94 private: 64 private:
95 static void updatePaintOffsetIfNeeded(DisplayItemList* displayItemList, cons t DisplayItemClientWrapper& client, const LayoutPoint& paintOffset) 65 static void updatePaintOffsetIfNeeded(DisplayItemList* displayItemList, cons t LayoutObject& layoutObject, const LayoutPoint& paintOffset)
pdr. 2015/09/23 19:55:47 WDYT about changing this LayoutObject to be non-co
Xianzhu 2015/09/23 21:39:44 I think making LayoutObject const for painters can
96 { 66 {
97 if (!RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled()) 67 if (!RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled())
98 return; 68 return;
99 69
100 // TODO(pdr): The paint offset cache should be stored on LayoutObject bu t is temporarily on the DisplayItemList. 70 if (layoutObject.paintOffsetChanged(paintOffset))
101 if (!displayItemList->paintOffsetIsUnchanged(client.displayItemClient(), paintOffset)) { 71 displayItemList->invalidatePaintOffset(layoutObject);
102 displayItemList->recordPaintOffset(client.displayItemClient(), paint Offset); 72 else
103 displayItemList->invalidatePaintOffset(client); 73 ASSERT(!displayItemList->paintOffsetWasInvalidated(layoutObject.disp layItemClient()) || !displayItemList->clientCacheIsValid(layoutObject.displayIte mClient()));
104 } else { 74
105 ASSERT(!displayItemList->paintOffsetWasInvalidated(client.displayIte mClient()) || !displayItemList->clientCacheIsValid(client.displayItemClient())); 75 layoutObject.setPreviousPaintOffset(paintOffset);
106 }
107 } 76 }
108 77
109 Optional<DisplayItemCacheSkipper> m_cacheSkipper; 78 Optional<DisplayItemCacheSkipper> m_cacheSkipper;
110 Optional<DrawingRecorder> m_drawingRecorder; 79 Optional<DrawingRecorder> m_drawingRecorder;
111 }; 80 };
112 81
113 } // namespace blink 82 } // namespace blink
114 83
115 #endif // LayoutObjectDrawingRecorder_h 84 #endif // LayoutObjectDrawingRecorder_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698