| 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/LayoutRect.h" | 10 #include "platform/geometry/LayoutRect.h" |
| 11 #include "platform/graphics/paint/DisplayItemCacheSkipper.h" |
| 11 #include "platform/graphics/paint/DrawingRecorder.h" | 12 #include "platform/graphics/paint/DrawingRecorder.h" |
| 13 #include "wtf/Optional.h" |
| 12 | 14 |
| 13 namespace blink { | 15 namespace blink { |
| 14 | 16 |
| 15 class GraphicsContext; | 17 class GraphicsContext; |
| 16 | 18 |
| 17 // Convenience constructors for creating DrawingRecorders. | 19 // Convenience wrapper of DrawingRecorder for LayoutObject painters. |
| 18 class LayoutObjectDrawingRecorder final : public DrawingRecorder { | 20 class LayoutObjectDrawingRecorder final { |
| 19 public: | 21 public: |
| 20 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, DisplayItem::Type displayItemType, const LayoutRect& clip) | 22 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, DisplayItem::Type displayItemType, const FloatRect& clip) |
| 21 : DrawingRecorder(context, layoutObject, displayItemType, pixelSnappedIn
tRect(clip)) | |
| 22 { | 23 { |
| 23 #if ENABLE(ASSERT) | 24 // We may paint a delayed-invalidation object before it's actually inval
idated. |
| 24 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) | 25 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) |
| 25 setUnderInvalidationCheckingMode(DrawingDisplayItem::DontCheck); | 26 m_cacheSkipper.emplace(context); |
| 26 #endif | 27 m_drawingRecorder.emplace(context, layoutObject, displayItemType, clip); |
| 27 } | 28 } |
| 28 | 29 |
| 29 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, PaintPhase phase, const FloatRect& clip) | 30 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, PaintPhase phase, const FloatRect& clip) |
| 30 : DrawingRecorder(context, layoutObject, DisplayItem::paintPhaseToDrawin
gType(phase), clip) { } | 31 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP
haseToDrawingType(phase), clip) { } |
| 31 | 32 |
| 32 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, DisplayItem::Type type, const FloatRect& clip) | 33 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, DisplayItem::Type type, const LayoutRect& clip) |
| 33 : DrawingRecorder(context, layoutObject, type, clip) { } | 34 : LayoutObjectDrawingRecorder(context, layoutObject, type, pixelSnappedI
ntRect(clip)) { } |
| 35 |
| 36 bool canUseCachedDrawing() const { return m_drawingRecorder->canUseCachedDra
wing(); } |
| 37 |
| 38 #if ENABLE(ASSERT) |
| 39 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC
heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); } |
| 40 #endif |
| 41 |
| 42 private: |
| 43 Optional<DisplayItemCacheSkipper> m_cacheSkipper; |
| 44 Optional<DrawingRecorder> m_drawingRecorder; |
| 34 }; | 45 }; |
| 35 | 46 |
| 36 } // namespace blink | 47 } // namespace blink |
| 37 | 48 |
| 38 #endif // LayoutObjectDrawingRecorder_h | 49 #endif // LayoutObjectDrawingRecorder_h |
| OLD | NEW |