diff options
author | senorblanco <senorblanco@chromium.org> | 2015-08-03 13:04:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-03 13:04:03 -0700 |
commit | 468dfa72eb6694145487be17876804dfca3b7adb (patch) | |
tree | 2cd289705ee10b6763616b593c6ba163fda3f43d /include/core/SkPathRef.h | |
parent | 4dea94f621ee84c03535f07389fc0cb69a2a1eec (diff) |
Implement caching of filled paths in the tessellated path renderer.
Paths are cached as tessellated triangle meshes in vertex buffers on the GPU. Stroked paths are not (yet) cached.
Paths containing no curved segments (linear paths) are reused at all scales. Paths containing curved segments are reused within a scale tolerance threshold.
In order to invalidate the cache when an SkPath is changed or deleted,
this required implementing genID change notification in SkPath. This is
modelled almost exactly on SkPixelRef::GenIDChangeListener.
However, It does not currently implement the check for unique genIDs,
so notifiers will fire when the first instance of an SkPathRef
using a given genID is destroyed.
Another caveat is that you cannot successfully add a change notifier
to an empty path, since it uses the "canonical" empty path which is
never modified or destroyed. For this reason, we prevent adding
listeners to it.
BUG=skia:4121,skia:4122, 497403
DOCS_PREVIEW= https://skia.org/?cl=1114353004
Review URL: https://codereview.chromium.org/1114353004
Diffstat (limited to 'include/core/SkPathRef.h')
-rw-r--r-- | include/core/SkPathRef.h | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/include/core/SkPathRef.h b/include/core/SkPathRef.h index e7cc31cff4..c09f6e87e4 100644 --- a/include/core/SkPathRef.h +++ b/include/core/SkPathRef.h @@ -180,19 +180,7 @@ public: */ static void Rewind(SkAutoTUnref<SkPathRef>* pathRef); - virtual ~SkPathRef() { - 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;) - } - + virtual ~SkPathRef(); int countPoints() const { SkDEBUGCODE(this->validate();) return fPointCnt; } int countVerbs() const { SkDEBUGCODE(this->validate();) return fVerbCnt; } int countWeights() const { SkDEBUGCODE(this->validate();) return fConicWeights.count(); } @@ -251,6 +239,13 @@ public: */ uint32_t genID() const; + struct GenIDChangeListener { + virtual ~GenIDChangeListener() {} + virtual void onChange() = 0; + }; + + void addGenIDChangeListener(GenIDChangeListener* listener); + SkDEBUGCODE(void validate() const;) private: @@ -422,6 +417,8 @@ private: return fPoints; } + void callGenIDChangeListeners(); + enum { kMinSize = 256, }; @@ -446,6 +443,8 @@ private: mutable uint32_t fGenerationID; SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use at any time. + SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owned + friend class PathRefTest_Private; typedef SkRefCnt INHERITED; }; |