Chromium Code Reviews| 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/paint/PaintPhase.h" | 10 #include "core/paint/PaintPhase.h" |
| 10 #include "platform/geometry/LayoutPoint.h" | 11 #include "platform/geometry/LayoutPoint.h" |
| 11 #include "platform/geometry/LayoutRect.h" | 12 #include "platform/geometry/LayoutRect.h" |
| 12 #include "platform/graphics/paint/DisplayItemCacheSkipper.h" | 13 #include "platform/graphics/paint/DisplayItemCacheSkipper.h" |
| 13 #include "platform/graphics/paint/DrawingRecorder.h" | 14 #include "platform/graphics/paint/DrawingRecorder.h" |
| 14 #include "wtf/Allocator.h" | 15 #include "wtf/Allocator.h" |
| 15 #include "wtf/Optional.h" | 16 #include "wtf/Optional.h" |
| 16 | 17 |
| 17 namespace blink { | 18 namespace blink { |
| 18 | 19 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 30 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay edFull) | 31 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay edFull) |
| 31 return false; | 32 return false; |
| 32 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject , displayItemType); | 33 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject , displayItemType); |
| 33 } | 34 } |
| 34 | 35 |
| 35 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) |
| 36 { | 37 { |
| 37 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa intPhaseToDrawingType(phase), paintOffset); | 38 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa intPhaseToDrawingType(phase), paintOffset); |
| 38 } | 39 } |
| 39 | 40 |
| 41 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Inlin eBox& inlineBox, DisplayItem::Type displayItemType, const LayoutPoint& paintOffs et) | |
| 42 { | |
| 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)) | |
| 45 return false; | |
| 46 return DrawingRecorder::useCachedDrawingIfPossible(context, inlineBox, d isplayItemType); | |
| 47 } | |
| 48 | |
| 49 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Inlin eBox& inlineBox, PaintPhase phase, const LayoutPoint& paintOffset) | |
| 50 { | |
| 51 return useCachedDrawingIfPossible(context, inlineBox, DisplayItem::paint PhaseToDrawingType(phase), paintOffset); | |
| 52 } | |
| 53 | |
| 40 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) |
| 41 { | 55 { |
| 42 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 56 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 43 // TODO(pdr): The paint offset cache should be stored on LayoutObjec t but is temporarily on the DisplayItemList. | 57 // 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)) { | 58 if (!context.displayItemList()->paintOffsetIsUnchanged(layoutObject. displayItemClient(), paintOffset)) { |
| 45 context.displayItemList()->recordPaintOffset(layoutObject.displa yItemClient(), paintOffset); | 59 context.displayItemList()->recordPaintOffset(layoutObject.displa yItemClient(), paintOffset); |
| 46 context.displayItemList()->invalidatePaintOffset(layoutObject.di splayItemClient()); | 60 context.displayItemList()->invalidatePaintOffset(layoutObject.di splayItemClient()); |
| 47 } else { | 61 } else { |
| 48 ASSERT(!context.displayItemList()->paintOffsetWasInvalidated(lay outObject.displayItemClient()) || !context.displayItemList()->clientCacheIsValid (layoutObject.displayItemClient())); | 62 ASSERT(!context.displayItemList()->paintOffsetWasInvalidated(lay outObject.displayItemClient()) || !context.displayItemList()->clientCacheIsValid (layoutObject.displayItemClient())); |
| 49 } | 63 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 60 | 74 |
| 61 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const FloatRect& clip, const LayoutPoint& paintOff set) | 75 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const FloatRect& clip, const LayoutPoint& paintOff set) |
| 62 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), clip, paintOffset) { } | 76 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), clip, paintOffset) { } |
| 63 | 77 |
| 64 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const LayoutRect& clip, const LayoutPoint& paintOf fset) | 78 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const LayoutRect& clip, const LayoutPoint& paintOf fset) |
| 65 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), FloatRect(clip), paintOffset) { } | 79 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), FloatRect(clip), paintOffset) { } |
| 66 | 80 |
| 67 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const IntRect& clip, const LayoutPoint& paintOffse t) | 81 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) { } | 82 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), FloatRect(clip), paintOffset) { } |
| 69 | 83 |
| 84 LayoutObjectDrawingRecorder(GraphicsContext& context, const InlineBox& inlin eBox, DisplayItem::Type displayItemType, const FloatRect& clip, const LayoutPoin t& paintOffset) | |
|
pdr.
2015/09/14 21:27:42
Can we use "const DisplayItemClientWrapper&" to av
Xianzhu
2015/09/14 21:43:43
There is a difference between the LayoutObject ver
| |
| 85 { | |
| 86 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 87 // TODO(pdr): The paint offset cache should be stored on LayoutObjec t but is temporarily on the DisplayItemList. | |
| 88 if (!context.displayItemList()->paintOffsetIsUnchanged(inlineBox.dis playItemClient(), paintOffset)) { | |
| 89 context.displayItemList()->recordPaintOffset(inlineBox.displayIt emClient(), paintOffset); | |
| 90 context.displayItemList()->invalidatePaintOffset(inlineBox.displ ayItemClient()); | |
| 91 } else { | |
| 92 ASSERT(!context.displayItemList()->paintOffsetWasInvalidated(inl ineBox.displayItemClient()) || !context.displayItemList()->clientCacheIsValid(in lineBox.displayItemClient())); | |
| 93 } | |
| 94 } | |
| 95 | |
| 96 m_drawingRecorder.emplace(context, inlineBox, displayItemType, clip); | |
| 97 } | |
| 98 | |
| 99 LayoutObjectDrawingRecorder(GraphicsContext& context, const InlineBox& inlin eBox, DisplayItem::Type displayItemType, const LayoutRect& clip, const LayoutPoi nt& paintOffset) | |
|
pdr.
2015/09/14 21:27:42
Lets not add these overloaded ctors unless they ar
Xianzhu
2015/09/14 21:43:43
3 of the 4 constructors are used by painters, and
| |
| 100 : LayoutObjectDrawingRecorder(context, inlineBox, displayItemType, Float Rect(clip), paintOffset) { } | |
| 101 | |
| 102 LayoutObjectDrawingRecorder(GraphicsContext& context, const InlineBox& inlin eBox, PaintPhase phase, const LayoutRect& clip, const LayoutPoint& paintOffset) | |
| 103 : LayoutObjectDrawingRecorder(context, inlineBox, DisplayItem::paintPhas eToDrawingType(phase), FloatRect(clip), paintOffset) { } | |
| 104 | |
| 105 LayoutObjectDrawingRecorder(GraphicsContext& context, const InlineBox& inlin eBox, PaintPhase phase, const IntRect& clip, const LayoutPoint& paintOffset) | |
| 106 : LayoutObjectDrawingRecorder(context, inlineBox, DisplayItem::paintPhas eToDrawingType(phase), FloatRect(clip), paintOffset) { } | |
| 107 | |
| 70 #if ENABLE(ASSERT) | 108 #if ENABLE(ASSERT) |
| 71 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); } | 109 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); } |
| 72 #endif | 110 #endif |
| 73 | 111 |
| 74 private: | 112 private: |
| 75 Optional<DisplayItemCacheSkipper> m_cacheSkipper; | 113 Optional<DisplayItemCacheSkipper> m_cacheSkipper; |
| 76 Optional<DrawingRecorder> m_drawingRecorder; | 114 Optional<DrawingRecorder> m_drawingRecorder; |
| 77 }; | 115 }; |
| 78 | 116 |
| 79 } // namespace blink | 117 } // namespace blink |
| 80 | 118 |
| 81 #endif // LayoutObjectDrawingRecorder_h | 119 #endif // LayoutObjectDrawingRecorder_h |
| OLD | NEW |