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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/GeometryMapper.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 GeometryMapper_h 5 #ifndef GeometryMapper_h
6 #define GeometryMapper_h 6 #define GeometryMapper_h
7 7
8 #include "platform/graphics/paint/FloatClipRect.h" 8 #include "platform/graphics/paint/FloatClipRect.h"
9 #include "platform/graphics/paint/PropertyTreeState.h" 9 #include "platform/graphics/paint/PropertyTreeState.h"
10 #include "platform/transforms/TransformationMatrix.h" 10 #include "platform/transforms/TransformationMatrix.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 const FloatRect&, 149 const FloatRect&,
150 const TransformPaintPropertyNode* localTransformNode, 150 const TransformPaintPropertyNode* localTransformNode,
151 const TransformPaintPropertyNode* ancestorTransformNode, 151 const TransformPaintPropertyNode* ancestorTransformNode,
152 bool& success); 152 bool& success);
153 153
154 const TransformationMatrix& localToAncestorMatrixInternal( 154 const TransformationMatrix& localToAncestorMatrixInternal(
155 const TransformPaintPropertyNode* localTransformNode, 155 const TransformPaintPropertyNode* localTransformNode,
156 const TransformPaintPropertyNode* ancestorTransformNode, 156 const TransformPaintPropertyNode* ancestorTransformNode,
157 bool& success); 157 bool& success);
158 158
159 FloatClipRect localToAncestorClipRectInternal( 159 const FloatClipRect& localToAncestorClipRectInternal(
160 const ClipPaintPropertyNode* descendant, 160 const ClipPaintPropertyNode* descendant,
161 const ClipPaintPropertyNode* ancestorClip, 161 const ClipPaintPropertyNode* ancestorClip,
162 const TransformPaintPropertyNode* ancestorTransform, 162 const TransformPaintPropertyNode* ancestorTransform,
163 bool& success); 163 bool& success);
164 164
165 FloatClipRect sourceToDestinationClipRectInternal( 165 FloatClipRect sourceToDestinationClipRectInternal(
166 const PropertyTreeState& sourceState, 166 const PropertyTreeState& sourceState,
167 const PropertyTreeState& destinationState, 167 const PropertyTreeState& destinationState,
168 bool& success); 168 bool& success);
169 169
170 FloatClipRect slowLocalToAncestorVisualRectWithEffects( 170 FloatClipRect slowLocalToAncestorVisualRectWithEffects(
171 const FloatRect&, 171 const FloatRect&,
172 const PropertyTreeState& localState, 172 const PropertyTreeState& localState,
173 const PropertyTreeState& ancestorState, 173 const PropertyTreeState& ancestorState,
174 bool& success); 174 bool& success);
175 175
176 // Maps from a transform node that is a descendant of the implied ancestor 176 struct ClipAndTransform {
177 // transform node to the combined transform between the descendant's and the 177 const ClipPaintPropertyNode* ancestorClip;
178 // ancestor's coordinate space. 178 const TransformPaintPropertyNode* ancestorTransform;
179 // The "implied ancestor" is the key of the m_transformCache object for which 179 bool operator==(const ClipAndTransform& other) const {
180 // this TransformCache is a value. 180 return ancestorClip == other.ancestorClip &&
181 using TransformCache = 181 ancestorTransform == other.ancestorTransform;
182 HashMap<const TransformPaintPropertyNode*, TransformationMatrix>; 182 }
183 ClipAndTransform(const ClipPaintPropertyNode* ancestorClipArg,
184 const TransformPaintPropertyNode* ancestorTransformArg)
185 : ancestorClip(ancestorClipArg),
186 ancestorTransform(ancestorTransformArg) {}
187 };
183 188
184 // Returns the transform cache for the given ancestor transform node. 189 struct ClipCacheEntry {
185 TransformCache& getTransformCache(const TransformPaintPropertyNode* ancestor); 190 const ClipAndTransform clipAndTransform;
191 const FloatClipRect clipRect;
192 ClipCacheEntry(const ClipAndTransform& clipAndTransformArg,
193 const FloatClipRect& clipRectArg)
194 : clipAndTransform(clipAndTransformArg), clipRect(clipRectArg) {}
195 };
186 196
187 // Maps from a descendant clip node to its equivalent "clip visual rect" in 197 Vector<ClipCacheEntry>* getClipCacheEntries(
188 // the local transform space of the implied ancestor clip node. The clip 198 const ClipPaintPropertyNode* descendantClip);
189 // visual rect is defined as the intersection of all clips between the
190 // descendant and the ancestor (*not* including the ancestor) in the clip
191 // tree, individually transformed from their localTransformSpace into the
192 // ancestor's localTransformSpace. If one of the clips that contributes to it
193 // has a border radius, the hasRadius() field is set to true.
194 // The "implied ancestor" is the key of the TransformToClip cachefor which
195 // this ClipCache is a value.
196 using ClipCache = HashMap<const ClipPaintPropertyNode*, FloatClipRect>;
197 199
198 using TransformToClip = 200 const FloatClipRect* getClip(const ClipPaintPropertyNode* descendantClip,
199 HashMap<const TransformPaintPropertyNode*, std::unique_ptr<ClipCache>>; 201 const ClipAndTransform& ancestors);
200 202
201 // Returns the clip cache for the given transform space relative to the 203 void setClip(const ClipPaintPropertyNode* descendantClip,
202 // given ancestor clip node. 204 const ClipAndTransform&,
203 ClipCache& getClipCache(const ClipPaintPropertyNode* ancestorClip, 205 const FloatClipRect&);
204 const TransformPaintPropertyNode* ancestorTransform); 206
207 struct TransformCacheEntry {
208 const TransformPaintPropertyNode* ancestorNode;
209 TransformationMatrix toAncestor;
210 TransformCacheEntry(const TransformPaintPropertyNode* ancestorNodeArg,
211 const TransformationMatrix& toAncestorArg)
212 : ancestorNode(ancestorNodeArg), toAncestor(toAncestorArg) {}
213 };
214
215 Vector<TransformCacheEntry>* getTransformCacheEntries(
216 const TransformPaintPropertyNode* descendantTransform);
217
218 const TransformationMatrix* getTransform(
219 const TransformPaintPropertyNode* descendantTransform,
220 const TransformPaintPropertyNode* ancestorTransform);
221
222 void setTransform(const TransformPaintPropertyNode* descendantTransform,
223 const TransformPaintPropertyNode* ancestorTransform,
224 const TransformationMatrix& toAncestor);
205 225
206 friend class GeometryMapperTest; 226 friend class GeometryMapperTest;
207 friend class PaintLayerClipperTest; 227 friend class PaintLayerClipperTest;
208 228
209 HashMap<const TransformPaintPropertyNode*, std::unique_ptr<TransformCache>> 229 // Maps from a descendant transform node to a list of all ancestor transform
230 // nodes for which there is a cached transform from the descendant.
231 HashMap<const TransformPaintPropertyNode*,
232 std::unique_ptr<Vector<TransformCacheEntry>>>
210 m_transformCache; 233 m_transformCache;
211 HashMap<const ClipPaintPropertyNode*, std::unique_ptr<TransformToClip>> 234
235 // Maps from a descendant clip node to a list of all <transform, clip>
236 // ancestor pairs for which there is a cached clip rect from the descendant.
237 HashMap<const ClipPaintPropertyNode*, std::unique_ptr<Vector<ClipCacheEntry>>>
212 m_clipCache; 238 m_clipCache;
213 239
214 const TransformationMatrix m_identity; 240 const TransformationMatrix m_identity;
241 const FloatClipRect m_infiniteClip;
215 242
216 DISALLOW_COPY_AND_ASSIGN(GeometryMapper); 243 DISALLOW_COPY_AND_ASSIGN(GeometryMapper);
217 }; 244 };
218 245
219 } // namespace blink 246 } // namespace blink
220 247
221 #endif // GeometryMapper_h 248 #endif // GeometryMapper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698