OLD | NEW |
---|---|
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 | 173 |
174 static SkPathRef* CreateFromBuffer(SkRBuffer* buffer); | 174 static SkPathRef* CreateFromBuffer(SkRBuffer* buffer); |
175 | 175 |
176 /** | 176 /** |
177 * Rollsback a path ref to zero verbs and points with the assumption that th e path ref will be | 177 * Rollsback a path ref to zero verbs and points with the assumption that th e path ref will be |
178 * repopulated with approximately the same number of verbs and points. A new path ref is created | 178 * repopulated with approximately the same number of verbs and points. A new path ref is created |
179 * only if necessary. | 179 * only if necessary. |
180 */ | 180 */ |
181 static void Rewind(SkAutoTUnref<SkPathRef>* pathRef); | 181 static void Rewind(SkAutoTUnref<SkPathRef>* pathRef); |
182 | 182 |
183 virtual ~SkPathRef() { | 183 virtual ~SkPathRef(); |
184 SkDEBUGCODE(this->validate();) | |
185 sk_free(fPoints); | |
186 | |
187 SkDEBUGCODE(fPoints = NULL;) | |
188 SkDEBUGCODE(fVerbs = NULL;) | |
189 SkDEBUGCODE(fVerbCnt = 0x9999999;) | |
190 SkDEBUGCODE(fPointCnt = 0xAAAAAAA;) | |
191 SkDEBUGCODE(fPointCnt = 0xBBBBBBB;) | |
192 SkDEBUGCODE(fGenerationID = 0xEEEEEEEE;) | |
193 SkDEBUGCODE(fEditorsAttached = 0x7777777;) | |
194 } | |
195 | |
196 int countPoints() const { SkDEBUGCODE(this->validate();) return fPointCnt; } | 184 int countPoints() const { SkDEBUGCODE(this->validate();) return fPointCnt; } |
197 int countVerbs() const { SkDEBUGCODE(this->validate();) return fVerbCnt; } | 185 int countVerbs() const { SkDEBUGCODE(this->validate();) return fVerbCnt; } |
198 int countWeights() const { SkDEBUGCODE(this->validate();) return fConicWeigh ts.count(); } | 186 int countWeights() const { SkDEBUGCODE(this->validate();) return fConicWeigh ts.count(); } |
199 | 187 |
200 /** | 188 /** |
201 * Returns a pointer one beyond the first logical verb (last verb in memory order). | 189 * Returns a pointer one beyond the first logical verb (last verb in memory order). |
202 */ | 190 */ |
203 const uint8_t* verbs() const { SkDEBUGCODE(this->validate();) return fVerbs; } | 191 const uint8_t* verbs() const { SkDEBUGCODE(this->validate();) return fVerbs; } |
204 | 192 |
205 /** | 193 /** |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 */ | 232 */ |
245 uint32_t writeSize() const; | 233 uint32_t writeSize() const; |
246 | 234 |
247 /** | 235 /** |
248 * Gets an ID that uniquely identifies the contents of the path ref. If two path refs have the | 236 * Gets an ID that uniquely identifies the contents of the path ref. If two path refs have the |
249 * same ID then they have the same verbs and points. However, two path refs may have the same | 237 * same ID then they have the same verbs and points. However, two path refs may have the same |
250 * contents but different genIDs. | 238 * contents but different genIDs. |
251 */ | 239 */ |
252 uint32_t genID() const; | 240 uint32_t genID() const; |
253 | 241 |
242 struct GenIDChangeListener { | |
243 virtual ~GenIDChangeListener() {} | |
244 virtual void onChange() = 0; | |
245 }; | |
246 | |
247 void addGenIDChangeListener(GenIDChangeListener* listener); | |
248 void removeGenIDChangeListener(GenIDChangeListener* listener); | |
reed1
2015/07/28 21:02:55
are there any callers for remove? we don't offer t
| |
249 | |
254 SkDEBUGCODE(void validate() const;) | 250 SkDEBUGCODE(void validate() const;) |
255 | 251 |
256 private: | 252 private: |
257 enum SerializationOffsets { | 253 enum SerializationOffsets { |
258 kIsFinite_SerializationShift = 25, // requires 1 bit | 254 kIsFinite_SerializationShift = 25, // requires 1 bit |
259 kIsOval_SerializationShift = 24, // requires 1 bit | 255 kIsOval_SerializationShift = 24, // requires 1 bit |
260 kSegmentMask_SerializationShift = 0 // requires 4 bits | 256 kSegmentMask_SerializationShift = 0 // requires 4 bits |
261 }; | 257 }; |
262 | 258 |
263 SkPathRef() { | 259 SkPathRef() { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 friend SkPathRef* sk_create_empty_pathref(); | 417 friend SkPathRef* sk_create_empty_pathref(); |
422 | 418 |
423 void setIsOval(bool isOval) { fIsOval = isOval; } | 419 void setIsOval(bool isOval) { fIsOval = isOval; } |
424 | 420 |
425 SkPoint* getPoints() { | 421 SkPoint* getPoints() { |
426 SkDEBUGCODE(this->validate();) | 422 SkDEBUGCODE(this->validate();) |
427 fIsOval = false; | 423 fIsOval = false; |
428 return fPoints; | 424 return fPoints; |
429 } | 425 } |
430 | 426 |
427 void callGenIDChangeListeners(); | |
428 | |
431 enum { | 429 enum { |
432 kMinSize = 256, | 430 kMinSize = 256, |
433 }; | 431 }; |
434 | 432 |
435 mutable SkRect fBounds; | 433 mutable SkRect fBounds; |
436 mutable uint8_t fBoundsIsDirty; | 434 mutable uint8_t fBoundsIsDirty; |
437 mutable SkBool8 fIsFinite; // only meaningful if bounds are valid | 435 mutable SkBool8 fIsFinite; // only meaningful if bounds are valid |
438 | 436 |
439 SkBool8 fIsOval; | 437 SkBool8 fIsOval; |
440 uint8_t fSegmentMask; | 438 uint8_t fSegmentMask; |
441 | 439 |
442 SkPoint* fPoints; // points to begining of the allocation | 440 SkPoint* fPoints; // points to begining of the allocation |
443 uint8_t* fVerbs; // points just past the end of the allocation (v erbs grow backwards) | 441 uint8_t* fVerbs; // points just past the end of the allocation (v erbs grow backwards) |
444 int fVerbCnt; | 442 int fVerbCnt; |
445 int fPointCnt; | 443 int fPointCnt; |
446 size_t fFreeSpace; // redundant but saves computation | 444 size_t fFreeSpace; // redundant but saves computation |
447 SkTDArray<SkScalar> fConicWeights; | 445 SkTDArray<SkScalar> fConicWeights; |
448 | 446 |
449 enum { | 447 enum { |
450 kEmptyGenID = 1, // GenID reserved for path ref with zero points and zer o verbs. | 448 kEmptyGenID = 1, // GenID reserved for path ref with zero points and zer o verbs. |
451 }; | 449 }; |
452 mutable uint32_t fGenerationID; | 450 mutable uint32_t fGenerationID; |
453 SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use at any time. | 451 SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use at any time. |
454 | 452 |
453 SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owne d | |
454 | |
455 friend class PathRefTest_Private; | 455 friend class PathRefTest_Private; |
456 typedef SkRefCnt INHERITED; | 456 typedef SkRefCnt INHERITED; |
457 }; | 457 }; |
458 | 458 |
459 #endif | 459 #endif |
OLD | NEW |