| 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/LayoutPoint.h" |
| 11 #include "platform/geometry/LayoutRect.h" | 11 #include "platform/geometry/LayoutRect.h" |
| 12 #include "platform/graphics/paint/DisplayItemCacheSkipper.h" | 12 #include "platform/graphics/paint/DisplayItemCacheSkipper.h" |
| 13 #include "platform/graphics/paint/DrawingRecorder.h" | 13 #include "platform/graphics/paint/DrawingRecorder.h" |
| 14 #include "wtf/Allocator.h" | 14 #include "wtf/Allocator.h" |
| 15 #include "wtf/Optional.h" | 15 #include "wtf/Optional.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 class GraphicsContext; | 19 class GraphicsContext; |
| 20 | 20 |
| 21 // Convenience wrapper of DrawingRecorder for LayoutObject painters. | 21 // Convenience wrapper of DrawingRecorder for LayoutObject painters. |
| 22 class LayoutObjectDrawingRecorder final { | 22 class LayoutObjectDrawingRecorder final { |
| 23 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 23 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 24 public: | 24 public: |
| 25 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) |
| 26 { | 26 { |
| 27 if (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && layou
tObject.paintOffsetChanged(paintOffset)) | |
| 28 return false; | |
| 29 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) | 27 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) |
| 30 return false; | 28 return false; |
| 31 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject
, displayItemType); | 29 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject
, displayItemType); |
| 32 } | 30 } |
| 33 | 31 |
| 34 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou
tObject& layoutObject, PaintPhase phase, const LayoutPoint& paintOffset) | 32 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou
tObject& layoutObject, PaintPhase phase) |
| 35 { | 33 { |
| 36 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa
intPhaseToDrawingType(phase), paintOffset); | 34 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa
intPhaseToDrawingType(phase)); |
| 37 } | 35 } |
| 38 | 36 |
| 39 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, DisplayItem::Type displayItemType, const FloatRect& clip, const Layo
utPoint& paintOffset) | 37 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, DisplayItem::Type displayItemType, const FloatRect& clip) |
| 40 { | 38 { |
| 41 updatePaintOffsetIfNeeded(context.paintController(), layoutObject, paint
Offset); | |
| 42 // We may paint a delayed-invalidation object before it's actually inval
idated. | 39 // We may paint a delayed-invalidation object before it's actually inval
idated. |
| 43 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) | 40 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) |
| 44 m_cacheSkipper.emplace(context); | 41 m_cacheSkipper.emplace(context); |
| 45 m_drawingRecorder.emplace(context, layoutObject, displayItemType, clip); | 42 m_drawingRecorder.emplace(context, layoutObject, displayItemType, clip); |
| 46 } | 43 } |
| 47 | 44 |
| 48 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, DisplayItem::Type displayItemType, const LayoutRect& clip, const Lay
outPoint& paintOffset) | 45 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, DisplayItem::Type displayItemType, const LayoutRect& clip) |
| 49 : LayoutObjectDrawingRecorder(context, layoutObject, displayItemType, Fl
oatRect(clip), paintOffset) { } | 46 : LayoutObjectDrawingRecorder(context, layoutObject, displayItemType, Fl
oatRect(clip)) { } |
| 50 | 47 |
| 51 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, PaintPhase phase, const FloatRect& clip, const LayoutPoint& paintOff
set) | 48 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, PaintPhase phase, const FloatRect& clip) |
| 52 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP
haseToDrawingType(phase), clip, paintOffset) { } | 49 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP
haseToDrawingType(phase), clip) { } |
| 53 | 50 |
| 54 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, PaintPhase phase, const LayoutRect& clip, const LayoutPoint& paintOf
fset) | 51 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, PaintPhase phase, const LayoutRect& clip) |
| 55 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP
haseToDrawingType(phase), FloatRect(clip), paintOffset) { } | 52 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP
haseToDrawingType(phase), FloatRect(clip)) { } |
| 56 | 53 |
| 57 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, PaintPhase phase, const IntRect& clip, const LayoutPoint& paintOffse
t) | 54 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, PaintPhase phase, const IntRect& clip) |
| 58 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP
haseToDrawingType(phase), FloatRect(clip), paintOffset) { } | 55 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP
haseToDrawingType(phase), FloatRect(clip)) { } |
| 59 | 56 |
| 60 void setKnownToBeOpaque() { ASSERT(RuntimeEnabledFeatures::slimmingPaintV2En
abled()); m_drawingRecorder->setKnownToBeOpaque(); } | 57 void setKnownToBeOpaque() { ASSERT(RuntimeEnabledFeatures::slimmingPaintV2En
abled()); m_drawingRecorder->setKnownToBeOpaque(); } |
| 61 | 58 |
| 62 #if ENABLE(ASSERT) | 59 #if ENABLE(ASSERT) |
| 63 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC
heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); } | 60 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC
heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); } |
| 64 #endif | 61 #endif |
| 65 | 62 |
| 66 private: | 63 private: |
| 67 static void updatePaintOffsetIfNeeded(PaintController& paintController, cons
t LayoutObject& layoutObject, const LayoutPoint& paintOffset) | |
| 68 { | |
| 69 if (!RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() || pain
tController.skippingCache()) | |
| 70 return; | |
| 71 | |
| 72 if (layoutObject.paintOffsetChanged(paintOffset)) | |
| 73 paintController.invalidatePaintOffset(layoutObject); | |
| 74 else | |
| 75 ASSERT(!paintController.paintOffsetWasInvalidated(layoutObject) || !
paintController.clientCacheIsValid(layoutObject)); | |
| 76 | |
| 77 layoutObject.mutableForPainting().setPreviousPaintOffset(paintOffset); | |
| 78 } | |
| 79 | |
| 80 Optional<DisplayItemCacheSkipper> m_cacheSkipper; | 64 Optional<DisplayItemCacheSkipper> m_cacheSkipper; |
| 81 Optional<DrawingRecorder> m_drawingRecorder; | 65 Optional<DrawingRecorder> m_drawingRecorder; |
| 82 }; | 66 }; |
| 83 | 67 |
| 84 } // namespace blink | 68 } // namespace blink |
| 85 | 69 |
| 86 #endif // LayoutObjectDrawingRecorder_h | 70 #endif // LayoutObjectDrawingRecorder_h |
| OLD | NEW |