OLD | NEW |
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/paint/PaintPhase.h" | 9 #include "core/paint/PaintPhase.h" |
| 10 #include "platform/geometry/LayoutPoint.h" |
10 #include "platform/geometry/LayoutRect.h" | 11 #include "platform/geometry/LayoutRect.h" |
11 #include "platform/graphics/paint/DisplayItemCacheSkipper.h" | 12 #include "platform/graphics/paint/DisplayItemCacheSkipper.h" |
12 #include "platform/graphics/paint/DrawingRecorder.h" | 13 #include "platform/graphics/paint/DrawingRecorder.h" |
13 #include "wtf/Allocator.h" | 14 #include "wtf/Allocator.h" |
14 #include "wtf/Optional.h" | 15 #include "wtf/Optional.h" |
15 | 16 |
16 namespace blink { | 17 namespace blink { |
17 | 18 |
18 class GraphicsContext; | 19 class GraphicsContext; |
19 | 20 |
20 // Convenience wrapper of DrawingRecorder for LayoutObject painters. | 21 // Convenience wrapper of DrawingRecorder for LayoutObject painters. |
21 class LayoutObjectDrawingRecorder final { | 22 class LayoutObjectDrawingRecorder final { |
22 ALLOW_ONLY_INLINE_ALLOCATION(); | 23 ALLOW_ONLY_INLINE_ALLOCATION(); |
23 public: | 24 public: |
24 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou
tObject& layoutObject, DisplayItem::Type displayItemType) | 25 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou
tObject& layoutObject, DisplayItem::Type displayItemType, const LayoutPoint& pai
ntOffset) |
25 { | 26 { |
| 27 // TODO(pdr): The paint offset cache should be stored on LayoutObject bu
t is temporarily on the DisplayItemList. |
| 28 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && !context.display
ItemList()->paintOffsetIsUnchanged(layoutObject.displayItemClient(), paintOffset
)) |
| 29 return false; |
26 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) | 30 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) |
27 return false; | 31 return false; |
28 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject
, displayItemType); | 32 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject
, displayItemType); |
29 } | 33 } |
30 | 34 |
31 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou
tObject& layoutObject, PaintPhase phase) | 35 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou
tObject& layoutObject, PaintPhase phase, const LayoutPoint& paintOffset) |
32 { | 36 { |
33 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa
intPhaseToDrawingType(phase)); | 37 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa
intPhaseToDrawingType(phase), paintOffset); |
34 } | 38 } |
35 | 39 |
36 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, DisplayItem::Type displayItemType, const FloatRect& clip) | 40 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, DisplayItem::Type displayItemType, const FloatRect& clip, const Layo
utPoint& paintOffset) |
37 { | 41 { |
| 42 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 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 |
38 // We may paint a delayed-invalidation object before it's actually inval
idated. | 52 // We may paint a delayed-invalidation object before it's actually inval
idated. |
39 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) | 53 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) |
40 m_cacheSkipper.emplace(context); | 54 m_cacheSkipper.emplace(context); |
41 m_drawingRecorder.emplace(context, layoutObject, displayItemType, clip); | 55 m_drawingRecorder.emplace(context, layoutObject, displayItemType, clip); |
42 } | 56 } |
43 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, DisplayItem::Type displayItemType, const LayoutRect& clip) | |
44 : LayoutObjectDrawingRecorder(context, layoutObject, displayItemType, Fl
oatRect(clip)) { } | |
45 | 57 |
46 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, PaintPhase phase, const FloatRect& clip) | 58 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, DisplayItem::Type displayItemType, const LayoutRect& clip, const Lay
outPoint& paintOffset) |
47 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP
haseToDrawingType(phase), clip) { } | 59 : LayoutObjectDrawingRecorder(context, layoutObject, displayItemType, Fl
oatRect(clip), paintOffset) { } |
48 | 60 |
49 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, PaintPhase phase, const LayoutRect& clip) | 61 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, PaintPhase phase, const FloatRect& clip, const LayoutPoint& paintOff
set) |
50 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP
haseToDrawingType(phase), FloatRect(clip)) { } | 62 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP
haseToDrawingType(phase), clip, paintOffset) { } |
51 | 63 |
52 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, PaintPhase phase, const IntRect& clip) | 64 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, PaintPhase phase, const LayoutRect& clip, const LayoutPoint& paintOf
fset) |
53 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP
haseToDrawingType(phase), FloatRect(clip)) { } | 65 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP
haseToDrawingType(phase), FloatRect(clip), paintOffset) { } |
| 66 |
| 67 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) { } |
54 | 69 |
55 #if ENABLE(ASSERT) | 70 #if ENABLE(ASSERT) |
56 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC
heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); } | 71 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC
heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); } |
57 #endif | 72 #endif |
58 | 73 |
59 private: | 74 private: |
60 Optional<DisplayItemCacheSkipper> m_cacheSkipper; | 75 Optional<DisplayItemCacheSkipper> m_cacheSkipper; |
61 Optional<DrawingRecorder> m_drawingRecorder; | 76 Optional<DrawingRecorder> m_drawingRecorder; |
62 }; | 77 }; |
63 | 78 |
64 } // namespace blink | 79 } // namespace blink |
65 | 80 |
66 #endif // LayoutObjectDrawingRecorder_h | 81 #endif // LayoutObjectDrawingRecorder_h |
OLD | NEW |