Line data Source code
1 : /*
2 : * Copyright 2014 Google Inc.
3 : *
4 : * Use of this source code is governed by a BSD-style license that can be
5 : * found in the LICENSE file.
6 : */
7 :
8 : #include "GrPathRange.h"
9 : #include "SkPath.h"
10 :
11 0 : GrPathRange::GrPathRange(GrGpu* gpu,
12 0 : PathGenerator* pathGenerator)
13 : : INHERITED(gpu),
14 : fPathGenerator(SkRef(pathGenerator)),
15 0 : fNumPaths(fPathGenerator->getNumPaths()) {
16 0 : const int numGroups = (fNumPaths + kPathsPerGroup - 1) / kPathsPerGroup;
17 0 : fGeneratedPaths.reset((numGroups + 7) / 8); // 1 bit per path group.
18 0 : memset(&fGeneratedPaths.front(), 0, fGeneratedPaths.count());
19 0 : }
20 :
21 0 : GrPathRange::GrPathRange(GrGpu* gpu,
22 0 : int numPaths)
23 : : INHERITED(gpu),
24 0 : fNumPaths(numPaths) {
25 0 : }
26 :
27 0 : void GrPathRange::loadPathsIfNeeded(const void* indices, PathIndexType indexType, int count) const {
28 0 : switch (indexType) {
29 : case kU8_PathIndexType:
30 0 : return this->loadPathsIfNeeded(reinterpret_cast<const uint8_t*>(indices), count);
31 : case kU16_PathIndexType:
32 0 : return this->loadPathsIfNeeded(reinterpret_cast<const uint16_t*>(indices), count);
33 : case kU32_PathIndexType:
34 0 : return this->loadPathsIfNeeded(reinterpret_cast<const uint32_t*>(indices), count);
35 : default:
36 0 : SkFAIL("Unknown path index type");
37 : }
38 : }
39 :
40 : #ifdef SK_DEBUG
41 :
42 0 : void GrPathRange::assertPathsLoaded(const void* indices, PathIndexType indexType, int count) const {
43 0 : switch (indexType) {
44 : case kU8_PathIndexType:
45 0 : return this->assertPathsLoaded(reinterpret_cast<const uint8_t*>(indices), count);
46 : case kU16_PathIndexType:
47 0 : return this->assertPathsLoaded(reinterpret_cast<const uint16_t*>(indices), count);
48 : case kU32_PathIndexType:
49 0 : return this->assertPathsLoaded(reinterpret_cast<const uint32_t*>(indices), count);
50 : default:
51 0 : SkFAIL("Unknown path index type");
52 : }
53 : }
54 :
55 : #endif
|