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

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: upload again, rietveld diff failed. 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
« no previous file with comments | « include/core/SkPath.h ('k') | src/core/SkPath.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 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.
234 */
235 uint32_t genID() const;
236
230 private: 237 private:
231 enum SerializationOffsets { 238 enum SerializationOffsets {
232 kIsFinite_SerializationShift = 25, // requires 1 bit 239 kIsFinite_SerializationShift = 25, // requires 1 bit
233 }; 240 };
234 241
235 SkPathRef() { 242 SkPathRef() {
236 fBoundsIsDirty = true; // this also invalidates fIsFinite 243 fBoundsIsDirty = true; // this also invalidates fIsFinite
237 fPointCnt = 0; 244 fPointCnt = 0;
238 fVerbCnt = 0; 245 fVerbCnt = 0;
239 fVerbs = NULL; 246 fVerbs = NULL;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 return fVerbs - fVerbCnt; 380 return fVerbs - fVerbCnt;
374 } 381 }
375 382
376 /** 383 /**
377 * Gets the total amount of space allocated for verbs, points, and reserve. 384 * Gets the total amount of space allocated for verbs, points, and reserve.
378 */ 385 */
379 size_t currSize() const { 386 size_t currSize() const {
380 return reinterpret_cast<intptr_t>(fVerbs) - reinterpret_cast<intptr_t>(f Points); 387 return reinterpret_cast<intptr_t>(fVerbs) - reinterpret_cast<intptr_t>(f Points);
381 } 388 }
382 389
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;) 390 SkDEBUGCODE(void validate() const;)
392 391
393 /** 392 /**
394 * Called the first time someone calls CreateEmpty to actually create the si ngleton. 393 * Called the first time someone calls CreateEmpty to actually create the si ngleton.
395 */ 394 */
396 static void CreateEmptyImpl(SkPathRef** empty); 395 static void CreateEmptyImpl(SkPathRef** empty);
397 396
398 enum { 397 enum {
399 kMinSize = 256, 398 kMinSize = 256,
400 }; 399 };
401 400
402 mutable SkRect fBounds; 401 mutable SkRect fBounds;
403 mutable uint8_t fBoundsIsDirty; 402 mutable uint8_t fBoundsIsDirty;
404 mutable SkBool8 fIsFinite; // only meaningful if bounds are valid 403 mutable SkBool8 fIsFinite; // only meaningful if bounds are valid
405 404
406 SkPoint* fPoints; // points to begining of the allocation 405 SkPoint* fPoints; // points to begining of the allocation
407 uint8_t* fVerbs; // points just past the end of the allocation (v erbs grow backwards) 406 uint8_t* fVerbs; // points just past the end of the allocation (v erbs grow backwards)
408 int fVerbCnt; 407 int fVerbCnt;
409 int fPointCnt; 408 int fPointCnt;
410 size_t fFreeSpace; // redundant but saves computation 409 size_t fFreeSpace; // redundant but saves computation
411 SkTDArray<SkScalar> fConicWeights; 410 SkTDArray<SkScalar> fConicWeights;
412 411
413 enum { 412 enum {
414 kEmptyGenID = 1, // GenID reserved for path ref with zero points and zer o verbs. 413 kEmptyGenID = 1, // GenID reserved for path ref with zero points and zer o verbs.
415 }; 414 };
416 mutable int32_t fGenerationID; 415 mutable uint32_t fGenerationID;
417 SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use at any time. 416 SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use at any time.
418 417
419 typedef SkRefCnt INHERITED; 418 typedef SkRefCnt INHERITED;
420 }; 419 };
421 420
422 #endif 421 #endif
OLDNEW
« no previous file with comments | « include/core/SkPath.h ('k') | src/core/SkPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698