aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-01 15:23:44 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-01 15:23:44 +0000
commit5c8ee2539b9316b22416a991a1f560ef5cec7957 (patch)
treeebd654235f81028533a630e9ae35617c03b78cb6 /include
parente1e99ef0af69fef21f2897621e7dfc5257da7ce7 (diff)
Make GrContext cache the gpu paths
Creating paths for nv_path_rendering is costly. Try to reduce this cost by caching paths based on the SkPath "hash" (i.e. SkPathRef generation id) and stroke properties. Adds the paths to GrContext::fTextureCache instance. Later this should be renamed and the GrContext API should reflect the nature of the cache better. R=bsalomon@google.com, mtklein@google.com Author: kkinnunen@nvidia.com Review URL: https://codereview.chromium.org/26557003 git-svn-id: http://skia.googlecode.com/svn/trunk@12083 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r--include/core/SkStrokeRec.h8
-rw-r--r--include/gpu/GrContext.h11
2 files changed, 19 insertions, 0 deletions
diff --git a/include/core/SkStrokeRec.h b/include/core/SkStrokeRec.h
index c5b47c25dd..1e0ec880f7 100644
--- a/include/core/SkStrokeRec.h
+++ b/include/core/SkStrokeRec.h
@@ -81,6 +81,14 @@ public:
*/
bool applyToPath(SkPath* dst, const SkPath& src) const;
+ bool operator==(const SkStrokeRec& other) const {
+ return fWidth == other.fWidth &&
+ fMiterLimit == other.fMiterLimit &&
+ fCap == other.fCap &&
+ fJoin == other.fJoin &&
+ fStrokeAndFill == other.fStrokeAndFill;
+ }
+
private:
SkScalar fWidth;
SkScalar fMiterLimit;
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index ba3e53a48f..f302a44808 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -29,6 +29,7 @@ class GrIndexBuffer;
class GrIndexBufferAllocPool;
class GrInOrderDrawBuffer;
class GrOvalRenderer;
+class GrPath;
class GrPathRenderer;
class GrResourceEntry;
class GrResourceCache;
@@ -925,6 +926,7 @@ private:
// Needed so GrTexture's returnToCache helper function can call
// addExistingTextureToCache
friend class GrTexture;
+ friend class GrStencilAndCoverPathRenderer;
// Add an existing texture to the texture cache. This is intended solely
// for use with textures released from an GrAutoScratchTexture.
@@ -948,6 +950,15 @@ private:
*/
static bool OverbudgetCB(void* data);
+ /** Creates a new gpu path, based on the specified path and stroke and returns it.
+ * The caller owns a ref on the returned path which must be balanced by a call to unref.
+ *
+ * @param skPath the path geometry.
+ * @param stroke the path stroke.
+ * @return a new path or NULL if the operation is not supported by the backend.
+ */
+ GrPath* createPath(const SkPath& skPath, const SkStrokeRec& stroke);
+
typedef SkRefCnt INHERITED;
};