Updates nvpr text blobs to not store a direct reference to the
per-glyph GPU path object, but rather store a key for looking it up in
the resource cache. This allows the cache to purge glyphs when needed.
Also indirectly fixes a memory leak that was introduced with nvpr text
blobs.
BUG=skia:
Review URL: https://codereview.chromium.org/1374853004
diff --git a/src/gpu/GrPathRange.cpp b/src/gpu/GrPathRange.cpp
index 117051d..754aca0 100644
--- a/src/gpu/GrPathRange.cpp
+++ b/src/gpu/GrPathRange.cpp
@@ -8,7 +8,6 @@
#include "GrPathRange.h"
#include "SkPath.h"
-
GrPathRange::GrPathRange(GrGpu* gpu,
PathGenerator* pathGenerator)
: INHERITED(gpu, kCached_LifeCycle),
@@ -27,10 +26,14 @@
void GrPathRange::loadPathsIfNeeded(const void* indices, PathIndexType indexType, int count) const {
switch (indexType) {
- case kU8_PathIndexType: return this->loadPathsIfNeeded<uint8_t>(indices, count);
- case kU16_PathIndexType: return this->loadPathsIfNeeded<uint16_t>(indices, count);
- case kU32_PathIndexType: return this->loadPathsIfNeeded<uint32_t>(indices, count);
- default: SkFAIL("Unknown path index type");
+ case kU8_PathIndexType:
+ return this->loadPathsIfNeeded(reinterpret_cast<const uint8_t*>(indices), count);
+ case kU16_PathIndexType:
+ return this->loadPathsIfNeeded(reinterpret_cast<const uint16_t*>(indices), count);
+ case kU32_PathIndexType:
+ return this->loadPathsIfNeeded(reinterpret_cast<const uint32_t*>(indices), count);
+ default:
+ SkFAIL("Unknown path index type");
}
}
@@ -38,10 +41,14 @@
void GrPathRange::assertPathsLoaded(const void* indices, PathIndexType indexType, int count) const {
switch (indexType) {
- case kU8_PathIndexType: return this->assertPathsLoaded<uint8_t>(indices, count);
- case kU16_PathIndexType: return this->assertPathsLoaded<uint16_t>(indices, count);
- case kU32_PathIndexType: return this->assertPathsLoaded<uint32_t>(indices, count);
- default: SkFAIL("Unknown path index type");
+ case kU8_PathIndexType:
+ return this->assertPathsLoaded(reinterpret_cast<const uint8_t*>(indices), count);
+ case kU16_PathIndexType:
+ return this->assertPathsLoaded(reinterpret_cast<const uint16_t*>(indices), count);
+ case kU32_PathIndexType:
+ return this->assertPathsLoaded(reinterpret_cast<const uint32_t*>(indices), count);
+ default:
+ SkFAIL("Unknown path index type");
}
}