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 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && paintOffset != l
ayoutObject.cachedPaintOffset()) |
| 26 return false; |
24 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) | 27 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) |
25 return false; | 28 return false; |
26 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject
, displayItemType); | 29 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject
, displayItemType); |
27 } | 30 } |
28 | 31 |
29 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou
tObject& layoutObject, PaintPhase phase) | 32 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou
tObject& layoutObject, PaintPhase phase, const LayoutPoint& paintOffset) |
30 { | 33 { |
31 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa
intPhaseToDrawingType(phase)); | 34 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa
intPhaseToDrawingType(phase), paintOffset); |
32 } | 35 } |
33 | 36 |
34 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, DisplayItem::Type displayItemType, const FloatRect& clip) | 37 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, DisplayItem::Type displayItemType, const FloatRect& clip, const Layo
utPoint& paintOffset) |
35 { | 38 { |
| 39 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 40 if (paintOffset != layoutObject.cachedPaintOffset()) { |
| 41 ASSERT(!context.displayItemList()->paintOffsetWasInvalidated(lay
outObject.displayItemClient())); |
| 42 layoutObject.updateCachedPaintOffset(paintOffset); |
| 43 context.displayItemList()->invalidatePaintOffset(layoutObject.di
splayItemClient()); |
| 44 } else { |
| 45 ASSERT(!context.displayItemList()->paintOffsetWasInvalidated(lay
outObject.displayItemClient()) || !context.displayItemList()->clientCacheIsValid
(layoutObject.displayItemClient())); |
| 46 } |
| 47 } |
| 48 |
36 // We may paint a delayed-invalidation object before it's actually inval
idated. | 49 // We may paint a delayed-invalidation object before it's actually inval
idated. |
37 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) | 50 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) |
38 m_cacheSkipper.emplace(context); | 51 m_cacheSkipper.emplace(context); |
39 m_drawingRecorder.emplace(context, layoutObject, displayItemType, clip); | 52 m_drawingRecorder.emplace(context, layoutObject, displayItemType, clip); |
40 } | 53 } |
41 | 54 |
42 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, PaintPhase phase, const FloatRect& clip) | 55 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, PaintPhase phase, const FloatRect& clip, const LayoutPoint& paintOff
set) |
43 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP
haseToDrawingType(phase), clip) { } | 56 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP
haseToDrawingType(phase), clip, paintOffset) { } |
44 | 57 |
45 #if ENABLE(ASSERT) | 58 #if ENABLE(ASSERT) |
46 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC
heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); } | 59 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC
heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); } |
47 #endif | 60 #endif |
48 | 61 |
49 private: | 62 private: |
50 Optional<DisplayItemCacheSkipper> m_cacheSkipper; | 63 Optional<DisplayItemCacheSkipper> m_cacheSkipper; |
51 Optional<DrawingRecorder> m_drawingRecorder; | 64 Optional<DrawingRecorder> m_drawingRecorder; |
52 }; | 65 }; |
53 | 66 |
54 } // namespace blink | 67 } // namespace blink |
55 | 68 |
56 #endif // LayoutObjectDrawingRecorder_h | 69 #endif // LayoutObjectDrawingRecorder_h |
OLD | NEW |