aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrPath.h
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 /src/gpu/GrPath.h
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 'src/gpu/GrPath.h')
-rw-r--r--src/gpu/GrPath.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/gpu/GrPath.h b/src/gpu/GrPath.h
index 37dc9591a6..f481ea4286 100644
--- a/src/gpu/GrPath.h
+++ b/src/gpu/GrPath.h
@@ -9,6 +9,8 @@
#define GrPath_DEFINED
#include "GrResource.h"
+#include "GrResourceCache.h"
+#include "SkPath.h"
#include "SkRect.h"
#include "SkStrokeRec.h"
@@ -16,9 +18,17 @@ class GrPath : public GrResource {
public:
SK_DECLARE_INST_COUNT(GrPath);
- GrPath(GrGpu* gpu, bool isWrapped, const SkStrokeRec& stroke)
+ GrPath(GrGpu* gpu, bool isWrapped, const SkPath& skPath, const SkStrokeRec& stroke)
: INHERITED(gpu, isWrapped),
- fStroke(stroke) {
+ fSkPath(skPath),
+ fStroke(stroke),
+ fBounds(skPath.getBounds()) {
+ }
+
+ static GrResourceKey ComputeKey(const SkPath& path, const SkStrokeRec& stroke);
+
+ bool isEqualTo(const SkPath& path, const SkStrokeRec& stroke) {
+ return fSkPath == path && fStroke == stroke;
}
const SkRect& getBounds() const { return fBounds; }
@@ -26,8 +36,9 @@ public:
const SkStrokeRec& getStroke() const { return fStroke; }
protected:
- SkRect fBounds;
+ SkPath fSkPath;
SkStrokeRec fStroke;
+ SkRect fBounds;
private:
typedef GrResource INHERITED;