| 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/DisplayItemCacheSkipper.h" |
| 12 #include "platform/graphics/paint/DrawingRecorder.h" | 12 #include "platform/graphics/paint/DrawingRecorder.h" |
| 13 #include "wtf/Optional.h" | 13 #include "wtf/Optional.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class GraphicsContext; | 17 class GraphicsContext; |
| 18 | 18 |
| 19 // Convenience wrapper of DrawingRecorder for LayoutObject painters. | 19 // Convenience wrapper of DrawingRecorder for LayoutObject painters. |
| 20 class LayoutObjectDrawingRecorder final { | 20 class LayoutObjectDrawingRecorder final { |
| 21 public: | 21 public: |
| 22 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou
tObject& layoutObject, DisplayItem::Type displayItemType) | 22 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou
tObject& layoutObject, DisplayItem::Type displayItemType) |
| 23 { | 23 { |
| 24 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) | 24 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay
edFull) |
| 25 return false; | 25 return false; |
| 26 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject
, displayItemType); | 26 // TODO(wangxianzhu): Use LayoutObject repaint flags when possible to av
oid hash lookups in DisplayItemList. |
| 27 if (DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject, d
isplayItemType)) { |
| 28 ASSERT(!layoutObject.selfNeedsRepaint()); |
| 29 return true; |
| 30 } |
| 31 return false; |
| 27 } | 32 } |
| 28 | 33 |
| 29 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou
tObject& layoutObject, PaintPhase phase) | 34 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou
tObject& layoutObject, PaintPhase phase) |
| 30 { | 35 { |
| 31 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa
intPhaseToDrawingType(phase)); | 36 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa
intPhaseToDrawingType(phase)); |
| 32 } | 37 } |
| 33 | 38 |
| 34 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, DisplayItem::Type displayItemType, const FloatRect& clip) | 39 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la
youtObject, DisplayItem::Type displayItemType, const FloatRect& clip) |
| 35 { | 40 { |
| 36 // We may paint a delayed-invalidation object before it's actually inval
idated. | 41 // We may paint a delayed-invalidation object before it's actually inval
idated. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 50 #endif | 55 #endif |
| 51 | 56 |
| 52 private: | 57 private: |
| 53 Optional<DisplayItemCacheSkipper> m_cacheSkipper; | 58 Optional<DisplayItemCacheSkipper> m_cacheSkipper; |
| 54 Optional<DrawingRecorder> m_drawingRecorder; | 59 Optional<DrawingRecorder> m_drawingRecorder; |
| 55 }; | 60 }; |
| 56 | 61 |
| 57 } // namespace blink | 62 } // namespace blink |
| 58 | 63 |
| 59 #endif // LayoutObjectDrawingRecorder_h | 64 #endif // LayoutObjectDrawingRecorder_h |
| OLD | NEW |