Home | History | Annotate | Download | only in gpu
      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 GrPathRange::GrPathRange(GrGpu* gpu,
     12                          PathGenerator* pathGenerator)
     13     : INHERITED(gpu),
     14       fPathGenerator(SkRef(pathGenerator)),
     15       fNumPaths(fPathGenerator->getNumPaths()) {
     16     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 
     21 GrPathRange::GrPathRange(GrGpu* gpu,
     22                          int numPaths)
     23     : INHERITED(gpu),
     24       fNumPaths(numPaths) {
     25 }
     26 
     27 void GrPathRange::loadPathsIfNeeded(const void* indices, PathIndexType indexType, int count) const {
     28     switch (indexType) {
     29         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:
     36             SK_ABORT("Unknown path index type");
     37     }
     38 }
     39 
     40 #ifdef SK_DEBUG
     41 
     42 void GrPathRange::assertPathsLoaded(const void* indices, PathIndexType indexType, int count) const {
     43     switch (indexType) {
     44         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:
     51             SK_ABORT("Unknown path index type");
     52     }
     53 }
     54 
     55 #endif
     56