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

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

Issue 49693002: Use SkPathRef gen id for SkPath::getGenerationID (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: cleanup Created 7 years, 1 month 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
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 /** 220 /**
221 * Writes the path points and verbs to a buffer. 221 * Writes the path points and verbs to a buffer.
222 */ 222 */
223 void writeToBuffer(SkWBuffer* buffer); 223 void writeToBuffer(SkWBuffer* buffer);
224 224
225 /** 225 /**
226 * Gets the number of bytes that would be written in writeBuffer() 226 * Gets the number of bytes that would be written in writeBuffer()
227 */ 227 */
228 uint32_t writeSize(); 228 uint32_t writeSize();
229 229
230 /**
231 * Gets an ID that uniquely identifies the contents of the path ref. If two path refs have the
232 * same ID then they have the same verbs and points. However, two path refs may have the same
233 * contents but different genIDs. Zero is reserved and means an ID has not y et been determined
mtklein 2013/10/29 20:38:36 We don't ever return 0 here do we? Do we need to
bsalomon 2013/10/29 20:45:04 good point, done.
234 * for the path ref.
235 */
236 uint32_t genID() const;
237
230 private: 238 private:
231 enum SerializationOffsets { 239 enum SerializationOffsets {
232 kIsFinite_SerializationShift = 25, // requires 1 bit 240 kIsFinite_SerializationShift = 25, // requires 1 bit
233 }; 241 };
234 242
235 SkPathRef() { 243 SkPathRef() {
236 fBoundsIsDirty = true; // this also invalidates fIsFinite 244 fBoundsIsDirty = true; // this also invalidates fIsFinite
237 fPointCnt = 0; 245 fPointCnt = 0;
238 fVerbCnt = 0; 246 fVerbCnt = 0;
239 fVerbs = NULL; 247 fVerbs = NULL;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 return fVerbs - fVerbCnt; 381 return fVerbs - fVerbCnt;
374 } 382 }
375 383
376 /** 384 /**
377 * Gets the total amount of space allocated for verbs, points, and reserve. 385 * Gets the total amount of space allocated for verbs, points, and reserve.
378 */ 386 */
379 size_t currSize() const { 387 size_t currSize() const {
380 return reinterpret_cast<intptr_t>(fVerbs) - reinterpret_cast<intptr_t>(f Points); 388 return reinterpret_cast<intptr_t>(fVerbs) - reinterpret_cast<intptr_t>(f Points);
381 } 389 }
382 390
383 /**
384 * Gets an ID that uniquely identifies the contents of the path ref. If two path refs have the
385 * same ID then they have the same verbs and points. However, two path refs may have the same
386 * contents but different genIDs. Zero is reserved and means an ID has not y et been determined
387 * for the path ref.
388 */
389 int32_t genID() const;
390
391 SkDEBUGCODE(void validate() const;) 391 SkDEBUGCODE(void validate() const;)
392 392
393 /** 393 /**
394 * Called the first time someone calls CreateEmpty to actually create the si ngleton. 394 * Called the first time someone calls CreateEmpty to actually create the si ngleton.
395 */ 395 */
396 static void CreateEmptyImpl(SkPathRef** empty); 396 static void CreateEmptyImpl(SkPathRef** empty);
397 397
398 enum { 398 enum {
399 kMinSize = 256, 399 kMinSize = 256,
400 }; 400 };
401 401
402 mutable SkRect fBounds; 402 mutable SkRect fBounds;
403 mutable uint8_t fBoundsIsDirty; 403 mutable uint8_t fBoundsIsDirty;
404 mutable SkBool8 fIsFinite; // only meaningful if bounds are valid 404 mutable SkBool8 fIsFinite; // only meaningful if bounds are valid
405 405
406 SkPoint* fPoints; // points to begining of the allocation 406 SkPoint* fPoints; // points to begining of the allocation
407 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)
408 int fVerbCnt; 408 int fVerbCnt;
409 int fPointCnt; 409 int fPointCnt;
410 size_t fFreeSpace; // redundant but saves computation 410 size_t fFreeSpace; // redundant but saves computation
411 SkTDArray<SkScalar> fConicWeights; 411 SkTDArray<SkScalar> fConicWeights;
412 412
413 enum { 413 enum {
414 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.
415 }; 415 };
416 mutable int32_t fGenerationID; 416 mutable uint32_t fGenerationID;
417 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.
418 418
419 typedef SkRefCnt INHERITED; 419 typedef SkRefCnt INHERITED;
420 }; 420 };
421 421
422 #endif 422 #endif
OLDNEW
« no previous file with comments | « include/core/SkPath.h ('k') | src/core/SkPath.cpp » ('j') | src/core/SkPath.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698