Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: Source/core/paint/LayoutObjectDrawingRecorder.h

Issue 1220583004: Refactor DrawingRecorders to check for cached drawings earlier (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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)
23 {
24 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay edFull)
25 return false;
26 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject , displayItemType);
27 }
28
29 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou tObject& layoutObject, PaintPhase phase)
30 {
31 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa intPhaseToDrawingType(phase));
32 }
33
22 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, DisplayItem::Type displayItemType, const FloatRect& clip) 34 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, DisplayItem::Type displayItemType, const FloatRect& clip)
23 { 35 {
24 // We may paint a delayed-invalidation object before it's actually inval idated. 36 // We may paint a delayed-invalidation object before it's actually inval idated.
25 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay edFull) 37 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay edFull)
26 m_cacheSkipper.emplace(context); 38 m_cacheSkipper.emplace(context);
27 m_drawingRecorder.emplace(context, layoutObject, displayItemType, clip); 39 m_drawingRecorder.emplace(context, layoutObject, displayItemType, clip);
28 } 40 }
29 41
30 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const FloatRect& clip) 42 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const FloatRect& clip)
31 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), clip) { } 43 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), clip) { }
32 44
33 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, DisplayItem::Type type, const LayoutRect& clip) 45 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, DisplayItem::Type type, const LayoutRect& clip)
34 : LayoutObjectDrawingRecorder(context, layoutObject, type, pixelSnappedI ntRect(clip)) { } 46 : LayoutObjectDrawingRecorder(context, layoutObject, type, pixelSnappedI ntRect(clip)) { }
35 47
36 bool canUseCachedDrawing() const { return m_drawingRecorder->canUseCachedDra wing(); }
37
38 #if ENABLE(ASSERT) 48 #if ENABLE(ASSERT)
39 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); } 49 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); }
40 #endif 50 #endif
41 51
42 private: 52 private:
43 Optional<DisplayItemCacheSkipper> m_cacheSkipper; 53 Optional<DisplayItemCacheSkipper> m_cacheSkipper;
44 Optional<DrawingRecorder> m_drawingRecorder; 54 Optional<DrawingRecorder> m_drawingRecorder;
45 }; 55 };
46 56
47 } // namespace blink 57 } // namespace blink
48 58
49 #endif // LayoutObjectDrawingRecorder_h 59 #endif // LayoutObjectDrawingRecorder_h
OLDNEW
« no previous file with comments | « Source/core/paint/LayerClipRecorderTest.cpp ('k') | Source/core/paint/LayoutObjectDrawingRecorderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698