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

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

Issue 1973343003: Initial implementation of GeometryMapper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: none Created 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef GeometryMapper_h
6 #define GeometryMapper_h
7
8 #include "platform/geometry/FloatRect.h"
9 #include "platform/graphics/paint/PropertyTreeState.h"
10 #include "platform/transforms/TransformationMatrix.h"
11 #include "wtf/HashMap.h"
12
13 namespace blink {
14
15 struct PrecomputedDataForAncestor {
16 // Maps from a transform node that is a descendant of the ancestor to the co mbined
17 // transform between the descendant's and the ancestor's coordinate space.
18 HashMap<const TransformPaintPropertyNode*, TransformationMatrix>
19 toAncestorTransforms;
Xianzhu 2016/06/22 23:20:30 Nit: The wrapping looks weird. I would put the abo
chrishtr 2016/06/23 00:18:26 Done.
20
21 // Maps from a descendant clip node to its equivalent "clip visual rect" in the space of the ancestor.
22 // The clip visual rect is defined as the intersection of all clips between the descendant
23 // and the ancestor (*not* including the ancestor) in the clip tree, individ ually transformed from their
24 // localTransformSpace into the ancestor's localTransformSpace.
25 HashMap<const ClipPaintPropertyNode*, FloatRect> toAncestorClipRects;
26 };
27
28 // GeometryMapper is a helper class for fast computations of transformed and vis ual rects in different
29 // PropertyTreeStates. The design document has a number of details on use cases, algorithmic definitions,
30 // and running times.
31 //
32 // Design document: http://bit.ly/28P4FDA
33 //
34 // TODO(chrishtr): take effect and scroll trees into account.
35 class PLATFORM_EXPORT GeometryMapper {
36 public:
37 GeometryMapper() {}
38
39 // The runtime of m calls among LocalToVisibleRectInAncestorSpace, LocalToAn cestorRect or AncestorToLocalRect
40 // with the same |ancestorState| parameter is guaranteed to be O(n + m), wh ere n is the number of transform and clip/
wkorman 2016/06/22 23:33:32 rm '/' after clip
chrishtr 2016/06/23 00:18:26 Done.
41 // nodes in their respective property trees.
42
43 // Maps from a rect in |localTransformSpace| to its visual rect in |ancestor State|. This is computed
44 // by multiplying the rect by its combined transform between |localTransform Space| and |ancestorSpace|,
45 // then flattening into 2D space, then intersecting by the "clip visual rect " for |localTransformState|'s clips.
46 // See above for the definition of "clip visual rect".
47 //
48 // Note that the clip of |ancestorState| is *not* applied.
49 //
50 // It is an error to call this method if any of the paint property tree node s in |localTransformState| not equal
wkorman 2016/06/22 23:33:32 are not equal
chrishtr 2016/06/23 00:18:27 Done.
51 // to or a descendat of that in |ancestorState|.
Xianzhu 2016/06/22 23:20:30 Nit: s/descendat/descendant/.
wkorman 2016/06/22 23:33:32 descendant (and 2x more below)
chrishtr 2016/06/23 00:18:27 Done.
52 FloatRect LocalToVisibleRectInAncestorSpace(const FloatRect&,
Xianzhu 2016/06/22 23:20:30 VisualRect?
wkorman 2016/06/22 23:33:32 Visible -> Visual in method name?
chrishtr 2016/06/23 00:18:26 Done.
53 const PropertyTreeState& localTransformState,
54 const PropertyTreeState& ancestorState);
55
56 // Maps from a rect in |localTransformSpace}| to its transformed rect in |an cestorSpace|. This is computed
Xianzhu 2016/06/22 23:20:30 Nit: extra '}'
chrishtr 2016/06/23 00:18:27 Done.
57 // by multiplying the rect by the combined transform between |localTransform State| and |ancestorState|,
58 // then flattening into 2D space.
59 //
60 // It is an error to call this method if any of the paint property tree node s in |localTransformState| not equal
wkorman 2016/06/22 23:33:32 What would be returned in this case? Should we hav
chrishtr 2016/06/23 00:18:27 Undefined. It should never happen and represents a
61 // to or a descendat of that in |ancestorState|.
62 FloatRect LocalToAncestorRect(const FloatRect&,
63 const PropertyTreeState& localTransformState,
64 const PropertyTreeState& ancestorState);
65
66 // Maps from a rect in |ancestorSpace}| to its transformed rect in |localTra nsformSpace|. This is computed
wkorman 2016/06/22 23:33:32 rm } before |
chrishtr 2016/06/23 00:18:27 Done.
67 // by multiplying the rect by the inverse combined transform between |localT ransformState| and |ancestorState|.
68 //
69 // It is an error to call this method if any of the paint property tree node s in |localTransformState| not equal
70 // to or a descendat of that in |ancestorState|.
71 FloatRect AncestorToLocalRect(const FloatRect&,
wkorman 2016/06/22 23:33:32 Should briefly comment on success arg and return v
chrishtr 2016/06/23 00:18:26 Done.
72 const PropertyTreeState& localTransformState,
73 const PropertyTreeState& ancestorState, bool* success);
74 private:
Xianzhu 2016/06/22 23:20:30 Nit: Insert a blank line before private:.
chrishtr 2016/06/23 00:18:26 Done.
75 // Returns the matrix used in |LocalToAncestorRect|.
76 const TransformationMatrix LocalToAncestorMatrix(
77 const TransformPaintPropertyNode* localTransformState,
78 const PropertyTreeState& ancestorState);
79
80 // Returns the "clip visual rect" between |localTransformState| and |ancesto rState|. See above for the definition
81 // of "clip visual rect".
82 const FloatRect LocalToAncestorClipRect(
83 const PropertyTreeState& localTransformState,
84 const PropertyTreeState& ancestorState);
85
86 // Returns the precomputed data if already set, or adds and memoizes a new P recomputedDataForAncestor otherwise.
87 PrecomputedDataForAncestor* GetPrecomputedDataForAncestor(const PropertyTree State&);
88
89 friend class GeometryMapperTest;
90
91 HashMap<const TransformPaintPropertyNode*, PrecomputedDataForAncestor> m_dat a;
92 };
93
94 } // namespace blink
95
96 #endif // GeometryMapper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698