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

Unified Diff: src/core/SkPathRef.cpp

Issue 1114353004: Implement vertex buffer caching in the tessellated path renderer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Merge resource cache fix, leak fix, inverse winding fix Created 5 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPathPriv.h ('k') | src/gpu/GrTessellatingPathRenderer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPathRef.cpp
diff --git a/src/core/SkPathRef.cpp b/src/core/SkPathRef.cpp
index 44838f924637ff144a83aa86ac3aaf90f89d76fa..38b4e71cba1d4479eba42c7846ba833f533d0965 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;
@@ -215,13 +231,6 @@ 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;
}
@@ -269,9 +278,6 @@ 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;
@@ -436,6 +442,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();
« no previous file with comments | « src/core/SkPathPriv.h ('k') | src/gpu/GrTessellatingPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698