aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2018-03-09 11:35:47 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-09 17:45:40 +0000
commit33cb22cb2b60255a2755cc88072490fe8d05b0b9 (patch)
tree1d68ad9fba801d28f065b3055a3d1d808f89e131 /src
parent41a3b87846553e9d77e0e113bfaf4ec74a068e96 (diff)
Remove one use of AttachCache, and a paint variant of FindOrCreate...
This is a point change to see if it causes bad draws using config gldft. Checked with skdiff on that config. Change-Id: Ibee4630df21456ba9dccf28480bded82d1d9bf47 Reviewed-on: https://skia-review.googlesource.com/113204 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkGlyphCache.cpp29
-rw-r--r--src/core/SkGlyphCache.h20
-rw-r--r--src/core/SkPaint.cpp16
-rw-r--r--src/core/SkTextToPathIter.h20
-rw-r--r--src/gpu/text/GrTextUtils.cpp2
5 files changed, 43 insertions, 44 deletions
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp
index 9bb43604a6..f16de64ea3 100644
--- a/src/core/SkGlyphCache.cpp
+++ b/src/core/SkGlyphCache.cpp
@@ -505,6 +505,23 @@ SkExclusiveStrikePtr SkGlyphCache::FindOrCreateStrikeExclusive(
return FindOrCreateStrikeExclusive(desc, creator);
}
+SkExclusiveStrikePtr SkGlyphCache::FindOrCreateStrikeExclusive(
+ const SkPaint& paint,
+ const SkSurfaceProps* surfaceProps,
+ SkScalerContextFlags scalerContextFlags,
+ const SkMatrix* deviceMatrix)
+{
+ SkAutoDescriptor ad;
+ SkScalerContextEffects effects;
+
+ auto desc = SkScalerContext::CreateDescriptorAndEffectsUsingPaint(
+ paint, surfaceProps, scalerContextFlags, deviceMatrix, &ad, &effects);
+
+ auto tf = SkPaintPriv::GetTypefaceOrDefault(paint);
+
+ return FindOrCreateStrikeExclusive(*desc, effects, *tf);
+}
+
void SkGlyphCache::AttachCache(SkGlyphCache* cache) {
SkGlyphCache_Globals::AttachCache(cache);
}
@@ -793,15 +810,3 @@ SkGlyphCache* SkGlyphCache::DetachCache(
return cache.release();
}
-SkGlyphCache* SkGlyphCache::DetachCacheUsingPaint(const SkPaint& paint,
- const SkSurfaceProps* surfaceProps,
- SkScalerContextFlags scalerContextFlags,
- const SkMatrix* deviceMatrix) {
- SkAutoDescriptor ad;
- SkScalerContextEffects effects;
-
- auto desc = SkScalerContext::CreateDescriptorAndEffectsUsingPaint(
- paint, surfaceProps, scalerContextFlags, deviceMatrix, &ad, &effects);
-
- return SkGlyphCache::DetachCache(SkPaintPriv::GetTypefaceOrDefault(paint), effects, desc);
-}
diff --git a/src/core/SkGlyphCache.h b/src/core/SkGlyphCache.h
index 8c335af859..aad1fa4fbb 100644
--- a/src/core/SkGlyphCache.h
+++ b/src/core/SkGlyphCache.h
@@ -148,6 +148,12 @@ public:
const SkScalerContextEffects& effects,
const SkTypeface& typeface);
+ static SkExclusiveStrikePtr FindOrCreateStrikeExclusive(
+ const SkPaint& paint,
+ const SkSurfaceProps* surfaceProps,
+ SkScalerContextFlags scalerContextFlags,
+ const SkMatrix* deviceMatrix);
+
template <typename ScalerContextCreator>
static SkExclusiveStrikePtr CreateStrikeExclusive(
const SkDescriptor& desc, ScalerContextCreator creator)
@@ -178,11 +184,6 @@ public:
static SkGlyphCache* DetachCache(
SkTypeface* typeface, const SkScalerContextEffects& effects, const SkDescriptor* desc);
- static SkGlyphCache* DetachCacheUsingPaint(const SkPaint& paint,
- const SkSurfaceProps* surfaceProps,
- SkScalerContextFlags scalerContextFlags,
- const SkMatrix* deviceMatrix);
-
static void Dump();
/** Dump memory usage statistics of all the attaches caches in the process using the
@@ -302,14 +303,13 @@ public:
SkAutoGlyphCache(SkGlyphCache* cache) : INHERITED(cache) {}
SkAutoGlyphCache(SkTypeface* typeface, const SkScalerContextEffects& effects,
const SkDescriptor* desc)
- : INHERITED(SkGlyphCache::DetachCache(typeface, effects, desc))
- {}
+ : INHERITED(SkGlyphCache::FindOrCreateStrikeExclusive(*desc, effects, *typeface)) {}
/** deprecated: always enables fake gamma */
SkAutoGlyphCache(const SkPaint& paint,
const SkSurfaceProps* surfaceProps,
const SkMatrix* matrix)
: INHERITED(
- SkGlyphCache::DetachCacheUsingPaint(
+ SkGlyphCache::FindOrCreateStrikeExclusive(
paint, surfaceProps,
SkScalerContextFlags::kFakeGammaAndBoostContrast, matrix))
{}
@@ -318,8 +318,8 @@ public:
SkScalerContextFlags scalerContextFlags,
const SkMatrix* matrix)
: INHERITED(
- SkGlyphCache::DetachCacheUsingPaint(paint, surfaceProps, scalerContextFlags, matrix))
- {}
+ SkGlyphCache::FindOrCreateStrikeExclusive(
+ paint, surfaceProps, scalerContextFlags, matrix)) {}
private:
using INHERITED = SkExclusiveStrikePtr;
};
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 1fd3bf55db..f059fc3474 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -1748,9 +1748,9 @@ SkTextBaseIter::SkTextBaseIter(const char text[], size_t length,
}
// SRGBTODO: Is this correct?
- fCache = SkGlyphCache::DetachCacheUsingPaint(fPaint, nullptr,
- SkScalerContextFlags::kFakeGammaAndBoostContrast,
- nullptr);
+ fCache = SkGlyphCache::FindOrCreateStrikeExclusive(
+ fPaint, nullptr,
+ SkScalerContextFlags::kFakeGammaAndBoostContrast, nullptr);
SkPaint::Style style = SkPaint::kFill_Style;
sk_sp<SkPathEffect> pe;
@@ -1768,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, text, length, &count, nullptr) * fScale;
+ SkScalar width = fPaint.measure_text(fCache.get(), text, length, &count, nullptr) * fScale;
if (paint.getTextAlign() == SkPaint::kCenter_Align) {
width = SkScalarHalf(width);
}
@@ -1783,13 +1783,9 @@ 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, &fText);
+ const SkGlyph& glyph = fGlyphCacheProc(fCache.get(), &fText);
fXPos += (fPrevAdvance + fAutoKern.adjust(glyph)) * fScale;
fPrevAdvance = advance(glyph, fXYIndex); // + fPaint.getTextTracking();
@@ -1812,7 +1808,7 @@ bool SkTextToPathIter::next(const SkPath** path, SkScalar* xpos) {
}
bool SkTextInterceptsIter::next(SkScalar* array, int* count) {
- const SkGlyph& glyph = fGlyphCacheProc(fCache, &fText);
+ const SkGlyph& glyph = fGlyphCacheProc(fCache.get(), &fText);
fXPos += (fPrevAdvance + fAutoKern.adjust(glyph)) * fScale;
fPrevAdvance = advance(glyph, fXYIndex); // + fPaint.getTextTracking();
if (fCache->findPath(glyph)) {
diff --git a/src/core/SkTextToPathIter.h b/src/core/SkTextToPathIter.h
index 6de12a84ce..219833468c 100644
--- a/src/core/SkTextToPathIter.h
+++ b/src/core/SkTextToPathIter.h
@@ -9,22 +9,20 @@
#define SkTextToPathIter_DEFINED
#include "SkAutoKern.h"
+#include "SkGlyphCache.h"
#include "SkPaint.h"
-class SkGlyphCache;
-
class SkTextBaseIter {
protected:
SkTextBaseIter(const char text[], size_t length, const SkPaint& paint,
bool applyStrokeAndPathEffects);
- ~SkTextBaseIter();
-
- SkGlyphCache* fCache;
- SkPaint fPaint;
- SkScalar fScale;
- SkScalar fPrevAdvance;
- const char* fText;
- const char* fStop;
+
+ SkExclusiveStrikePtr fCache;
+ SkPaint fPaint;
+ SkScalar fScale;
+ SkScalar fPrevAdvance;
+ const char* fText;
+ const char* fStop;
SkPaint::GlyphCacheProc fGlyphCacheProc;
SkScalar fXPos; // accumulated xpos, returned in next
@@ -74,7 +72,7 @@ public:
if (TextType::kPosText == fTextType
&& fPaint.getTextAlign() != SkPaint::kLeft_Align) { // need to measure first
const char* text = fText;
- const SkGlyph& glyph = fGlyphCacheProc(fCache, &text);
+ const SkGlyph& glyph = fGlyphCacheProc(fCache.get(), &text);
SkScalar width = (&glyph.fAdvanceX)[0] * fScale;
if (fPaint.getTextAlign() == SkPaint::kCenter_Align) {
width = SkScalarHalf(width);
diff --git a/src/gpu/text/GrTextUtils.cpp b/src/gpu/text/GrTextUtils.cpp
index 680e262766..7d693d1e29 100644
--- a/src/gpu/text/GrTextUtils.cpp
+++ b/src/gpu/text/GrTextUtils.cpp
@@ -81,7 +81,7 @@ bool GrTextUtils::PathTextIter::next(const SkGlyph** skGlyph, const SkPath** pat
SkASSERT(path);
SkASSERT(xpos);
if (fText < fStop) {
- const SkGlyph& glyph = fGlyphCacheProc(fCache, &fText);
+ const SkGlyph& glyph = fGlyphCacheProc(fCache.get(), &fText);
fXPos += (fPrevAdvance + fAutoKern.adjust(glyph)) * fScale;
SkASSERT(0 == fXYIndex || 1 == fXYIndex);