diff options
author | 2013-11-01 15:23:44 +0000 | |
---|---|---|
committer | 2013-11-01 15:23:44 +0000 | |
commit | 5c8ee2539b9316b22416a991a1f560ef5cec7957 (patch) | |
tree | ebd654235f81028533a630e9ae35617c03b78cb6 /src/gpu/GrPath.cpp | |
parent | e1e99ef0af69fef21f2897621e7dfc5257da7ce7 (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.cpp')
-rw-r--r-- | src/gpu/GrPath.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/gpu/GrPath.cpp b/src/gpu/GrPath.cpp index afd223902f..f928dffaa8 100644 --- a/src/gpu/GrPath.cpp +++ b/src/gpu/GrPath.cpp @@ -8,3 +8,26 @@ #include "GrPath.h" SK_DEFINE_INST_COUNT(GrPath) + +GrResourceKey GrPath::ComputeKey(const SkPath& path, const SkStrokeRec& stroke) { + static const GrResourceKey::ResourceType gPathResourceType = GrResourceKey::GenerateResourceType(); + static const GrCacheID::Domain gPathDomain = GrCacheID::GenerateDomain(); + + GrCacheID::Key key; + uint32_t* keyData = key.fData32; + keyData[0] = path.getGenerationID(); + + SK_COMPILE_ASSERT(SkPaint::kJoinCount <= 3, cap_shift_will_be_wrong); + keyData[1] = stroke.needToApply(); + if (0 != keyData[1]) { + keyData[1] |= stroke.getJoin() << 1; + keyData[1] |= stroke.getCap() << 3; + keyData[2] = static_cast<uint32_t>(stroke.getMiter()); + keyData[3] = static_cast<uint32_t>(stroke.getWidth()); + } else { + keyData[2] = 0; + keyData[3] = 0; + } + + return GrResourceKey(GrCacheID(gPathDomain, key), gPathResourceType, 0); +} |