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

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

Issue 1340133003: Paint offset caching/change-detection for InlineBoxes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Extract PaintInvalidationDelayedFullExtract updatePaintOffsetIfNeeded 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
« no previous file with comments | « Source/core/paint/InlineTextBoxPainter.cpp ('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 #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"
9 #include "core/paint/PaintPhase.h" 10 #include "core/paint/PaintPhase.h"
10 #include "platform/geometry/LayoutPoint.h" 11 #include "platform/geometry/LayoutPoint.h"
11 #include "platform/geometry/LayoutRect.h" 12 #include "platform/geometry/LayoutRect.h"
12 #include "platform/graphics/paint/DisplayItemCacheSkipper.h" 13 #include "platform/graphics/paint/DisplayItemCacheSkipper.h"
13 #include "platform/graphics/paint/DrawingRecorder.h" 14 #include "platform/graphics/paint/DrawingRecorder.h"
14 #include "wtf/Allocator.h" 15 #include "wtf/Allocator.h"
15 #include "wtf/Optional.h" 16 #include "wtf/Optional.h"
16 17
17 namespace blink { 18 namespace blink {
18 19
(...skipping 11 matching lines...) Expand all
30 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay edFull) 31 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay edFull)
31 return false; 32 return false;
32 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject , displayItemType); 33 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject , displayItemType);
33 } 34 }
34 35
35 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou tObject& layoutObject, PaintPhase phase, const LayoutPoint& paintOffset) 36 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou tObject& layoutObject, PaintPhase phase, const LayoutPoint& paintOffset)
36 { 37 {
37 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa intPhaseToDrawingType(phase), paintOffset); 38 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa intPhaseToDrawingType(phase), paintOffset);
38 } 39 }
39 40
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::slimmingPaintV2Enabled() && !context.display ItemList()->paintOffsetIsUnchanged(inlineBox.displayItemClient(), paintOffset))
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
40 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, DisplayItem::Type displayItemType, const FloatRect& clip, const Layo utPoint& paintOffset) 54 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, DisplayItem::Type displayItemType, const FloatRect& clip, const Layo utPoint& paintOffset)
41 { 55 {
42 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 56 updatePaintOffsetIfNeeded(context.displayItemList(), layoutObject.displa yItemClient(), paintOffset);
43 // TODO(pdr): The paint offset cache should be stored on LayoutObjec t but is temporarily on the DisplayItemList.
44 if (!context.displayItemList()->paintOffsetIsUnchanged(layoutObject. displayItemClient(), paintOffset)) {
45 context.displayItemList()->recordPaintOffset(layoutObject.displa yItemClient(), paintOffset);
46 context.displayItemList()->invalidatePaintOffset(layoutObject.di splayItemClient());
47 } else {
48 ASSERT(!context.displayItemList()->paintOffsetWasInvalidated(lay outObject.displayItemClient()) || !context.displayItemList()->clientCacheIsValid (layoutObject.displayItemClient()));
49 }
50 }
51
52 // We may paint a delayed-invalidation object before it's actually inval idated. 57 // We may paint a delayed-invalidation object before it's actually inval idated.
53 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay edFull) 58 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay edFull)
54 m_cacheSkipper.emplace(context); 59 m_cacheSkipper.emplace(context);
55 m_drawingRecorder.emplace(context, layoutObject, displayItemType, clip); 60 m_drawingRecorder.emplace(context, layoutObject, displayItemType, clip);
56 } 61 }
57 62
58 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, DisplayItem::Type displayItemType, const LayoutRect& clip, const Lay outPoint& paintOffset) 63 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, DisplayItem::Type displayItemType, const LayoutRect& clip, const Lay outPoint& paintOffset)
59 : LayoutObjectDrawingRecorder(context, layoutObject, displayItemType, Fl oatRect(clip), paintOffset) { } 64 : LayoutObjectDrawingRecorder(context, layoutObject, displayItemType, Fl oatRect(clip), paintOffset) { }
60 65
61 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const FloatRect& clip, const LayoutPoint& paintOff set) 66 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const FloatRect& clip, const LayoutPoint& paintOff set)
62 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), clip, paintOffset) { } 67 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), clip, paintOffset) { }
63 68
64 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const LayoutRect& clip, const LayoutPoint& paintOf fset) 69 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const LayoutRect& clip, const LayoutPoint& paintOf fset)
65 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), FloatRect(clip), paintOffset) { } 70 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), FloatRect(clip), paintOffset) { }
66 71
67 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const IntRect& clip, const LayoutPoint& paintOffse t) 72 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const IntRect& clip, const LayoutPoint& paintOffse t)
68 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), FloatRect(clip), paintOffset) { } 73 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), FloatRect(clip), paintOffset) { }
69 74
75 LayoutObjectDrawingRecorder(GraphicsContext& context, const InlineBox& inlin eBox, DisplayItem::Type displayItemType, const FloatRect& clip, const LayoutPoin t& paintOffset)
76 {
77 updatePaintOffsetIfNeeded(context.displayItemList(), inlineBox.displayIt emClient(), paintOffset);
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
70 #if ENABLE(ASSERT) 90 #if ENABLE(ASSERT)
71 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); } 91 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); }
72 #endif 92 #endif
73 93
74 private: 94 private:
95 static void updatePaintOffsetIfNeeded(DisplayItemList* displayItemList, Disp layItemClient displayItemClient, const LayoutPoint& paintOffset)
96 {
97 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled())
98 return;
99
100 // TODO(pdr): The paint offset cache should be stored on LayoutObject bu t is temporarily on the DisplayItemList.
101 if (!displayItemList->paintOffsetIsUnchanged(displayItemClient, paintOff set)) {
102 displayItemList->recordPaintOffset(displayItemClient, paintOffset);
103 displayItemList->invalidatePaintOffset(displayItemClient);
104 } else {
105 ASSERT(!displayItemList->paintOffsetWasInvalidated(displayItemClient ) || !displayItemList->clientCacheIsValid(displayItemClient));
106 }
107 }
108
75 Optional<DisplayItemCacheSkipper> m_cacheSkipper; 109 Optional<DisplayItemCacheSkipper> m_cacheSkipper;
76 Optional<DrawingRecorder> m_drawingRecorder; 110 Optional<DrawingRecorder> m_drawingRecorder;
77 }; 111 };
78 112
79 } // namespace blink 113 } // namespace blink
80 114
81 #endif // LayoutObjectDrawingRecorder_h 115 #endif // LayoutObjectDrawingRecorder_h
OLDNEW
« no previous file with comments | « Source/core/paint/InlineTextBoxPainter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698