aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPaint.cpp
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2018-03-07 18:05:39 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-07 18:05:51 +0000
commitab6fd7ef91aeca8a3fbbc6c6670cb89a5a7b6d53 (patch)
treee98936f124d58dafe85aab73b3a85fd8279e1d8a /src/core/SkPaint.cpp
parente64b064f87018cc84ad843b3cad3185f87917fe8 (diff)
Revert "Remove attach and detach glyph cache."
This reverts commit 61d56b92a4076f8afd644d015913641d691e39c8. Reason for revert: broke gldft text Original change's description: > Remove attach and detach glyph cache. > > BUG=skia:7515 > > Change-Id: Ib978e3cf4cfffdefe6453feb520e5e73684abf2e > Reviewed-on: https://skia-review.googlesource.com/112560 > Reviewed-by: Ben Wagner <bungeman@google.com> > Commit-Queue: Herb Derby <herb@google.com> TBR=bungeman@google.com,herb@google.com Change-Id: Id5723a3abcd103ed20197bba2dab06e8074be633 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:7515 Reviewed-on: https://skia-review.googlesource.com/112745 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkPaint.cpp')
-rw-r--r--src/core/SkPaint.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 210b8e5a3a..e3680713b5 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -431,7 +431,7 @@ int SkPaint::textToGlyphs(const void* textData, size_t byteLength, uint16_t glyp
}
SkAutoGlyphCache autoCache(*this, nullptr, nullptr);
- SkGlyphCache* cache = autoCache.get();
+ SkGlyphCache* cache = autoCache.getCache();
const char* text = (const char*)textData;
const char* stop = text + byteLength;
@@ -489,7 +489,7 @@ bool SkPaint::containsText(const void* textData, size_t byteLength) const {
}
SkAutoGlyphCache autoCache(*this, nullptr, nullptr);
- SkGlyphCache* cache = autoCache.get();
+ SkGlyphCache* cache = autoCache.getCache();
switch (this->getTextEncoding()) {
case SkPaint::kUTF8_TextEncoding: {
@@ -539,7 +539,7 @@ void SkPaint::glyphsToUnichars(const uint16_t glyphs[], int count, SkUnichar tex
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
SkAutoGlyphCache autoCache(*this, &props, nullptr);
- SkGlyphCache* cache = autoCache.get();
+ SkGlyphCache* cache = autoCache.getCache();
for (int index = 0; index < count; index++) {
textData[index] = cache->glyphToUnichar(glyphs[index]);
@@ -805,7 +805,7 @@ SkScalar SkPaint::measureText(const void* textData, size_t length, SkRect* bound
SkScalar scale = canon.getScale();
SkAutoGlyphCache autoCache(paint, nullptr, nullptr);
- SkGlyphCache* cache = autoCache.get();
+ SkGlyphCache* cache = autoCache.getCache();
SkScalar width = 0;
@@ -859,7 +859,7 @@ size_t SkPaint::breakText(const void* textD, size_t length, SkScalar maxWidth,
}
SkAutoGlyphCache autoCache(paint, nullptr, nullptr);
- SkGlyphCache* cache = autoCache.get();
+ SkGlyphCache* cache = autoCache.getCache();
GlyphCacheProc glyphCacheProc = SkPaint::GetGlyphCacheProc(paint.getTextEncoding(),
paint.isDevKernText(),
@@ -965,7 +965,7 @@ int SkPaint::getTextWidths(const void* textData, size_t byteLength,
SkScalar scale = canon.getScale();
SkAutoGlyphCache autoCache(paint, nullptr, nullptr);
- SkGlyphCache* cache = autoCache.get();
+ SkGlyphCache* cache = autoCache.getCache();
GlyphCacheProc glyphCacheProc = SkPaint::GetGlyphCacheProc(paint.getTextEncoding(),
paint.isDevKernText(),
nullptr != bounds);
@@ -1748,8 +1748,9 @@ SkTextBaseIter::SkTextBaseIter(const char text[], size_t length,
}
// SRGBTODO: Is this correct?
- fCache = SkGlyphCache::FindOrCreateStrikeExclusive(
- fPaint, nullptr, SkScalerContextFlags::kFakeGammaAndBoostContrast, nullptr);
+ fCache = SkGlyphCache::DetachCacheUsingPaint(fPaint, nullptr,
+ SkScalerContextFlags::kFakeGammaAndBoostContrast,
+ nullptr);
SkPaint::Style style = SkPaint::kFill_Style;
sk_sp<SkPathEffect> pe;
@@ -1767,7 +1768,7 @@ SkTextBaseIter::SkTextBaseIter(const char text[], size_t length,
SkScalar xOffset = 0;
if (paint.getTextAlign() != SkPaint::kLeft_Align) { // need to measure first
int count;
- SkScalar width = fPaint.measure_text(fCache.get(), text, length, &count, nullptr) * fScale;
+ SkScalar width = fPaint.measure_text(fCache, text, length, &count, nullptr) * fScale;
if (paint.getTextAlign() == SkPaint::kCenter_Align) {
width = SkScalarHalf(width);
}
@@ -1782,9 +1783,13 @@ SkTextBaseIter::SkTextBaseIter(const char text[], size_t length,
fXYIndex = paint.isVerticalText() ? 1 : 0;
}
+SkTextBaseIter::~SkTextBaseIter() {
+ SkGlyphCache::AttachCache(fCache);
+}
+
bool SkTextToPathIter::next(const SkPath** path, SkScalar* xpos) {
if (fText < fStop) {
- const SkGlyph& glyph = fGlyphCacheProc(fCache.get(), &fText);
+ const SkGlyph& glyph = fGlyphCacheProc(fCache, &fText);
fXPos += (fPrevAdvance + fAutoKern.adjust(glyph)) * fScale;
fPrevAdvance = advance(glyph, fXYIndex); // + fPaint.getTextTracking();
@@ -1807,7 +1812,7 @@ bool SkTextToPathIter::next(const SkPath** path, SkScalar* xpos) {
}
bool SkTextInterceptsIter::next(SkScalar* array, int* count) {
- const SkGlyph& glyph = fGlyphCacheProc(fCache.get(), &fText);
+ const SkGlyph& glyph = fGlyphCacheProc(fCache, &fText);
fXPos += (fPrevAdvance + fAutoKern.adjust(glyph)) * fScale;
fPrevAdvance = advance(glyph, fXYIndex); // + fPaint.getTextTracking();
if (fCache->findPath(glyph)) {