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

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

Issue 2802443002: Compute rounded-ness of visual rects (Closed)
Patch Set: none Created 3 years, 8 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 30 matching lines...) Expand all
41 // localToAncestorVisualRect. Otherwise, maps the input rect to the 41 // localToAncestorVisualRect. Otherwise, maps the input rect to the
42 // transform state which is the lowest common ancestor of 42 // transform state which is the lowest common ancestor of
43 // |sourceState.transform| and |destinationState.transform|, then multiplies 43 // |sourceState.transform| and |destinationState.transform|, then multiplies
44 // it by the the inverse transform mapping from the lowest common ancestor to 44 // it by the the inverse transform mapping from the lowest common ancestor to
45 // |destinationState.transform|. 45 // |destinationState.transform|.
46 // 46 //
47 // DCHECK fails if the clip of |destinationState| is not an ancestor of the 47 // DCHECK fails if the clip of |destinationState| is not an ancestor of the
48 // clip of |sourceState|, or the inverse transform is not invertible. 48 // clip of |sourceState|, or the inverse transform is not invertible.
49 // 49 //
50 // |mappingRect| is both input and output. 50 // |mappingRect| is both input and output.
51 //
52 // The output FloatClipRect may contain false positives for rounded-ness
53 // if a rounded clip is clipped out, and overly conservative results
54 // in the presences of transforms.
55 //
56 // TODO(chrishtr): we should provide a variant of these methods that
57 // guarantees a tight result, or else signals an error. crbug.com/708741
51 static void sourceToDestinationVisualRect( 58 static void sourceToDestinationVisualRect(
52 const PropertyTreeState& sourceState, 59 const PropertyTreeState& sourceState,
53 const PropertyTreeState& destinationState, 60 const PropertyTreeState& destinationState,
54 FloatRect& mappingRect); 61 FloatClipRect& mappingRect);
55 62
56 // Same as sourceToDestinationVisualRect() except that only transforms are 63 // Same as sourceToDestinationVisualRect() except that only transforms are
57 // applied. 64 // applied.
58 // 65 //
59 // |mappingRect| is both input and output. 66 // |mappingRect| is both input and output.
60 static void sourceToDestinationRect( 67 static void sourceToDestinationRect(
61 const TransformPaintPropertyNode* sourceTransformNode, 68 const TransformPaintPropertyNode* sourceTransformNode,
62 const TransformPaintPropertyNode* destinationTransformNode, 69 const TransformPaintPropertyNode* destinationTransformNode,
63 FloatRect& mappingRect); 70 FloatRect& mappingRect);
64 71
65 // Maps from a rect in |localTransformSpace| to its visual rect in 72 // Maps from a rect in |localTransformSpace| to its visual rect in
66 // |ancestorState|. This is computed by multiplying the rect by its combined 73 // |ancestorState|. This is computed by multiplying the rect by its combined
67 // transform between |localTransformSpace| and |ancestorSpace|, then 74 // transform between |localTransformSpace| and |ancestorSpace|, then
68 // flattening into 2D space, then intersecting by the "clip visual rect" for 75 // flattening into 2D space, then intersecting by the "clip visual rect" for
69 // |localTransformState|'s clips. See above for the definition of "clip visual 76 // |localTransformState|'s clips. See above for the definition of "clip visual
70 // rect". 77 // rect".
71 // 78 //
72 // Note that the clip of |ancestorState| is *not* applied. 79 // Note that the clip of |ancestorState| is *not* applied.
73 // 80 //
74 // DCHECK fails if any of the paint property tree nodes in 81 // DCHECK fails if any of the paint property tree nodes in
75 // |localTransformState| are not equal to or a descendant of that in 82 // |localTransformState| are not equal to or a descendant of that in
76 // |ancestorState|. 83 // |ancestorState|.
77 // 84 //
78 // |mappingRect| is both input and output. 85 // |mappingRect| is both input and output.
86 //
87 // The output FloatClipRect may contain false positives for rounded-ness
88 // if a rounded clip is clipped out, and overly conservative results
89 // in the presences of transforms.
79 static void localToAncestorVisualRect( 90 static void localToAncestorVisualRect(
80 const PropertyTreeState& localTransformState, 91 const PropertyTreeState& localTransformState,
81 const PropertyTreeState& ancestorState, 92 const PropertyTreeState& ancestorState,
82 FloatRect& mappingRect); 93 FloatClipRect& mappingRect);
83 94
84 // Maps from a rect in |localTransformNode| space to its transformed rect in 95 // Maps from a rect in |localTransformNode| space to its transformed rect in
85 // |ancestorTransformNode| space. This is computed by multiplying the rect by 96 // |ancestorTransformNode| space. This is computed by multiplying the rect by
86 // the combined transform between |localTransformNode| and 97 // the combined transform between |localTransformNode| and
87 // |ancestorTransformNode|, then flattening into 2D space. 98 // |ancestorTransformNode|, then flattening into 2D space.
88 // 99 //
89 // DCHECK fails if |localTransformNode| is not equal to or a descendant of 100 // DCHECK fails if |localTransformNode| is not equal to or a descendant of
90 // |ancestorTransformNode|. 101 // |ancestorTransformNode|.
91 // 102 //
92 //|mappingRect| is both input and output. 103 //|mappingRect| is both input and output.
(...skipping 23 matching lines...) Expand all
116 // This matrix may not be flattened. Since GeometryMapper only supports 127 // This matrix may not be flattened. Since GeometryMapper only supports
117 // flattened ancestor spaces, the returned matrix must be flattened to have 128 // flattened ancestor spaces, the returned matrix must be flattened to have
118 // the correct semantics (calling mapRect() on it implicitly applies 129 // the correct semantics (calling mapRect() on it implicitly applies
119 // flattening to the input; flattenTo2d() does it explicitly to tme matrix). 130 // flattening to the input; flattenTo2d() does it explicitly to tme matrix).
120 static const TransformationMatrix& localToAncestorMatrix( 131 static const TransformationMatrix& localToAncestorMatrix(
121 const TransformPaintPropertyNode* localTransformNode, 132 const TransformPaintPropertyNode* localTransformNode,
122 const TransformPaintPropertyNode* ancestorTransformNode); 133 const TransformPaintPropertyNode* ancestorTransformNode);
123 134
124 // Returns the "clip visual rect" between |localTransformState| and 135 // Returns the "clip visual rect" between |localTransformState| and
125 // |ancestorState|. See above for the definition of "clip visual rect". 136 // |ancestorState|. See above for the definition of "clip visual rect".
137 //
138 // The output FloatClipRect may contain false positives for rounded-ness
139 // if a rounded clip is clipped out, and overly conservative results
140 // in the presences of transforms.
126 static FloatClipRect localToAncestorClipRect( 141 static FloatClipRect localToAncestorClipRect(
127 const PropertyTreeState& localTransformState, 142 const PropertyTreeState& localTransformState,
128 const PropertyTreeState& ancestorState); 143 const PropertyTreeState& ancestorState);
129 144
130 // Like localToAncestorClipRect, except it can handle destination transform 145 // Like localToAncestorClipRect, except it can handle destination transform
131 // spaces which are not direct ancestors of the source transform space. 146 // spaces which are not direct ancestors of the source transform space.
147 //
148 // The output FloatClipRect may contain false positives for rounded-ness
149 // if a rounded clip is clipped out, and overly conservative results
150 // in the presences of transforms.
132 static const FloatClipRect& sourceToDestinationClipRect( 151 static const FloatClipRect& sourceToDestinationClipRect(
133 const PropertyTreeState& sourceState, 152 const PropertyTreeState& sourceState,
134 const PropertyTreeState& destinationState); 153 const PropertyTreeState& destinationState);
135 154
136 // Returns the lowest common ancestor in the paint property tree. 155 // Returns the lowest common ancestor in the paint property tree.
137 template <typename NodeType> 156 template <typename NodeType>
138 static PLATFORM_EXPORT const NodeType* lowestCommonAncestor(const NodeType*, 157 static PLATFORM_EXPORT const NodeType* lowestCommonAncestor(const NodeType*,
139 const NodeType*); 158 const NodeType*);
140 159
141 static void clearCache(); 160 static void clearCache();
142 161
143 private: 162 private:
144 // The internal methods do the same things as their public counterparts, but 163 // The internal methods do the same things as their public counterparts, but
145 // take an extra |success| parameter which indicates if the function is 164 // take an extra |success| parameter which indicates if the function is
146 // successful on return. See comments of the public functions for failure 165 // successful on return. See comments of the public functions for failure
147 // conditions. 166 // conditions.
148 167
149 static void sourceToDestinationVisualRectInternal( 168 static void sourceToDestinationVisualRectInternal(
150 const PropertyTreeState& sourceState, 169 const PropertyTreeState& sourceState,
151 const PropertyTreeState& destinationState, 170 const PropertyTreeState& destinationState,
152 FloatRect& mappingRect, 171 FloatClipRect& mappingRect,
153 bool& success); 172 bool& success);
154 173
155 static void localToAncestorVisualRectInternal( 174 static void localToAncestorVisualRectInternal(
156 const PropertyTreeState& localTransformState, 175 const PropertyTreeState& localTransformState,
157 const PropertyTreeState& ancestorState, 176 const PropertyTreeState& ancestorState,
158 FloatRect& mappingRect, 177 FloatClipRect& mappingRect,
159 bool& success); 178 bool& success);
160 179
161 static void localToAncestorRectInternal( 180 static void localToAncestorRectInternal(
162 const TransformPaintPropertyNode* localTransformNode, 181 const TransformPaintPropertyNode* localTransformNode,
163 const TransformPaintPropertyNode* ancestorTransformNode, 182 const TransformPaintPropertyNode* ancestorTransformNode,
164 FloatRect&, 183 FloatRect&,
165 bool& success); 184 bool& success);
166 185
167 static const TransformationMatrix& localToAncestorMatrixInternal( 186 static const TransformationMatrix& localToAncestorMatrixInternal(
168 const TransformPaintPropertyNode* localTransformNode, 187 const TransformPaintPropertyNode* localTransformNode,
169 const TransformPaintPropertyNode* ancestorTransformNode, 188 const TransformPaintPropertyNode* ancestorTransformNode,
170 bool& success); 189 bool& success);
171 190
172 static const FloatClipRect& localToAncestorClipRectInternal( 191 static const FloatClipRect& localToAncestorClipRectInternal(
173 const ClipPaintPropertyNode* descendant, 192 const ClipPaintPropertyNode* descendant,
174 const ClipPaintPropertyNode* ancestorClip, 193 const ClipPaintPropertyNode* ancestorClip,
175 const TransformPaintPropertyNode* ancestorTransform, 194 const TransformPaintPropertyNode* ancestorTransform,
176 bool& success); 195 bool& success);
177 196
178 static const FloatClipRect& sourceToDestinationClipRectInternal( 197 static const FloatClipRect& sourceToDestinationClipRectInternal(
179 const PropertyTreeState& sourceState, 198 const PropertyTreeState& sourceState,
180 const PropertyTreeState& destinationState, 199 const PropertyTreeState& destinationState,
181 bool& success); 200 bool& success);
182 201
183 static void slowLocalToAncestorVisualRectWithEffects( 202 static void slowLocalToAncestorVisualRectWithEffects(
184 const PropertyTreeState& localState, 203 const PropertyTreeState& localState,
185 const PropertyTreeState& ancestorState, 204 const PropertyTreeState& ancestorState,
186 FloatRect& mappingRect, 205 FloatClipRect& mappingRect,
187 bool& success); 206 bool& success);
188 207
189 static const TransformationMatrix& identityMatrix(); 208 static const TransformationMatrix& identityMatrix();
190 static const FloatClipRect& infiniteClip(); 209 static const FloatClipRect& infiniteClip();
191 static FloatClipRect& tempRect(); 210 static FloatClipRect& tempRect();
192 211
193 friend class GeometryMapperTest; 212 friend class GeometryMapperTest;
194 friend class PaintLayerClipperTest; 213 friend class PaintLayerClipperTest;
195 }; 214 };
196 215
197 } // namespace blink 216 } // namespace blink
198 217
199 #endif // GeometryMapper_h 218 #endif // GeometryMapper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698