blob: 8ed4fd62a7a03e50cdf1024d8707770936214c99 [file] [log] [blame]
cdalton855d83f2014-09-18 13:51:53 -07001/*
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
cdalton855d83f2014-09-18 13:51:53 -070011GrPathRange::GrPathRange(GrGpu* gpu,
kkinnunen50b58e62015-05-18 23:02:07 -070012 PathGenerator* pathGenerator)
kkinnunen2e6055b2016-04-22 01:48:29 -070013 : INHERITED(gpu),
cdalton855d83f2014-09-18 13:51:53 -070014 fPathGenerator(SkRef(pathGenerator)),
kkinnunen50b58e62015-05-18 23:02:07 -070015 fNumPaths(fPathGenerator->getNumPaths()) {
cdalton855d83f2014-09-18 13:51:53 -070016 const int numGroups = (fNumPaths + kPathsPerGroup - 1) / kPathsPerGroup;
17 fGeneratedPaths.reset((numGroups + 7) / 8); // 1 bit per path group.
18 memset(&fGeneratedPaths.front(), 0, fGeneratedPaths.count());
19}
20
21GrPathRange::GrPathRange(GrGpu* gpu,
kkinnunen50b58e62015-05-18 23:02:07 -070022 int numPaths)
kkinnunen2e6055b2016-04-22 01:48:29 -070023 : INHERITED(gpu),
kkinnunen50b58e62015-05-18 23:02:07 -070024 fNumPaths(numPaths) {
cdalton855d83f2014-09-18 13:51:53 -070025}
26
cdaltond1201052015-10-05 15:56:34 -070027void GrPathRange::loadPathsIfNeeded(const void* indices, PathIndexType indexType, int count) const {
cdalton55b24af2014-11-25 11:00:56 -080028 switch (indexType) {
cdalton8585dd22015-10-08 08:04:09 -070029 case kU8_PathIndexType:
30 return this->loadPathsIfNeeded(reinterpret_cast<const uint8_t*>(indices), count);
31 case kU16_PathIndexType:
32 return this->loadPathsIfNeeded(reinterpret_cast<const uint16_t*>(indices), count);
33 case kU32_PathIndexType:
34 return this->loadPathsIfNeeded(reinterpret_cast<const uint32_t*>(indices), count);
35 default:
Ben Wagnerb4aab9a2017-08-16 10:53:04 -040036 SK_ABORT("Unknown path index type");
cdalton55b24af2014-11-25 11:00:56 -080037 }
38}
39
cdaltond1201052015-10-05 15:56:34 -070040#ifdef SK_DEBUG
cdalton55b24af2014-11-25 11:00:56 -080041
cdaltond1201052015-10-05 15:56:34 -070042void GrPathRange::assertPathsLoaded(const void* indices, PathIndexType indexType, int count) const {
43 switch (indexType) {
cdalton8585dd22015-10-08 08:04:09 -070044 case kU8_PathIndexType:
45 return this->assertPathsLoaded(reinterpret_cast<const uint8_t*>(indices), count);
46 case kU16_PathIndexType:
47 return this->assertPathsLoaded(reinterpret_cast<const uint16_t*>(indices), count);
48 case kU32_PathIndexType:
49 return this->assertPathsLoaded(reinterpret_cast<const uint32_t*>(indices), count);
50 default:
Ben Wagnerb4aab9a2017-08-16 10:53:04 -040051 SK_ABORT("Unknown path index type");
cdalton855d83f2014-09-18 13:51:53 -070052 }
53}
cdaltond1201052015-10-05 15:56:34 -070054
55#endif