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