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

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

Issue 26491003: SK_ONCE for SkData (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: dropped assert Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkData.h ('k') | src/core/SkData.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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 SkPathRef* pathRef() { return fPathRef; } 101 SkPathRef* pathRef() { return fPathRef; }
102 102
103 private: 103 private:
104 SkPathRef* fPathRef; 104 SkPathRef* fPathRef;
105 }; 105 };
106 106
107 public: 107 public:
108 /** 108 /**
109 * Gets a path ref with no verbs or points. 109 * Gets a path ref with no verbs or points.
110 */ 110 */
111 static SkPathRef* CreateEmpty() { 111 static SkPathRef* CreateEmpty();
112 static SkPathRef* gEmptyPathRef;
113 if (!gEmptyPathRef) {
114 gEmptyPathRef = SkNEW(SkPathRef); // leak!
115 gEmptyPathRef->computeBounds(); // Premptively avoid a race to cle ar fBoundsIsDirty.
116 }
117 return SkRef(gEmptyPathRef);
118 }
119 112
120 /** 113 /**
121 * Returns true if all of the points in this path are finite, meaning there 114 * Returns true if all of the points in this path are finite, meaning there
122 * are no infinities and no NaNs. 115 * are no infinities and no NaNs.
123 */ 116 */
124 bool isFinite() const { 117 bool isFinite() const {
125 if (fBoundsIsDirty) { 118 if (fBoundsIsDirty) {
126 this->computeBounds(); 119 this->computeBounds();
127 } 120 }
128 return SkToBool(fIsFinite); 121 return SkToBool(fIsFinite);
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 /** 383 /**
391 * Gets an ID that uniquely identifies the contents of the path ref. If two path refs have the 384 * Gets an ID that uniquely identifies the contents of the path ref. If two path refs have the
392 * same ID then they have the same verbs and points. However, two path refs may have the same 385 * same ID then they have the same verbs and points. However, two path refs may have the same
393 * contents but different genIDs. Zero is reserved and means an ID has not y et been determined 386 * contents but different genIDs. Zero is reserved and means an ID has not y et been determined
394 * for the path ref. 387 * for the path ref.
395 */ 388 */
396 int32_t genID() const; 389 int32_t genID() const;
397 390
398 SkDEBUGCODE(void validate() const;) 391 SkDEBUGCODE(void validate() const;)
399 392
393 /**
394 * Called the first time someone calls CreateEmpty to actually create the si ngleton.
395 */
396 static void CreateEmptyImpl(SkPathRef** empty);
397
400 enum { 398 enum {
401 kMinSize = 256, 399 kMinSize = 256,
402 }; 400 };
403 401
404 mutable SkRect fBounds; 402 mutable SkRect fBounds;
405 mutable uint8_t fBoundsIsDirty; 403 mutable uint8_t fBoundsIsDirty;
406 mutable SkBool8 fIsFinite; // only meaningful if bounds are valid 404 mutable SkBool8 fIsFinite; // only meaningful if bounds are valid
407 405
408 SkPoint* fPoints; // points to begining of the allocation 406 SkPoint* fPoints; // points to begining of the allocation
409 uint8_t* fVerbs; // points just past the end of the allocation (v erbs grow backwards) 407 uint8_t* fVerbs; // points just past the end of the allocation (v erbs grow backwards)
410 int fVerbCnt; 408 int fVerbCnt;
411 int fPointCnt; 409 int fPointCnt;
412 size_t fFreeSpace; // redundant but saves computation 410 size_t fFreeSpace; // redundant but saves computation
413 SkTDArray<SkScalar> fConicWeights; 411 SkTDArray<SkScalar> fConicWeights;
414 412
415 enum { 413 enum {
416 kEmptyGenID = 1, // GenID reserved for path ref with zero points and zer o verbs. 414 kEmptyGenID = 1, // GenID reserved for path ref with zero points and zer o verbs.
417 }; 415 };
418 mutable int32_t fGenerationID; 416 mutable int32_t fGenerationID;
419 SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use at any time. 417 SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use at any time.
420 418
421 typedef SkRefCnt INHERITED; 419 typedef SkRefCnt INHERITED;
422 }; 420 };
423 421
424 #endif 422 #endif
OLDNEW
« no previous file with comments | « include/core/SkData.h ('k') | src/core/SkData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698