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

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: Integrated cache invalidation based on SkPath GenID change Created 5 years, 5 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
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();

Powered by Google App Engine
This is Rietveld 408576698