Index: src/core/SkPathRef.cpp |
diff --git a/src/core/SkPathRef.cpp b/src/core/SkPathRef.cpp |
index 38b4e71cba1d4479eba42c7846ba833f533d0965..44838f924637ff144a83aa86ac3aaf90f89d76fa 100644 |
--- a/src/core/SkPathRef.cpp |
+++ b/src/core/SkPathRef.cpp |
@@ -23,27 +23,12 @@ 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); |
@@ -169,7 +154,6 @@ 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; |
@@ -231,6 +215,13 @@ bool SkPathRef::operator== (const SkPathRef& ref) const { |
SkASSERT(!genIDMatch); |
return false; |
} |
+ // We've done the work to determine that these are equal. If either has a zero genID, copy |
+ // the other's. If both are 0 then genID() will compute the next ID. |
+ if (0 == fGenerationID) { |
+ fGenerationID = ref.genID(); |
+ } else if (0 == ref.fGenerationID) { |
+ ref.fGenerationID = this->genID(); |
+ } |
return true; |
} |
@@ -278,6 +269,9 @@ void SkPathRef::copy(const SkPathRef& ref, |
memcpy(this->verbsMemWritable(), ref.verbsMemBegin(), ref.fVerbCnt * sizeof(uint8_t)); |
memcpy(this->fPoints, ref.fPoints, ref.fPointCnt * sizeof(SkPoint)); |
fConicWeights = ref.fConicWeights; |
+ // We could call genID() here to force a real ID (instead of 0). However, if we're making |
+ // a copy then presumably we intend to make a modification immediately afterwards. |
+ fGenerationID = ref.fGenerationID; |
fBoundsIsDirty = ref.fBoundsIsDirty; |
if (!fBoundsIsDirty) { |
fBounds = ref.fBounds; |
@@ -442,24 +436,6 @@ 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(); |