| 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 "platform/wtf/Allocator.h" | 14 #include "platform/wtf/Allocator.h" |
| 15 #include "platform/wtf/Optional.h" | 15 #include "platform/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 | 24 |
| 25 public: | 25 public: |
| 26 static bool UseCachedDrawingIfPossible(GraphicsContext& context, | 26 static bool UseCachedDrawingIfPossible(GraphicsContext& context, |
| 27 const LayoutObject& layout_object, | 27 const LayoutObject& layout_object, |
| 28 DisplayItem::Type display_item_type) { | 28 DisplayItem::Type display_item_type) { |
| 29 if (layout_object.FullPaintInvalidationReason() == | 29 if (layout_object.FullPaintInvalidationReason() == |
| 30 kPaintInvalidationDelayedFull) | 30 PaintInvalidationReason::kDelayedFull) |
| 31 return false; | 31 return false; |
| 32 return DrawingRecorder::UseCachedDrawingIfPossible(context, layout_object, | 32 return DrawingRecorder::UseCachedDrawingIfPossible(context, layout_object, |
| 33 display_item_type); | 33 display_item_type); |
| 34 } | 34 } |
| 35 | 35 |
| 36 static bool UseCachedDrawingIfPossible(GraphicsContext& context, | 36 static bool UseCachedDrawingIfPossible(GraphicsContext& context, |
| 37 const LayoutObject& layout_object, | 37 const LayoutObject& layout_object, |
| 38 PaintPhase phase) { | 38 PaintPhase phase) { |
| 39 return UseCachedDrawingIfPossible( | 39 return UseCachedDrawingIfPossible( |
| 40 context, layout_object, DisplayItem::PaintPhaseToDrawingType(phase)); | 40 context, layout_object, DisplayItem::PaintPhaseToDrawingType(phase)); |
| 41 } | 41 } |
| 42 | 42 |
| 43 LayoutObjectDrawingRecorder(GraphicsContext& context, | 43 LayoutObjectDrawingRecorder(GraphicsContext& context, |
| 44 const LayoutObject& layout_object, | 44 const LayoutObject& layout_object, |
| 45 DisplayItem::Type display_item_type, | 45 DisplayItem::Type display_item_type, |
| 46 const FloatRect& clip) { | 46 const FloatRect& clip) { |
| 47 // We may paint a delayed-invalidation object before it's actually | 47 // We may paint a delayed-invalidation object before it's actually |
| 48 // invalidated. | 48 // invalidated. |
| 49 if (layout_object.FullPaintInvalidationReason() == | 49 if (layout_object.FullPaintInvalidationReason() == |
| 50 kPaintInvalidationDelayedFull) | 50 PaintInvalidationReason::kDelayedFull) |
| 51 cache_skipper_.emplace(context); | 51 cache_skipper_.emplace(context); |
| 52 drawing_recorder_.emplace(context, layout_object, display_item_type, clip); | 52 drawing_recorder_.emplace(context, layout_object, display_item_type, clip); |
| 53 } | 53 } |
| 54 | 54 |
| 55 LayoutObjectDrawingRecorder(GraphicsContext& context, | 55 LayoutObjectDrawingRecorder(GraphicsContext& context, |
| 56 const LayoutObject& layout_object, | 56 const LayoutObject& layout_object, |
| 57 DisplayItem::Type display_item_type, | 57 DisplayItem::Type display_item_type, |
| 58 const LayoutRect& clip) | 58 const LayoutRect& clip) |
| 59 : LayoutObjectDrawingRecorder(context, | 59 : LayoutObjectDrawingRecorder(context, |
| 60 layout_object, | 60 layout_object, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 94 } |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 Optional<DisplayItemCacheSkipper> cache_skipper_; | 97 Optional<DisplayItemCacheSkipper> cache_skipper_; |
| 98 Optional<DrawingRecorder> drawing_recorder_; | 98 Optional<DrawingRecorder> drawing_recorder_; |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 } // namespace blink | 101 } // namespace blink |
| 102 | 102 |
| 103 #endif // LayoutObjectDrawingRecorder_h | 103 #endif // LayoutObjectDrawingRecorder_h |
| OLD | NEW |