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

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

Issue 1655553002: Update svg's root paint offset property during paint (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/ObjectPaintProperties.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"
15 #include "platform/graphics/paint/ScopedPaintChunkProperties.h"
14 #include "wtf/Allocator.h" 16 #include "wtf/Allocator.h"
15 #include "wtf/Optional.h" 17 #include "wtf/Optional.h"
16 18
17 namespace blink { 19 namespace blink {
18 20
19 class GraphicsContext; 21 class GraphicsContext;
20 22
21 // Convenience wrapper of DrawingRecorder for LayoutObject painters. 23 // Convenience wrapper of DrawingRecorder for LayoutObject painters.
22 class LayoutObjectDrawingRecorder final { 24 class LayoutObjectDrawingRecorder final {
23 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 25 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
24 public: 26 public:
25 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou tObject& layoutObject, DisplayItem::Type displayItemType, const LayoutPoint& pai ntOffset) 27 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou tObject& layoutObject, DisplayItem::Type displayItemType, const LayoutPoint& pai ntOffset)
26 { 28 {
27 if (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && layou tObject.paintOffsetChanged(paintOffset)) 29 if (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && layou tObject.paintOffsetChanged(paintOffset))
28 return false; 30 return false;
29 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay edFull) 31 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay edFull)
30 return false; 32 return false;
33
34 Optional<ScopedPaintChunkProperties> propertyScope;
jbroman 2016/02/01 16:44:20 I'm not convinced LayoutObjectDrawingRecorder is t
35 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
36 // TODO(pdr): Refactor this so it is not called twice (again in useC achedDrawingIfPossible).
37 bool willUseCachedDrawing = !context.paintController().clientCacheIs Valid(layoutObject);
38 if (willUseCachedDrawing)
39 updatePropertyScope(propertyScope, context, layoutObject);
40 }
41
31 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject , displayItemType); 42 return DrawingRecorder::useCachedDrawingIfPossible(context, layoutObject , displayItemType);
32 } 43 }
33 44
34 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou tObject& layoutObject, PaintPhase phase, const LayoutPoint& paintOffset) 45 static bool useCachedDrawingIfPossible(GraphicsContext& context, const Layou tObject& layoutObject, PaintPhase phase, const LayoutPoint& paintOffset)
35 { 46 {
36 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa intPhaseToDrawingType(phase), paintOffset); 47 return useCachedDrawingIfPossible(context, layoutObject, DisplayItem::pa intPhaseToDrawingType(phase), paintOffset);
37 } 48 }
38 49
39 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, DisplayItem::Type displayItemType, const FloatRect& clip, const Layo utPoint& paintOffset) 50 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, DisplayItem::Type displayItemType, const FloatRect& clip, const Layo utPoint& paintOffset)
40 { 51 {
52 updatePropertyScope(m_propertyScope, context, layoutObject);
41 updatePaintOffsetIfNeeded(context.paintController(), layoutObject, paint Offset); 53 updatePaintOffsetIfNeeded(context.paintController(), layoutObject, paint Offset);
42 // We may paint a delayed-invalidation object before it's actually inval idated. 54 // We may paint a delayed-invalidation object before it's actually inval idated.
43 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay edFull) 55 if (layoutObject.fullPaintInvalidationReason() == PaintInvalidationDelay edFull)
44 m_cacheSkipper.emplace(context); 56 m_cacheSkipper.emplace(context);
45 m_drawingRecorder.emplace(context, layoutObject, displayItemType, clip); 57 m_drawingRecorder.emplace(context, layoutObject, displayItemType, clip);
46 } 58 }
47 59
48 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, DisplayItem::Type displayItemType, const LayoutRect& clip, const Lay outPoint& paintOffset) 60 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, DisplayItem::Type displayItemType, const LayoutRect& clip, const Lay outPoint& paintOffset)
49 : LayoutObjectDrawingRecorder(context, layoutObject, displayItemType, Fl oatRect(clip), paintOffset) { } 61 : LayoutObjectDrawingRecorder(context, layoutObject, displayItemType, Fl oatRect(clip), paintOffset) { }
50 62
51 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const FloatRect& clip, const LayoutPoint& paintOff set) 63 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const FloatRect& clip, const LayoutPoint& paintOff set)
52 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), clip, paintOffset) { } 64 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), clip, paintOffset) { }
53 65
54 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const LayoutRect& clip, const LayoutPoint& paintOf fset) 66 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const LayoutRect& clip, const LayoutPoint& paintOf fset)
55 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), FloatRect(clip), paintOffset) { } 67 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), FloatRect(clip), paintOffset) { }
56 68
57 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const IntRect& clip, const LayoutPoint& paintOffse t) 69 LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase, const IntRect& clip, const LayoutPoint& paintOffse t)
58 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), FloatRect(clip), paintOffset) { } 70 : LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintP haseToDrawingType(phase), FloatRect(clip), paintOffset) { }
59 71
60 void setKnownToBeOpaque() { ASSERT(RuntimeEnabledFeatures::slimmingPaintV2En abled()); m_drawingRecorder->setKnownToBeOpaque(); } 72 void setKnownToBeOpaque() { ASSERT(RuntimeEnabledFeatures::slimmingPaintV2En abled()); m_drawingRecorder->setKnownToBeOpaque(); }
61 73
62 #if ENABLE(ASSERT) 74 #if ENABLE(ASSERT)
63 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); } 75 void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationC heckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); }
64 #endif 76 #endif
65 77
78 static void updatePropertyScope(Optional<ScopedPaintChunkProperties>& scoped PaintChunkProperties, GraphicsContext& context, const LayoutObject& layoutObject )
79 {
80 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled())
81 return;
82
83 // Only objects with properties and no layer need to update paint
84 // properties, as PaintLayerPainter will handle all other cases.
trchen 2016/02/02 01:34:48 This statement is not true. For example, a PaintLa
85 // (see: PaintLayerPainter::paintLayerContents).
86 if (!layoutObject.objectPaintProperties() || layoutObject.hasLayer())
87 return;
88
89 const ObjectPaintProperties& objectProperties = *layoutObject.objectPain tProperties();
90 PaintChunkProperties properties(context.paintController().currentPaintCh unkProperties());
91 if (TransformPaintPropertyNode* transform = objectProperties.paintOffset Translation())
92 properties.transform = transform;
93 if (TransformPaintPropertyNode* transform = objectProperties.transform() )
94 properties.transform = transform;
95 if (TransformPaintPropertyNode* transform = objectProperties.perspective ())
96 properties.transform = transform;
97 if (TransformPaintPropertyNode* transform = objectProperties.scrollTrans lation())
98 properties.transform = transform;
99 if (EffectPaintPropertyNode* effect = objectProperties.effect())
100 properties.effect = effect;
101 scopedPaintChunkProperties.emplace(context.paintController(), properties );
102 }
66 private: 103 private:
67 static void updatePaintOffsetIfNeeded(PaintController& paintController, cons t LayoutObject& layoutObject, const LayoutPoint& paintOffset) 104 static void updatePaintOffsetIfNeeded(PaintController& paintController, cons t LayoutObject& layoutObject, const LayoutPoint& paintOffset)
68 { 105 {
69 if (!RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() || pain tController.skippingCache()) 106 if (!RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() || pain tController.skippingCache())
70 return; 107 return;
71 108
72 if (layoutObject.paintOffsetChanged(paintOffset)) 109 if (layoutObject.paintOffsetChanged(paintOffset))
73 paintController.invalidatePaintOffset(layoutObject); 110 paintController.invalidatePaintOffset(layoutObject);
74 else 111 else
75 ASSERT(!paintController.paintOffsetWasInvalidated(layoutObject) || ! paintController.clientCacheIsValid(layoutObject)); 112 ASSERT(!paintController.paintOffsetWasInvalidated(layoutObject) || ! paintController.clientCacheIsValid(layoutObject));
76 113
77 layoutObject.mutableForPainting().setPreviousPaintOffset(paintOffset); 114 layoutObject.mutableForPainting().setPreviousPaintOffset(paintOffset);
78 } 115 }
79 116
117 Optional<ScopedPaintChunkProperties> m_propertyScope;
80 Optional<DisplayItemCacheSkipper> m_cacheSkipper; 118 Optional<DisplayItemCacheSkipper> m_cacheSkipper;
81 Optional<DrawingRecorder> m_drawingRecorder; 119 Optional<DrawingRecorder> m_drawingRecorder;
82 }; 120 };
83 121
84 } // namespace blink 122 } // namespace blink
85 123
86 #endif // LayoutObjectDrawingRecorder_h 124 #endif // LayoutObjectDrawingRecorder_h
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/virtual/spv2/svg/README.txt ('k') | third_party/WebKit/Source/core/paint/SVGRootPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698