| 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) | 17 const SkStrokeRec& stroke) |
| 18 : INHERITED(gpu, kIsWrapped), | 18 : INHERITED(gpu, kCached_LifeCycle), |
| 19 fPathGenerator(SkRef(pathGenerator)), | 19 fPathGenerator(SkRef(pathGenerator)), |
| 20 fNumPaths(fPathGenerator->getNumPaths()), | 20 fNumPaths(fPathGenerator->getNumPaths()), |
| 21 fStroke(stroke) { | 21 fStroke(stroke) { |
| 22 const int numGroups = (fNumPaths + kPathsPerGroup - 1) / kPathsPerGroup; | 22 const int numGroups = (fNumPaths + kPathsPerGroup - 1) / kPathsPerGroup; |
| 23 fGeneratedPaths.reset((numGroups + 7) / 8); // 1 bit per path group. | 23 fGeneratedPaths.reset((numGroups + 7) / 8); // 1 bit per path group. |
| 24 memset(&fGeneratedPaths.front(), 0, fGeneratedPaths.count()); | 24 memset(&fGeneratedPaths.front(), 0, fGeneratedPaths.count()); |
| 25 } | 25 } |
| 26 | 26 |
| 27 GrPathRange::GrPathRange(GrGpu* gpu, | 27 GrPathRange::GrPathRange(GrGpu* gpu, |
| 28 int numPaths, | 28 int numPaths, |
| 29 const SkStrokeRec& stroke) | 29 const SkStrokeRec& stroke) |
| 30 : INHERITED(gpu, kIsWrapped), | 30 : INHERITED(gpu, kCached_LifeCycle), |
| 31 fNumPaths(numPaths), | 31 fNumPaths(numPaths), |
| 32 fStroke(stroke) { | 32 fStroke(stroke) { |
| 33 } | 33 } |
| 34 | 34 |
| 35 void GrPathRange::willDrawPaths(const void* indices, PathIndexType indexType, in
t count) const { | 35 void GrPathRange::willDrawPaths(const void* indices, PathIndexType indexType, in
t count) const { |
| 36 if (!fPathGenerator) { | 36 if (!fPathGenerator) { |
| 37 return; | 37 return; |
| 38 } | 38 } |
| 39 | 39 |
| 40 switch (indexType) { | 40 switch (indexType) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 fGeneratedPaths[groupByte] |= groupBit; | 74 fGeneratedPaths[groupByte] |= groupBit; |
| 75 didLoadPaths = true; | 75 didLoadPaths = true; |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 if (didLoadPaths) { | 79 if (didLoadPaths) { |
| 80 this->didChangeGpuMemorySize(); | 80 this->didChangeGpuMemorySize(); |
| 81 } | 81 } |
| 82 } | 82 } |
| OLD | NEW |