Index: src/gpu/GrPath.cpp |
diff --git a/src/gpu/GrPath.cpp b/src/gpu/GrPath.cpp |
index afd223902fd440b0864839c3e9ecfe828d9d19fc..f928dffaa85c950a234dd23c9992937a98f12933 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); |
+} |