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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/ClipPaintPropertyNode.h

Issue 2729243002: Improve performance of GeometryMapper cache. (Closed)
Patch Set: none Created 3 years, 9 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 ClipPaintPropertyNode_h 5 #ifndef ClipPaintPropertyNode_h
6 #define ClipPaintPropertyNode_h 6 #define ClipPaintPropertyNode_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "platform/geometry/FloatRoundedRect.h" 9 #include "platform/geometry/FloatRoundedRect.h"
10 #include "platform/graphics/paint/FloatClipRect.h"
10 #include "platform/graphics/paint/TransformPaintPropertyNode.h" 11 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
11 #include "wtf/PassRefPtr.h" 12 #include "wtf/PassRefPtr.h"
12 #include "wtf/RefCounted.h" 13 #include "wtf/RefCounted.h"
13 #include "wtf/RefPtr.h" 14 #include "wtf/RefPtr.h"
14 #include "wtf/text/WTFString.h" 15 #include "wtf/text/WTFString.h"
15 16
16 #include <iosfwd> 17 #include <iosfwd>
17 18
18 namespace blink { 19 namespace blink {
19 20
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 80
80 String toTreeString() const; 81 String toTreeString() const;
81 #endif 82 #endif
82 83
83 String toString() const; 84 String toString() const;
84 85
85 bool hasDirectCompositingReasons() const { 86 bool hasDirectCompositingReasons() const {
86 return m_directCompositingReasons != CompositingReasonNone; 87 return m_directCompositingReasons != CompositingReasonNone;
87 } 88 }
88 89
90 // Clears all clip caches (see getClipCache()).
91 static void clearCache();
92
93 struct ClipAndTransform {
94 const ClipPaintPropertyNode* ancestorClip;
95 const TransformPaintPropertyNode* ancestorTransform;
96 bool operator==(const ClipAndTransform& other) const {
97 return ancestorClip == other.ancestorClip &&
98 ancestorTransform == other.ancestorTransform;
99 }
100 ClipAndTransform(const ClipPaintPropertyNode* ancestorClipArg,
101 const TransformPaintPropertyNode* ancestorTransformArg)
102 : ancestorClip(ancestorClipArg),
103 ancestorTransform(ancestorTransformArg) {}
104 };
105
89 private: 106 private:
90 ClipPaintPropertyNode( 107 ClipPaintPropertyNode(
91 PassRefPtr<const ClipPaintPropertyNode> parent, 108 PassRefPtr<const ClipPaintPropertyNode> parent,
92 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, 109 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace,
93 const FloatRoundedRect& clipRect, 110 const FloatRoundedRect& clipRect,
94 CompositingReasons directCompositingReasons) 111 CompositingReasons directCompositingReasons);
95 : m_parent(parent), 112
96 m_localTransformSpace(localTransformSpace), 113 struct ClipCacheEntry {
97 m_clipRect(clipRect), 114 const ClipAndTransform clipAndTransform;
98 m_directCompositingReasons(directCompositingReasons) {} 115 const FloatClipRect clipRect;
116 ClipCacheEntry(const ClipAndTransform& clipAndTransformArg,
117 const FloatClipRect& clipRectArg)
118 : clipAndTransform(clipAndTransformArg), clipRect(clipRectArg) {}
119 };
120
121 Vector<ClipCacheEntry>* getClipCacheEntries();
122
123 // For access to getCachedClip() and setCachedClip.
124 friend class GeometryMapper;
125 friend class GeometryMapperTest;
126
127 // Returns the "clip visual rect" (See GeometryMapper.h) of |this|
128 // in the space of |ancestors|, if there is one cached. Otherwise returns
129 // null.
130 const FloatClipRect* getCachedClip(const ClipAndTransform& ancestors) const;
131 // Stores the "clip visual rect" of |this in the space of |ancestors|,
132 // into a local cache.
133
134 void setCachedClip(const ClipAndTransform&, const FloatClipRect&) const;
99 135
100 RefPtr<const ClipPaintPropertyNode> m_parent; 136 RefPtr<const ClipPaintPropertyNode> m_parent;
101 RefPtr<const TransformPaintPropertyNode> m_localTransformSpace; 137 RefPtr<const TransformPaintPropertyNode> m_localTransformSpace;
102 FloatRoundedRect m_clipRect; 138 FloatRoundedRect m_clipRect;
103 CompositingReasons m_directCompositingReasons; 139 CompositingReasons m_directCompositingReasons;
140
141 std::unique_ptr<Vector<ClipCacheEntry>> m_clipCache;
pdr. 2017/03/07 23:22:13 We're exposing a lot of geometry mapper's caching
chrishtr 2017/03/08 00:35:44 It's not all that exposed, since it's private to t
142 unsigned m_cacheGeneration;
143 const FloatClipRect m_infiniteClip;
104 }; 144 };
105 145
106 // Redeclared here to avoid ODR issues. 146 // Redeclared here to avoid ODR issues.
107 // See platform/testing/PaintPrinters.h. 147 // See platform/testing/PaintPrinters.h.
108 void PrintTo(const ClipPaintPropertyNode&, std::ostream*); 148 void PrintTo(const ClipPaintPropertyNode&, std::ostream*);
109 149
110 } // namespace blink 150 } // namespace blink
111 151
112 #endif // ClipPaintPropertyNode_h 152 #endif // ClipPaintPropertyNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698