Chromium Code Reviews| Index: src/gpu/GrPath.cpp |
| diff --git a/src/gpu/GrPath.cpp b/src/gpu/GrPath.cpp |
| index 3a66865c6e5d3448eaeaefce22db731364340519..710a2d585a8567c892055db3898fae8d3cabd64c 100644 |
| --- a/src/gpu/GrPath.cpp |
| +++ b/src/gpu/GrPath.cpp |
| @@ -13,14 +13,14 @@ template<int NumBits> static uint64_t get_top_n_float_bits(float f) { |
| return floatBits >> (32 - NumBits); |
| } |
| -void GrPath::ComputeKey(const SkPath& path, const SkStrokeRec& stroke, GrUniqueKey* key) { |
| +void GrPath::ComputeKey(const SkPath& path, const GrStrokeInfo& stroke, GrUniqueKey* key) { |
| static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); |
| GrUniqueKey::Builder builder(key, kDomain, 3); |
| *reinterpret_cast<uint64_t*>(&builder[0]) = ComputeStrokeKey(stroke); |
| builder[2] = path.getGenerationID(); |
| } |
| -uint64_t GrPath::ComputeStrokeKey(const SkStrokeRec& stroke) { |
| +uint64_t GrPath::ComputeStrokeKey(const GrStrokeInfo& stroke) { |
| enum { |
| kStyleBits = 2, |
| kJoinBits = 2, |
| @@ -40,16 +40,24 @@ uint64_t GrPath::ComputeStrokeKey(const SkStrokeRec& stroke) { |
| SK_COMPILE_ASSERT(SkPaint::kJoinCount <= (1 << kJoinBits), cap_shift_will_be_wrong); |
| SK_COMPILE_ASSERT(SkPaint::kCapCount <= (1 << kCapBits), miter_shift_will_be_wrong); |
| SK_COMPILE_ASSERT(kBitCount == 64, wrong_stroke_key_size); |
| - |
| - if (!stroke.needToApply()) { |
| - return SkStrokeRec::kFill_Style; |
| + const SkStrokeRec& strokeRec = stroke.getStrokeRec(); |
| + uint64_t key = strokeRec.getStyle(); |
| + if (strokeRec.needToApply()) { |
| + key |= strokeRec.getJoin() << kJoinShift; |
| + key |= strokeRec.getCap() << kCapShift; |
| + key |= get_top_n_float_bits<kWidthBits>(strokeRec.getWidth()) << kWidthShift; |
| + key |= get_top_n_float_bits<kMiterBits>(strokeRec.getMiter()) << kMiterShift; |
| + } |
| + if (stroke.isDashed()) { |
| + int32_t count = stroke.getDashCount() & static_cast<int32_t>(~1); |
| + SkASSERT(count == stroke.getDashCount()); |
| + const SkScalar* intervals = stroke.getDashIntervals(); |
| + for (int i = 0; i < count; i += 2) { |
| + key ^= get_top_n_float_bits<32>(intervals[i]); |
|
egdaniel
2015/05/05 19:48:44
So this doesn't seem like it will give a unique ke
Kimmo Kinnunen
2015/05/06 08:30:25
Done.
|
| + key ^= get_top_n_float_bits<32>(intervals[i + 1]) << 32; |
| + } |
| + key ^= get_top_n_float_bits<32>(stroke.getDashPhase()); |
| + key ^= static_cast<uint64_t>(count) << 32; |
| } |
| - |
| - uint64_t key = stroke.getStyle(); |
| - key |= stroke.getJoin() << kJoinShift; |
| - key |= stroke.getCap() << kCapShift; |
| - key |= get_top_n_float_bits<kWidthBits>(stroke.getWidth()) << kWidthShift; |
| - key |= get_top_n_float_bits<kMiterBits>(stroke.getMiter()) << kMiterShift; |
| - |
| return key; |
| } |