OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrPathRange.h" | 8 #include "GrPathRange.h" |
9 #include "SkPath.h" | 9 #include "SkPath.h" |
10 | 10 |
11 | |
12 GrPathRange::GrPathRange(GrGpu* gpu, | 11 GrPathRange::GrPathRange(GrGpu* gpu, |
13 PathGenerator* pathGenerator) | 12 PathGenerator* pathGenerator) |
14 : INHERITED(gpu, kCached_LifeCycle), | 13 : INHERITED(gpu, kCached_LifeCycle), |
15 fPathGenerator(SkRef(pathGenerator)), | 14 fPathGenerator(SkRef(pathGenerator)), |
16 fNumPaths(fPathGenerator->getNumPaths()) { | 15 fNumPaths(fPathGenerator->getNumPaths()) { |
17 const int numGroups = (fNumPaths + kPathsPerGroup - 1) / kPathsPerGroup; | 16 const int numGroups = (fNumPaths + kPathsPerGroup - 1) / kPathsPerGroup; |
18 fGeneratedPaths.reset((numGroups + 7) / 8); // 1 bit per path group. | 17 fGeneratedPaths.reset((numGroups + 7) / 8); // 1 bit per path group. |
19 memset(&fGeneratedPaths.front(), 0, fGeneratedPaths.count()); | 18 memset(&fGeneratedPaths.front(), 0, fGeneratedPaths.count()); |
20 } | 19 } |
21 | 20 |
22 GrPathRange::GrPathRange(GrGpu* gpu, | 21 GrPathRange::GrPathRange(GrGpu* gpu, |
23 int numPaths) | 22 int numPaths) |
24 : INHERITED(gpu, kCached_LifeCycle), | 23 : INHERITED(gpu, kCached_LifeCycle), |
25 fNumPaths(numPaths) { | 24 fNumPaths(numPaths) { |
26 } | 25 } |
27 | 26 |
28 void GrPathRange::loadPathsIfNeeded(const void* indices, PathIndexType indexType
, int count) const { | 27 void GrPathRange::loadPathsIfNeeded(const void* indices, PathIndexType indexType
, int count) const { |
29 switch (indexType) { | 28 switch (indexType) { |
30 case kU8_PathIndexType: return this->loadPathsIfNeeded<uint8_t>(indices,
count); | 29 case kU8_PathIndexType: |
31 case kU16_PathIndexType: return this->loadPathsIfNeeded<uint16_t>(indice
s, count); | 30 return this->loadPathsIfNeeded(reinterpret_cast<const uint8_t*>(indi
ces), count); |
32 case kU32_PathIndexType: return this->loadPathsIfNeeded<uint32_t>(indice
s, count); | 31 case kU16_PathIndexType: |
33 default: SkFAIL("Unknown path index type"); | 32 return this->loadPathsIfNeeded(reinterpret_cast<const uint16_t*>(ind
ices), count); |
| 33 case kU32_PathIndexType: |
| 34 return this->loadPathsIfNeeded(reinterpret_cast<const uint32_t*>(ind
ices), count); |
| 35 default: |
| 36 SkFAIL("Unknown path index type"); |
34 } | 37 } |
35 } | 38 } |
36 | 39 |
37 #ifdef SK_DEBUG | 40 #ifdef SK_DEBUG |
38 | 41 |
39 void GrPathRange::assertPathsLoaded(const void* indices, PathIndexType indexType
, int count) const { | 42 void GrPathRange::assertPathsLoaded(const void* indices, PathIndexType indexType
, int count) const { |
40 switch (indexType) { | 43 switch (indexType) { |
41 case kU8_PathIndexType: return this->assertPathsLoaded<uint8_t>(indices,
count); | 44 case kU8_PathIndexType: |
42 case kU16_PathIndexType: return this->assertPathsLoaded<uint16_t>(indice
s, count); | 45 return this->assertPathsLoaded(reinterpret_cast<const uint8_t*>(indi
ces), count); |
43 case kU32_PathIndexType: return this->assertPathsLoaded<uint32_t>(indice
s, count); | 46 case kU16_PathIndexType: |
44 default: SkFAIL("Unknown path index type"); | 47 return this->assertPathsLoaded(reinterpret_cast<const uint16_t*>(ind
ices), count); |
| 48 case kU32_PathIndexType: |
| 49 return this->assertPathsLoaded(reinterpret_cast<const uint32_t*>(ind
ices), count); |
| 50 default: |
| 51 SkFAIL("Unknown path index type"); |
45 } | 52 } |
46 } | 53 } |
47 | 54 |
48 #endif | 55 #endif |
OLD | NEW |