| Index: src/core/SkPathRef.cpp
|
| diff --git a/src/core/SkPathRef.cpp b/src/core/SkPathRef.cpp
|
| index 44838f924637ff144a83aa86ac3aaf90f89d76fa..4017c531658304ed319da4e0895ab7c8c03eaad6 100644
|
| --- a/src/core/SkPathRef.cpp
|
| +++ b/src/core/SkPathRef.cpp
|
| @@ -23,12 +23,27 @@ SkPathRef::Editor::Editor(SkAutoTUnref<SkPathRef>* pathRef,
|
| pathRef->reset(copy);
|
| }
|
| fPathRef = *pathRef;
|
| + fPathRef->callGenIDChangeListeners();
|
| fPathRef->fGenerationID = 0;
|
| SkDEBUGCODE(sk_atomic_inc(&fPathRef->fEditorsAttached);)
|
| }
|
|
|
| //////////////////////////////////////////////////////////////////////////////
|
|
|
| +SkPathRef::~SkPathRef() {
|
| + this->callGenIDChangeListeners();
|
| + SkDEBUGCODE(this->validate();)
|
| + sk_free(fPoints);
|
| +
|
| + SkDEBUGCODE(fPoints = NULL;)
|
| + SkDEBUGCODE(fVerbs = NULL;)
|
| + SkDEBUGCODE(fVerbCnt = 0x9999999;)
|
| + SkDEBUGCODE(fPointCnt = 0xAAAAAAA;)
|
| + SkDEBUGCODE(fPointCnt = 0xBBBBBBB;)
|
| + SkDEBUGCODE(fGenerationID = 0xEEEEEEEE;)
|
| + SkDEBUGCODE(fEditorsAttached = 0x7777777;)
|
| +}
|
| +
|
| // As a template argument, this must have external linkage.
|
| SkPathRef* sk_create_empty_pathref() {
|
| SkPathRef* empty = SkNEW(SkPathRef);
|
| @@ -154,6 +169,7 @@ SkPathRef* SkPathRef::CreateFromBuffer(SkRBuffer* buffer) {
|
| void SkPathRef::Rewind(SkAutoTUnref<SkPathRef>* pathRef) {
|
| if ((*pathRef)->unique()) {
|
| SkDEBUGCODE((*pathRef)->validate();)
|
| + (*pathRef)->callGenIDChangeListeners();
|
| (*pathRef)->fBoundsIsDirty = true; // this also invalidates fIsFinite
|
| (*pathRef)->fVerbCnt = 0;
|
| (*pathRef)->fPointCnt = 0;
|
| @@ -436,6 +452,24 @@ uint32_t SkPathRef::genID() const {
|
| return fGenerationID;
|
| }
|
|
|
| +void SkPathRef::addGenIDChangeListener(GenIDChangeListener* listener) {
|
| + if (NULL == listener || this == empty.get()) {
|
| + SkDELETE(listener);
|
| + return;
|
| + }
|
| + *fGenIDChangeListeners.append() = listener;
|
| +}
|
| +
|
| +// we need to be called *before* the genID gets changed or zerod
|
| +void SkPathRef::callGenIDChangeListeners() {
|
| + for (int i = 0; i < fGenIDChangeListeners.count(); i++) {
|
| + fGenIDChangeListeners[i]->onChange();
|
| + }
|
| +
|
| + // Listeners get at most one shot, so whether these triggered or not, blow them away.
|
| + fGenIDChangeListeners.deleteAll();
|
| +}
|
| +
|
| #ifdef SK_DEBUG
|
| void SkPathRef::validate() const {
|
| this->INHERITED::validate();
|
|
|