| 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/layout/line/InlineBox.h" | 9 #include "core/layout/line/InlineBox.h" |
| 10 #include "core/paint/PaintPhase.h" | 10 #include "core/paint/PaintPhase.h" |
| 11 #include "platform/geometry/LayoutPoint.h" | 11 #include "platform/geometry/LayoutPoint.h" |
| 12 #include "platform/geometry/LayoutRect.h" | 12 #include "platform/geometry/LayoutRect.h" |
| 13 #include "platform/graphics/paint/DisplayItemCacheSkipper.h" | 13 #include "platform/graphics/paint/DisplayItemCacheSkipper.h" |
| 14 #include "platform/graphics/paint/DrawingRecorder.h" | 14 #include "platform/graphics/paint/DrawingRecorder.h" |
| 15 #include "wtf/Allocator.h" | 15 #include "wtf/Allocator.h" |
| 16 #include "wtf/Optional.h" | 16 #include "wtf/Optional.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 class GraphicsContext; | 20 class GraphicsContext; |
| 21 | 21 |
| 22 // Convenience wrapper of DrawingRecorder for LayoutObject painters. | 22 // Convenience wrapper of DrawingRecorder for LayoutObject painters. |
| 23 class LayoutObjectDrawingRecorder final { | 23 class LayoutObjectDrawingRecorder final { |
| 24 ALLOW_ONLY_INLINE_ALLOCATION(); | 24 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 25 public: | 25 public: |
| 26 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou
tObject& layoutObject, DisplayItem::Type displayItemType, const LayoutPoint& pai
ntOffset) | 26 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou
tObject& layoutObject, DisplayItem::Type displayItemType, const LayoutPoint& pai
ntOffset) |
| 27 { | 27 { |
| 28 // TODO(pdr): The paint offset cache should be stored on LayoutObject bu
t is temporarily on the DisplayItemList. | 28 // TODO(pdr): The paint offset cache should be stored on LayoutObject bu
t is temporarily on the DisplayItemList. |
| 29 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && !context.display
ItemList()->paintOffsetIsUnchanged(layoutObject.displayItemClient(), paintOffset
)) | 29 if (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && !cont
ext.displayItemList()->paintOffsetIsUnchanged(layoutObject.displayItemClient(),
paintOffset)) |
| 30 return false; | 30 return false; |
| 31 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) | 31 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) |
| 32 return false; | 32 return false; |
| 33 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject
, displayItemType); | 33 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject
, displayItemType); |
| 34 } | 34 } |
| 35 | 35 |
| 36 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) |
| 37 { | 37 { |
| 38 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa
intPhaseToDrawingType(phase), paintOffset); | 38 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa
intPhaseToDrawingType(phase), paintOffset); |
| 39 } | 39 } |
| 40 | 40 |
| 41 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Inlin
eBox& inlineBox, DisplayItem::Type displayItemType, const LayoutPoint& paintOffs
et) | 41 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Inlin
eBox& inlineBox, DisplayItem::Type displayItemType, const LayoutPoint& paintOffs
et) |
| 42 { | 42 { |
| 43 // TODO(pdr): The paint offset cache should be stored on LayoutObject bu
t is temporarily on the DisplayItemList. | 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)) | 44 if (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && !cont
ext.displayItemList()->paintOffsetIsUnchanged(inlineBox.displayItemClient(), pai
ntOffset)) |
| 45 return false; | 45 return false; |
| 46 return DrawingRecorder::useCachedDrawingIfPossible(context, inlineBox, d
isplayItemType); | 46 return DrawingRecorder::useCachedDrawingIfPossible(context, inlineBox, d
isplayItemType); |
| 47 } | 47 } |
| 48 | 48 |
| 49 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Inlin
eBox& inlineBox, PaintPhase phase, const LayoutPoint& paintOffset) | 49 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Inlin
eBox& inlineBox, PaintPhase phase, const LayoutPoint& paintOffset) |
| 50 { | 50 { |
| 51 return useCachedDrawingIfPossible(context, inlineBox, DisplayItem::paint
PhaseToDrawingType(phase), paintOffset); | 51 return useCachedDrawingIfPossible(context, inlineBox, DisplayItem::paint
PhaseToDrawingType(phase), paintOffset); |
| 52 } | 52 } |
| 53 | 53 |
| 54 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) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 LayoutObjectDrawingRecorder(GraphicsContext& context, const InlineBox& inlin
eBox, PaintPhase phase, const IntRect& clip, const LayoutPoint& paintOffset) | 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) { } | 88 : LayoutObjectDrawingRecorder(context, inlineBox, DisplayItem::paintPhas
eToDrawingType(phase), FloatRect(clip), paintOffset) { } |
| 89 | 89 |
| 90 #if ENABLE(ASSERT) | 90 #if ENABLE(ASSERT) |
| 91 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC
heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); } | 91 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC
heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); } |
| 92 #endif | 92 #endif |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 static void updatePaintOffsetIfNeeded(DisplayItemList* displayItemList, cons
t DisplayItemClientWrapper& client, const LayoutPoint& paintOffset) | 95 static void updatePaintOffsetIfNeeded(DisplayItemList* displayItemList, cons
t DisplayItemClientWrapper& client, const LayoutPoint& paintOffset) |
| 96 { | 96 { |
| 97 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 97 if (!RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled()) |
| 98 return; | 98 return; |
| 99 | 99 |
| 100 // TODO(pdr): The paint offset cache should be stored on LayoutObject bu
t is temporarily on the DisplayItemList. | 100 // TODO(pdr): The paint offset cache should be stored on LayoutObject bu
t is temporarily on the DisplayItemList. |
| 101 if (!displayItemList->paintOffsetIsUnchanged(client.displayItemClient(),
paintOffset)) { | 101 if (!displayItemList->paintOffsetIsUnchanged(client.displayItemClient(),
paintOffset)) { |
| 102 displayItemList->recordPaintOffset(client.displayItemClient(), paint
Offset); | 102 displayItemList->recordPaintOffset(client.displayItemClient(), paint
Offset); |
| 103 displayItemList->invalidatePaintOffset(client); | 103 displayItemList->invalidatePaintOffset(client); |
| 104 } else { | 104 } else { |
| 105 ASSERT(!displayItemList->paintOffsetWasInvalidated(client.displayIte
mClient()) || !displayItemList->clientCacheIsValid(client.displayItemClient())); | 105 ASSERT(!displayItemList->paintOffsetWasInvalidated(client.displayIte
mClient()) || !displayItemList->clientCacheIsValid(client.displayItemClient())); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 Optional<DisplayItemCacheSkipper> m_cacheSkipper; | 109 Optional<DisplayItemCacheSkipper> m_cacheSkipper; |
| 110 Optional<DrawingRecorder> m_drawingRecorder; | 110 Optional<DrawingRecorder> m_drawingRecorder; |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 } // namespace blink | 113 } // namespace blink |
| 114 | 114 |
| 115 #endif // LayoutObjectDrawingRecorder_h | 115 #endif // LayoutObjectDrawingRecorder_h |
| OLD | NEW |