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

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

Issue 2672993004: Fix clip caching bug in GeometryMapper. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/paint/GeometryMapper.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/geometry/FloatRect.h" 8 #include "platform/geometry/FloatRect.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"
11 #include "wtf/HashMap.h" 11 #include "wtf/HashMap.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 // Maps from a descendant clip node to its equivalent "clip visual rect" in
16 // the space of the ancestor. The clip visual rect is defined as the
17 // intersection of all clips between the descendant and the ancestor (*not*
18 // including the ancestor) in the clip tree, individually transformed from
19 // their localTransformSpace into the ancestor's localTransformSpace.
20 typedef HashMap<const ClipPaintPropertyNode*, FloatRect> ClipCache;
21
22 // Maps from a transform node that is a descendant of the ancestor to the
23 // combined transform between the descendant's and the ancestor's coordinate
24 typedef HashMap<const TransformPaintPropertyNode*, TransformationMatrix>
25 TransformCache;
26
15 struct PrecomputedDataForAncestor { 27 struct PrecomputedDataForAncestor {
16 // Maps from a transform node that is a descendant of the ancestor to the 28 TransformCache toAncestorTransforms;
17 // combined transform between the descendant's and the ancestor's coordinate
18 // space.
19 HashMap<const TransformPaintPropertyNode*, TransformationMatrix>
20 toAncestorTransforms;
21 29
22 // Maps from a descendant clip node to its equivalent "clip visual rect" in 30 // There can be multiple clips within the same transform space. This
23 // the space of the ancestor. The clip visual rect is defined as the 31 // maps from the desired destination clip within the same transform
24 // intersection of all clips between the descendant and the ancestor (*not* 32 // space to its corresponding ClipCache.
25 // including the ancestor) in the clip tree, individually transformed from 33 HashMap<const ClipPaintPropertyNode*, std::unique_ptr<ClipCache>>
26 // their localTransformSpace into the ancestor's localTransformSpace. 34 precomputedClips;
27 HashMap<const ClipPaintPropertyNode*, FloatRect> toAncestorClipRects;
28 35
29 static std::unique_ptr<PrecomputedDataForAncestor> create() { 36 static std::unique_ptr<PrecomputedDataForAncestor> create() {
30 return WTF::makeUnique<PrecomputedDataForAncestor>(); 37 return WTF::makeUnique<PrecomputedDataForAncestor>();
31 } 38 }
32 }; 39 };
Xianzhu 2017/02/05 02:03:45 Nit: Move the above types into private section of
33 40
34 // GeometryMapper is a helper class for fast computations of transformed and 41 // GeometryMapper is a helper class for fast computations of transformed and
35 // visual rects in different PropertyTreeStates. The design document has a 42 // visual rects in different PropertyTreeStates. The design document has a
36 // number of details on use cases, algorithmic definitions, and running times. 43 // number of details on use cases, algorithmic definitions, and running times.
37 // 44 //
38 // NOTE: A GeometryMapper object is only valid for property trees that do not 45 // NOTE: A GeometryMapper object is only valid for property trees that do not
39 // change. If any mutation occurs, a new GeometryMapper object must be allocated 46 // change. If any mutation occurs, a new GeometryMapper object must be allocated
40 // corresponding to the new state. 47 // corresponding to the new state.
41 // 48 //
42 // Design document: http://bit.ly/28P4FDA 49 // Design document: http://bit.ly/28P4FDA
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 FloatRect localToAncestorClipRectInternal( 173 FloatRect localToAncestorClipRectInternal(
167 const PropertyTreeState& localTransformState, 174 const PropertyTreeState& localTransformState,
168 const PropertyTreeState& ancestorState, 175 const PropertyTreeState& ancestorState,
169 bool& success); 176 bool& success);
170 177
171 // Returns the precomputed data if already set, or adds and memoizes a new 178 // Returns the precomputed data if already set, or adds and memoizes a new
172 // PrecomputedDataForAncestor otherwise. 179 // PrecomputedDataForAncestor otherwise.
173 PrecomputedDataForAncestor& getPrecomputedDataForAncestor( 180 PrecomputedDataForAncestor& getPrecomputedDataForAncestor(
174 const TransformPaintPropertyNode*); 181 const TransformPaintPropertyNode*);
175 182
183 // Returns the transform cache for the given ancestor transform node.
184 TransformCache& getTransformCache(const TransformPaintPropertyNode*);
185
186 // Returns the clip cache for the given ancestor clip node.
187 ClipCache& getClipCache(const TransformPaintPropertyNode*,
188 const ClipPaintPropertyNode*);
189
176 friend class GeometryMapperTest; 190 friend class GeometryMapperTest;
177 friend class PaintLayerClipperTest; 191 friend class PaintLayerClipperTest;
178 192
179 HashMap<const TransformPaintPropertyNode*, 193 HashMap<const TransformPaintPropertyNode*,
180 std::unique_ptr<PrecomputedDataForAncestor>> 194 std::unique_ptr<PrecomputedDataForAncestor>>
181 m_data; 195 m_data;
182 196
183 const TransformationMatrix m_identity; 197 const TransformationMatrix m_identity;
184 198
185 DISALLOW_COPY_AND_ASSIGN(GeometryMapper); 199 DISALLOW_COPY_AND_ASSIGN(GeometryMapper);
186 }; 200 };
187 201
188 } // namespace blink 202 } // namespace blink
189 203
190 #endif // GeometryMapper_h 204 #endif // GeometryMapper_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/paint/GeometryMapper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698