OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrPath.h" | 8 #include "GrPath.h" |
9 | 9 |
10 template<int NumBits> static uint64_t get_top_n_float_bits(float f) { | 10 template<int NumBits> static uint64_t get_top_n_float_bits(float f) { |
11 char* floatData = reinterpret_cast<char*>(&f); | 11 char* floatData = reinterpret_cast<char*>(&f); |
12 uint32_t floatBits = *reinterpret_cast<uint32_t*>(floatData); | 12 uint32_t floatBits = *reinterpret_cast<uint32_t*>(floatData); |
13 return floatBits >> (32 - NumBits); | 13 return floatBits >> (32 - NumBits); |
14 } | 14 } |
15 | 15 |
16 GrResourceKey GrPath::ComputeKey(const SkPath& path, const SkStrokeRec& stroke)
{ | 16 void GrPath::ComputeKey(const SkPath& path, const SkStrokeRec& stroke, GrContent
Key* key) { |
17 static const GrCacheID::Domain gPathDomain = GrCacheID::GenerateDomain(); | 17 static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain(); |
18 | 18 |
19 GrCacheID::Key key; | 19 GrContentKey::Builder builder(key, kDomain, 3); |
20 uint64_t* keyData = key.fData64; | 20 struct PathKey { |
21 keyData[0] = path.getGenerationID(); | 21 uint32_t fGenID; |
22 keyData[1] = ComputeStrokeKey(stroke); | 22 uint64_t fStroke; |
23 | 23 }; |
24 return GrResourceKey(GrCacheID(gPathDomain, key), 0); | 24 PathKey *pathKey = reinterpret_cast<PathKey*>(&builder[0]); |
| 25 pathKey->fGenID = path.getGenerationID(); |
| 26 pathKey->fStroke = ComputeStrokeKey(stroke); |
25 } | 27 } |
26 | 28 |
27 uint64_t GrPath::ComputeStrokeKey(const SkStrokeRec& stroke) { | 29 uint64_t GrPath::ComputeStrokeKey(const SkStrokeRec& stroke) { |
28 enum { | 30 enum { |
29 kStyleBits = 2, | 31 kStyleBits = 2, |
30 kJoinBits = 2, | 32 kJoinBits = 2, |
31 kCapBits = 2, | 33 kCapBits = 2, |
32 kWidthBits = 29, | 34 kWidthBits = 29, |
33 kMiterBits = 29, | 35 kMiterBits = 29, |
34 | 36 |
(...skipping 15 matching lines...) Expand all Loading... |
50 } | 52 } |
51 | 53 |
52 uint64_t key = stroke.getStyle(); | 54 uint64_t key = stroke.getStyle(); |
53 key |= stroke.getJoin() << kJoinShift; | 55 key |= stroke.getJoin() << kJoinShift; |
54 key |= stroke.getCap() << kCapShift; | 56 key |= stroke.getCap() << kCapShift; |
55 key |= get_top_n_float_bits<kWidthBits>(stroke.getWidth()) << kWidthShift; | 57 key |= get_top_n_float_bits<kWidthBits>(stroke.getWidth()) << kWidthShift; |
56 key |= get_top_n_float_bits<kMiterBits>(stroke.getMiter()) << kMiterShift; | 58 key |= get_top_n_float_bits<kMiterBits>(stroke.getMiter()) << kMiterShift; |
57 | 59 |
58 return key; | 60 return key; |
59 } | 61 } |
OLD | NEW |