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 enum { | 11 enum { |
12 kPathsPerGroup = 16 // Paths get tracked in groups of 16 for lazy loading. | 12 kPathsPerGroup = 16 // Paths get tracked in groups of 16 for lazy loading. |
13 }; | 13 }; |
14 | 14 |
15 GrPathRange::GrPathRange(GrGpu* gpu, | 15 GrPathRange::GrPathRange(GrGpu* gpu, |
16 PathGenerator* pathGenerator, | 16 PathGenerator* pathGenerator) |
17 const SkStrokeRec& stroke) | |
18 : INHERITED(gpu, kCached_LifeCycle), | 17 : INHERITED(gpu, kCached_LifeCycle), |
19 fPathGenerator(SkRef(pathGenerator)), | 18 fPathGenerator(SkRef(pathGenerator)), |
20 fNumPaths(fPathGenerator->getNumPaths()), | 19 fNumPaths(fPathGenerator->getNumPaths()) { |
21 fStroke(stroke) { | |
22 const int numGroups = (fNumPaths + kPathsPerGroup - 1) / kPathsPerGroup; | 20 const int numGroups = (fNumPaths + kPathsPerGroup - 1) / kPathsPerGroup; |
23 fGeneratedPaths.reset((numGroups + 7) / 8); // 1 bit per path group. | 21 fGeneratedPaths.reset((numGroups + 7) / 8); // 1 bit per path group. |
24 memset(&fGeneratedPaths.front(), 0, fGeneratedPaths.count()); | 22 memset(&fGeneratedPaths.front(), 0, fGeneratedPaths.count()); |
25 } | 23 } |
26 | 24 |
27 GrPathRange::GrPathRange(GrGpu* gpu, | 25 GrPathRange::GrPathRange(GrGpu* gpu, |
28 int numPaths, | 26 int numPaths) |
29 const SkStrokeRec& stroke) | |
30 : INHERITED(gpu, kCached_LifeCycle), | 27 : INHERITED(gpu, kCached_LifeCycle), |
31 fNumPaths(numPaths), | 28 fNumPaths(numPaths) { |
32 fStroke(stroke) { | |
33 } | 29 } |
34 | 30 |
35 void GrPathRange::willDrawPaths(const void* indices, PathIndexType indexType, in
t count) const { | 31 void GrPathRange::willDrawPaths(const void* indices, PathIndexType indexType, in
t count) const { |
36 if (!fPathGenerator) { | 32 if (!fPathGenerator) { |
37 return; | 33 return; |
38 } | 34 } |
39 | 35 |
40 switch (indexType) { | 36 switch (indexType) { |
41 case kU8_PathIndexType: return this->willDrawPaths<uint8_t>(indices, cou
nt); | 37 case kU8_PathIndexType: return this->willDrawPaths<uint8_t>(indices, cou
nt); |
42 case kU16_PathIndexType: return this->willDrawPaths<uint16_t>(indices, c
ount); | 38 case kU16_PathIndexType: return this->willDrawPaths<uint16_t>(indices, c
ount); |
(...skipping 30 matching lines...) Expand all Loading... |
73 | 69 |
74 fGeneratedPaths[groupByte] |= groupBit; | 70 fGeneratedPaths[groupByte] |= groupBit; |
75 didLoadPaths = true; | 71 didLoadPaths = true; |
76 } | 72 } |
77 } | 73 } |
78 | 74 |
79 if (didLoadPaths) { | 75 if (didLoadPaths) { |
80 this->didChangeGpuMemorySize(); | 76 this->didChangeGpuMemorySize(); |
81 } | 77 } |
82 } | 78 } |
OLD | NEW |