aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkGlyphCache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkGlyphCache.cpp')
-rw-r--r--src/core/SkGlyphCache.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp
index d9d8d41eb1..bf5f77c817 100644
--- a/src/core/SkGlyphCache.cpp
+++ b/src/core/SkGlyphCache.cpp
@@ -194,7 +194,9 @@ const void* SkGlyphCache::findImage(const SkGlyph& glyph) {
return glyph.fImage;
}
-void SkGlyphCache::initializeImage(const volatile void* data, size_t size, SkGlyph* glyph) {
+bool SkGlyphCache::initializeImage(const volatile void* data, size_t size, SkGlyph* glyph) {
+ if (glyph->fImage) return false;
+
if (glyph->fWidth > 0 && glyph->fWidth < kMaxGlyphWidth) {
size_t allocSize = glyph->allocImage(&fAlloc);
// check that alloc() actually succeeded
@@ -204,6 +206,8 @@ void SkGlyphCache::initializeImage(const volatile void* data, size_t size, SkGly
fMemoryUsed += size;
}
}
+
+ return true;
}
const SkPath* SkGlyphCache::findPath(const SkGlyph& glyph) {
@@ -225,6 +229,25 @@ const SkPath* SkGlyphCache::findPath(const SkGlyph& glyph) {
return glyph.fPathData ? glyph.fPathData->fPath : nullptr;
}
+bool SkGlyphCache::initializePath(SkGlyph* glyph, const volatile void* data, size_t size) {
+ if (glyph->fPathData) return false;
+
+ if (glyph->fWidth) {
+ SkGlyph::PathData* pathData = fAlloc.make<SkGlyph::PathData>();
+ glyph->fPathData = pathData;
+ pathData->fIntercept = nullptr;
+ SkPath* path = new SkPath;
+ if (!path->readFromMemory(const_cast<const void*>(data), size)) {
+ delete path;
+ return false;
+ }
+ pathData->fPath = path;
+ fMemoryUsed += compute_path_size(*path);
+ }
+
+ return true;
+}
+
#include "../pathops/SkPathOpsCubic.h"
#include "../pathops/SkPathOpsQuad.h"