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

Side by Side Diff: include/core/SkPathRef.h

Issue 1261773002: change getBounds to return 0000 iff there are zero points (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 | « include/core/SkPath.h ('k') | tests/PathTest.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 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #ifndef SkPathRef_DEFINED 9 #ifndef SkPathRef_DEFINED
10 #define SkPathRef_DEFINED 10 #define SkPathRef_DEFINED
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 fSegmentMask = 0; 271 fSegmentMask = 0;
272 fIsOval = false; 272 fIsOval = false;
273 SkDEBUGCODE(fEditorsAttached = 0;) 273 SkDEBUGCODE(fEditorsAttached = 0;)
274 SkDEBUGCODE(this->validate();) 274 SkDEBUGCODE(this->validate();)
275 } 275 }
276 276
277 void copy(const SkPathRef& ref, int additionalReserveVerbs, int additionalRe servePoints); 277 void copy(const SkPathRef& ref, int additionalReserveVerbs, int additionalRe servePoints);
278 278
279 // Return true if the computed bounds are finite. 279 // Return true if the computed bounds are finite.
280 static bool ComputePtBounds(SkRect* bounds, const SkPathRef& ref) { 280 static bool ComputePtBounds(SkRect* bounds, const SkPathRef& ref) {
281 int count = ref.countPoints(); 281 return bounds->setBoundsCheck(ref.points(), ref.countPoints());
282 if (count <= 1) { // we ignore just 1 point (moveto)
283 bounds->setEmpty();
284 return count ? ref.points()->isFinite() : true;
285 } else {
286 return bounds->setBoundsCheck(ref.points(), count);
287 }
288 } 282 }
289 283
290 // called, if dirty, by getBounds() 284 // called, if dirty, by getBounds()
291 void computeBounds() const { 285 void computeBounds() const {
292 SkDEBUGCODE(this->validate();) 286 SkDEBUGCODE(this->validate();)
293 // TODO(mtklein): remove fBoundsIsDirty and fIsFinite, 287 // TODO(mtklein): remove fBoundsIsDirty and fIsFinite,
294 // using an inverted rect instead of fBoundsIsDirty and always recalcula ting fIsFinite. 288 // using an inverted rect instead of fBoundsIsDirty and always recalcula ting fIsFinite.
295 SkASSERT(fBoundsIsDirty); 289 SkASSERT(fBoundsIsDirty);
296 290
297 fIsFinite = ComputePtBounds(&fBounds, *this); 291 fIsFinite = ComputePtBounds(&fBounds, *this);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 kEmptyGenID = 1, // GenID reserved for path ref with zero points and zer o verbs. 444 kEmptyGenID = 1, // GenID reserved for path ref with zero points and zer o verbs.
451 }; 445 };
452 mutable uint32_t fGenerationID; 446 mutable uint32_t fGenerationID;
453 SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use at any time. 447 SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use at any time.
454 448
455 friend class PathRefTest_Private; 449 friend class PathRefTest_Private;
456 typedef SkRefCnt INHERITED; 450 typedef SkRefCnt INHERITED;
457 }; 451 };
458 452
459 #endif 453 #endif
OLDNEW
« no previous file with comments | « include/core/SkPath.h ('k') | tests/PathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698