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

Side by Side Diff: src/gpu/GrShape.h

Issue 2085913003: Canonicalize path fill types for stroked paths in GrShape. (Closed) Base URL: https://chromium.googlesource.com/skia.git@canonicalize_paths
Patch Set: minor cleanup 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
« no previous file with comments | « no previous file | src/gpu/GrShape.cpp » ('j') | src/gpu/GrShape.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrShape_DEFINED 8 #ifndef GrShape_DEFINED
9 #define GrShape_DEFINED 9 #define GrShape_DEFINED
10 10
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 void asPath(SkPath* out) const { 183 void asPath(SkPath* out) const {
184 switch (fType) { 184 switch (fType) {
185 case Type::kEmpty: 185 case Type::kEmpty:
186 out->reset(); 186 out->reset();
187 break; 187 break;
188 case Type::kRRect: 188 case Type::kRRect:
189 out->reset(); 189 out->reset();
190 out->addRRect(fRRect, fRRectDir, fRRectStart); 190 out->addRRect(fRRect, fRRectDir, fRRectStart);
191 // Below matches the fill type that attemptToSimplifyPath uses. 191 // Below matches the fill type that attemptToSimplifyPath uses.
192 if (fRRectIsInverted) { 192 if (fRRectIsInverted) {
193 out->setFillType(SkPath::kInverseEvenOdd_FillType); 193 out->setFillType(kDefaultPathInverseFillType);
194 } else { 194 } else {
195 out->setFillType(SkPath::kEvenOdd_FillType); 195 out->setFillType(kDefaultPathFillType);
196 } 196 }
197 break; 197 break;
198 case Type::kPath: 198 case Type::kPath:
199 *out = *fPath.get(); 199 *out = *fPath.get();
200 break; 200 break;
201 } 201 }
202 } 202 }
203 203
204 /** 204 /**
205 * Returns whether the geometry is empty. Note that applying the style could produce a 205 * Returns whether the geometry is empty. Note that applying the style could produce a
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 277
278 /** 278 /**
279 * Determines the key we should inherit from the input shape's geometry and style when 279 * Determines the key we should inherit from the input shape's geometry and style when
280 * we are applying the style to create a new shape. 280 * we are applying the style to create a new shape.
281 */ 281 */
282 void setInheritedKey(const GrShape& parentShape, GrStyle::Apply, SkScalar sc ale); 282 void setInheritedKey(const GrShape& parentShape, GrStyle::Apply, SkScalar sc ale);
283 283
284 void attemptToSimplifyPath(); 284 void attemptToSimplifyPath();
285 void attemptToSimplifyRRect(); 285 void attemptToSimplifyRRect();
286 286
287 // Defaults to use when there is no distinction between even/odd and winding fills.
288 static constexpr SkPath::FillType kDefaultPathFillType = SkPath::kEvenOdd_Fi llType;
289 static constexpr SkPath::FillType kDefaultPathInverseFillType =
290 SkPath::kInverseEvenOdd_FillType;
291
287 static constexpr SkPath::Direction kDefaultRRectDir = SkPath::kCW_Direction; 292 static constexpr SkPath::Direction kDefaultRRectDir = SkPath::kCW_Direction;
288 static constexpr unsigned kDefaultRRectStart = 0; 293 static constexpr unsigned kDefaultRRectStart = 0;
289 294
290 static unsigned DefaultRectDirAndStartIndex(const SkRect& rect, bool hasPath Effect, 295 static unsigned DefaultRectDirAndStartIndex(const SkRect& rect, bool hasPath Effect,
291 SkPath::Direction* dir) { 296 SkPath::Direction* dir) {
292 *dir = kDefaultRRectDir; 297 *dir = kDefaultRRectDir;
293 // This comes from SkPath's interface. The default for adding a SkRect i s counter clockwise 298 // This comes from SkPath's interface. The default for adding a SkRect i s counter clockwise
294 // beginning at index 0 (which happens to correspond to rrect index 0 or 7). 299 // beginning at index 0 (which happens to correspond to rrect index 0 or 7).
295 if (!hasPathEffect) { 300 if (!hasPathEffect) {
296 // It doesn't matter what start we use, just be consistent to avoid redundant keys. 301 // It doesn't matter what start we use, just be consistent to avoid redundant keys.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 SkPath::Direction fRRectDir; 339 SkPath::Direction fRRectDir;
335 unsigned fRRectStart; 340 unsigned fRRectStart;
336 bool fRRectIsInverted; 341 bool fRRectIsInverted;
337 SkTLazy<SkPath> fPath; 342 SkTLazy<SkPath> fPath;
338 // Gen ID of the original path (fPath may be modified) 343 // Gen ID of the original path (fPath may be modified)
339 int32_t fPathGenID = 0; 344 int32_t fPathGenID = 0;
340 GrStyle fStyle; 345 GrStyle fStyle;
341 SkAutoSTArray<8, uint32_t> fInheritedKey; 346 SkAutoSTArray<8, uint32_t> fInheritedKey;
342 }; 347 };
343 #endif 348 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrShape.cpp » ('j') | src/gpu/GrShape.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698