aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/GrResourceKey.h
diff options
context:
space:
mode:
authorGravatar senorblanco <senorblanco@chromium.org>2015-08-03 13:04:03 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-03 13:04:03 -0700
commit468dfa72eb6694145487be17876804dfca3b7adb (patch)
tree2cd289705ee10b6763616b593c6ba163fda3f43d /include/gpu/GrResourceKey.h
parent4dea94f621ee84c03535f07389fc0cb69a2a1eec (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/gpu/GrResourceKey.h')
-rw-r--r--include/gpu/GrResourceKey.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/gpu/GrResourceKey.h b/include/gpu/GrResourceKey.h
index a353dc2114..0a97c20b4d 100644
--- a/include/gpu/GrResourceKey.h
+++ b/include/gpu/GrResourceKey.h
@@ -10,6 +10,7 @@
#define GrResourceKey_DEFINED
#include "GrTypes.h"
+#include "SkData.h"
#include "SkOnce.h"
#include "SkTemplates.h"
@@ -237,6 +238,7 @@ public:
GrUniqueKey& operator=(const GrUniqueKey& that) {
this->INHERITED::operator=(that);
+ this->setCustomData(that.getCustomData());
return *this;
}
@@ -245,6 +247,14 @@ public:
}
bool operator!=(const GrUniqueKey& that) const { return !(*this == that); }
+ void setCustomData(const SkData* data) {
+ SkSafeRef(data);
+ fData.reset(data);
+ }
+ const SkData* getCustomData() const {
+ return fData.get();
+ }
+
class Builder : public INHERITED::Builder {
public:
Builder(GrUniqueKey* key, Domain domain, int data32Count)
@@ -268,6 +278,9 @@ public:
return SkToInt((innerKey.dataSize() >> 2) + 1);
}
};
+
+private:
+ SkAutoTUnref<const SkData> fData;
};
/**