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

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

Issue 2678263002: Plumb border radius through when computing clip visual rects. (Closed)
Patch Set: none 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
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/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"
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 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 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* 17 // intersection of all clips between the descendant and the ancestor (*not*
18 // including the ancestor) in the clip tree, individually transformed from 18 // including the ancestor) in the clip tree, individually transformed from
19 // their localTransformSpace into the ancestor's localTransformSpace. 19 // their localTransformSpace into the ancestor's localTransformSpace.
20 typedef HashMap<const ClipPaintPropertyNode*, FloatRect> ClipCache; 20 // If one of the clip that contributes to it has a border radius, the
21 // hasRadius() field is set to true.
22 typedef HashMap<const ClipPaintPropertyNode*, FloatClipRect> ClipCache;
21 23
22 // Maps from a transform node that is a descendant of the ancestor to the 24 // 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 25 // combined transform between the descendant's and the ancestor's coordinate
24 typedef HashMap<const TransformPaintPropertyNode*, TransformationMatrix> 26 typedef HashMap<const TransformPaintPropertyNode*, TransformationMatrix>
25 TransformCache; 27 TransformCache;
26 28
27 struct PrecomputedDataForAncestor { 29 struct PrecomputedDataForAncestor {
28 TransformCache toAncestorTransforms; 30 TransformCache toAncestorTransforms;
29 31
30 // There can be multiple clips within the same transform space. This 32 // There can be multiple clips within the same transform space. This
(...skipping 29 matching lines...) Expand all
60 // If the clips and transforms of |sourceState| are equal to or descendants of 62 // If the clips and transforms of |sourceState| are equal to or descendants of
61 // those of |destinationState|, returns the same value as 63 // those of |destinationState|, returns the same value as
62 // localToAncestorVisualRect. Otherwise, maps the input rect to the 64 // localToAncestorVisualRect. Otherwise, maps the input rect to the
63 // transform state which is the lowest common ancestor of 65 // transform state which is the lowest common ancestor of
64 // |sourceState.transform| and |destinationState.transform|, then multiplies 66 // |sourceState.transform| and |destinationState.transform|, then multiplies
65 // it by the the inverse transform mapping from the lowest common ancestor to 67 // it by the the inverse transform mapping from the lowest common ancestor to
66 // |destinationState.transform|. 68 // |destinationState.transform|.
67 // 69 //
68 // DCHECK fails if the clip of |destinationState| is not an ancestor of the 70 // DCHECK fails if the clip of |destinationState| is not an ancestor of the
69 // clip of |sourceState|, or the inverse transform is not invertible. 71 // clip of |sourceState|, or the inverse transform is not invertible.
70 FloatRect sourceToDestinationVisualRect( 72 FloatClipRect sourceToDestinationVisualRect(
71 const FloatRect&, 73 const FloatRect&,
72 const PropertyTreeState& sourceState, 74 const PropertyTreeState& sourceState,
73 const PropertyTreeState& destinationState); 75 const PropertyTreeState& destinationState);
74 76
75 // Same as sourceToDestinationVisualRect() except that only transforms are 77 // Same as sourceToDestinationVisualRect() except that only transforms are
76 // applied. 78 // applied.
77 FloatRect sourceToDestinationRect( 79 FloatRect sourceToDestinationRect(
78 const FloatRect&, 80 const FloatRect&,
79 const TransformPaintPropertyNode* sourceTransformNode, 81 const TransformPaintPropertyNode* sourceTransformNode,
80 const TransformPaintPropertyNode* destinationTransformNode); 82 const TransformPaintPropertyNode* destinationTransformNode);
81 83
82 // Maps from a rect in |localTransformSpace| to its visual rect in 84 // Maps from a rect in |localTransformSpace| to its visual rect in
83 // |ancestorState|. This is computed by multiplying the rect by its combined 85 // |ancestorState|. This is computed by multiplying the rect by its combined
84 // transform between |localTransformSpace| and |ancestorSpace|, then 86 // transform between |localTransformSpace| and |ancestorSpace|, then
85 // flattening into 2D space, then intersecting by the "clip visual rect" for 87 // flattening into 2D space, then intersecting by the "clip visual rect" for
86 // |localTransformState|'s clips. See above for the definition of "clip visual 88 // |localTransformState|'s clips. See above for the definition of "clip visual
87 // rect". 89 // rect".
88 // 90 //
89 // Note that the clip of |ancestorState| is *not* applied. 91 // Note that the clip of |ancestorState| is *not* applied.
90 // 92 //
91 // DCHECK fails if any of the paint property tree nodes in 93 // DCHECK fails if any of the paint property tree nodes in
92 // |localTransformState| are not equal to or a descendant of that in 94 // |localTransformState| are not equal to or a descendant of that in
93 // |ancestorState|. 95 // |ancestorState|.
94 FloatRect localToAncestorVisualRect( 96 FloatClipRect localToAncestorVisualRect(
95 const FloatRect&, 97 const FloatRect&,
96 const PropertyTreeState& localTransformState, 98 const PropertyTreeState& localTransformState,
97 const PropertyTreeState& ancestorState); 99 const PropertyTreeState& ancestorState);
98 100
99 // Maps from a rect in |localTransformNode| space to its transformed rect in 101 // Maps from a rect in |localTransformNode| space to its transformed rect in
100 // |ancestorTransformNode| space. This is computed by multiplying the rect by 102 // |ancestorTransformNode| space. This is computed by multiplying the rect by
101 // the combined transform between |localTransformNode| and 103 // the combined transform between |localTransformNode| and
102 // |ancestorTransformNode|, then flattening into 2D space. 104 // |ancestorTransformNode|, then flattening into 2D space.
103 // 105 //
104 // DCHECK fails if |localTransformNode| is not equal to or a descendant of 106 // DCHECK fails if |localTransformNode| is not equal to or a descendant of
(...skipping 18 matching lines...) Expand all
123 125
124 // Returns the matrix used in |LocalToAncestorRect|. DCHECK fails iff 126 // Returns the matrix used in |LocalToAncestorRect|. DCHECK fails iff
125 // |localTransformNode| is not equal to or a descendant of 127 // |localTransformNode| is not equal to or a descendant of
126 // |ancestorTransformNode|. 128 // |ancestorTransformNode|.
127 const TransformationMatrix& localToAncestorMatrix( 129 const TransformationMatrix& localToAncestorMatrix(
128 const TransformPaintPropertyNode* localTransformNode, 130 const TransformPaintPropertyNode* localTransformNode,
129 const TransformPaintPropertyNode* ancestorTransformNode); 131 const TransformPaintPropertyNode* ancestorTransformNode);
130 132
131 // Returns the "clip visual rect" between |localTransformState| and 133 // Returns the "clip visual rect" between |localTransformState| and
132 // |ancestorState|. See above for the definition of "clip visual rect". 134 // |ancestorState|. See above for the definition of "clip visual rect".
133 FloatRect localToAncestorClipRect( 135 FloatClipRect localToAncestorClipRect(
134 const PropertyTreeState& localTransformState, 136 const PropertyTreeState& localTransformState,
135 const PropertyTreeState& ancestorState); 137 const PropertyTreeState& ancestorState);
136 138
137 // Returns the lowest common ancestor in the paint property tree. 139 // Returns the lowest common ancestor in the paint property tree.
138 template <typename NodeType> 140 template <typename NodeType>
139 static PLATFORM_EXPORT const NodeType* lowestCommonAncestor(const NodeType*, 141 static PLATFORM_EXPORT const NodeType* lowestCommonAncestor(const NodeType*,
140 const NodeType*); 142 const NodeType*);
141 143
142 void clearCache(); 144 void clearCache();
143 145
144 private: 146 private:
145 // The internal methods do the same things as their public counterparts, but 147 // The internal methods do the same things as their public counterparts, but
146 // take an extra |success| parameter which indicates if the function is 148 // take an extra |success| parameter which indicates if the function is
147 // successful on return. See comments of the public functions for failure 149 // successful on return. See comments of the public functions for failure
148 // conditions. 150 // conditions.
149 151
150 FloatRect sourceToDestinationVisualRectInternal( 152 FloatClipRect sourceToDestinationVisualRectInternal(
151 const FloatRect&, 153 const FloatRect&,
152 const PropertyTreeState& sourceState, 154 const PropertyTreeState& sourceState,
153 const PropertyTreeState& destinationState, 155 const PropertyTreeState& destinationState,
154 bool& success); 156 bool& success);
155 157
156 FloatRect localToAncestorVisualRectInternal( 158 FloatClipRect localToAncestorVisualRectInternal(
157 const FloatRect&, 159 const FloatRect&,
158 const PropertyTreeState& localTransformState, 160 const PropertyTreeState& localTransformState,
159 const PropertyTreeState& ancestorState, 161 const PropertyTreeState& ancestorState,
160 bool& success); 162 bool& success);
161 163
162 FloatRect localToAncestorRectInternal( 164 FloatRect localToAncestorRectInternal(
163 const FloatRect&, 165 const FloatRect&,
164 const TransformPaintPropertyNode* localTransformNode, 166 const TransformPaintPropertyNode* localTransformNode,
165 const TransformPaintPropertyNode* ancestorTransformNode, 167 const TransformPaintPropertyNode* ancestorTransformNode,
166 bool& success); 168 bool& success);
167 169
168 const TransformationMatrix& localToAncestorMatrixInternal( 170 const TransformationMatrix& localToAncestorMatrixInternal(
169 const TransformPaintPropertyNode* localTransformNode, 171 const TransformPaintPropertyNode* localTransformNode,
170 const TransformPaintPropertyNode* ancestorTransformNode, 172 const TransformPaintPropertyNode* ancestorTransformNode,
171 bool& success); 173 bool& success);
172 174
173 FloatRect localToAncestorClipRectInternal( 175 FloatClipRect localToAncestorClipRectInternal(
174 const PropertyTreeState& localTransformState, 176 const PropertyTreeState& localTransformState,
175 const PropertyTreeState& ancestorState, 177 const PropertyTreeState& ancestorState,
176 bool& success); 178 bool& success);
177 179
178 // Returns the precomputed data if already set, or adds and memoizes a new 180 // Returns the precomputed data if already set, or adds and memoizes a new
179 // PrecomputedDataForAncestor otherwise. 181 // PrecomputedDataForAncestor otherwise.
180 PrecomputedDataForAncestor& getPrecomputedDataForAncestor( 182 PrecomputedDataForAncestor& getPrecomputedDataForAncestor(
181 const TransformPaintPropertyNode*); 183 const TransformPaintPropertyNode*);
182 184
183 // Returns the transform cache for the given ancestor transform node. 185 // Returns the transform cache for the given ancestor transform node.
(...skipping 11 matching lines...) Expand all
195 m_data; 197 m_data;
196 198
197 const TransformationMatrix m_identity; 199 const TransformationMatrix m_identity;
198 200
199 DISALLOW_COPY_AND_ASSIGN(GeometryMapper); 201 DISALLOW_COPY_AND_ASSIGN(GeometryMapper);
200 }; 202 };
201 203
202 } // namespace blink 204 } // namespace blink
203 205
204 #endif // GeometryMapper_h 206 #endif // GeometryMapper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698