diff options
Diffstat (limited to 'src/gpu/text/GrTextUtils.cpp')
-rw-r--r-- | src/gpu/text/GrTextUtils.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/gpu/text/GrTextUtils.cpp b/src/gpu/text/GrTextUtils.cpp index 0b26c84168..ad5c040977 100644 --- a/src/gpu/text/GrTextUtils.cpp +++ b/src/gpu/text/GrTextUtils.cpp @@ -40,7 +40,7 @@ static const int kLargeDFFontLimit = 2 * kLargeDFFontSize; void GrTextUtils::DrawBmpText(GrAtlasTextBlob* blob, int runIndex, GrBatchFontCache* fontCache, const SkSurfaceProps& props, const SkPaint& skPaint, - GrColor color, + GrColor color, SkPaint::FakeGamma fakeGamma, const SkMatrix& viewMatrix, const char text[], size_t byteLength, SkScalar x, SkScalar y) { @@ -57,7 +57,7 @@ void GrTextUtils::DrawBmpText(GrAtlasTextBlob* blob, int runIndex, GrBatchTextStrike* currStrike = nullptr; // Get GrFontScaler from cache - SkGlyphCache* cache = blob->setupCache(runIndex, props, SkPaint::FakeGamma::On, + SkGlyphCache* cache = blob->setupCache(runIndex, props, fakeGamma, skPaint, &viewMatrix); GrFontScaler* fontScaler = GrTextUtils::GetGrFontScaler(cache); @@ -80,7 +80,7 @@ void GrTextUtils::DrawBmpText(GrAtlasTextBlob* blob, int runIndex, void GrTextUtils::DrawBmpPosText(GrAtlasTextBlob* blob, int runIndex, GrBatchFontCache* fontCache, const SkSurfaceProps& props, const SkPaint& skPaint, - GrColor color, + GrColor color, SkPaint::FakeGamma fakeGamma, const SkMatrix& viewMatrix, const char text[], size_t byteLength, const SkScalar pos[], int scalarsPerPosition, @@ -99,7 +99,7 @@ void GrTextUtils::DrawBmpPosText(GrAtlasTextBlob* blob, int runIndex, GrBatchTextStrike* currStrike = nullptr; // Get GrFontScaler from cache - SkGlyphCache* cache = blob->setupCache(runIndex, props, SkPaint::FakeGamma::On, + SkGlyphCache* cache = blob->setupCache(runIndex, props, fakeGamma, skPaint, &viewMatrix); GrFontScaler* fontScaler = GrTextUtils::GetGrFontScaler(cache); @@ -247,7 +247,7 @@ void GrTextUtils::InitDistanceFieldPaint(GrAtlasTextBlob* blob, void GrTextUtils::DrawDFText(GrAtlasTextBlob* blob, int runIndex, GrBatchFontCache* fontCache, const SkSurfaceProps& props, - const SkPaint& skPaint, GrColor color, + const SkPaint& skPaint, GrColor color, SkPaint::FakeGamma fakeGamma, const SkMatrix& viewMatrix, const char text[], size_t byteLength, SkScalar x, SkScalar y) { @@ -260,6 +260,8 @@ void GrTextUtils::DrawDFText(GrAtlasTextBlob* blob, int runIndex, SkPaint::GlyphCacheProc glyphCacheProc = skPaint.getGlyphCacheProc(true); SkAutoDescriptor desc; + // We apply the fake-gamma by altering the distance in the shader, so we ignore the + // fakeGamma parameter. (It's only used when we fall-back to bitmap text). skPaint.getScalerContextDescriptor(&desc, props, SkPaint::FakeGamma::Off, nullptr); SkGlyphCache* origPaintCache = SkGlyphCache::DetachCache(skPaint.getTypeface(), desc.getDesc()); @@ -310,14 +312,15 @@ void GrTextUtils::DrawDFText(GrAtlasTextBlob* blob, int runIndex, y -= alignY; SkPoint offset = SkPoint::Make(x, y); - DrawDFPosText(blob, runIndex, fontCache, props, skPaint, color, viewMatrix, text, byteLength, - positions.begin(), 2, offset); + DrawDFPosText(blob, runIndex, fontCache, props, skPaint, color, fakeGamma, viewMatrix, + text, byteLength, positions.begin(), 2, offset); } void GrTextUtils::DrawDFPosText(GrAtlasTextBlob* blob, int runIndex, GrBatchFontCache* fontCache, const SkSurfaceProps& props, const SkPaint& origPaint, - GrColor color, const SkMatrix& viewMatrix, + GrColor color, SkPaint::FakeGamma fakeGamma, + const SkMatrix& viewMatrix, const char text[], size_t byteLength, const SkScalar pos[], int scalarsPerPosition, const SkPoint& offset) { @@ -341,6 +344,8 @@ void GrTextUtils::DrawDFPosText(GrAtlasTextBlob* blob, int runIndex, GrBatchTextStrike* currStrike = nullptr; + // We apply the fake-gamma by altering the distance in the shader, so we ignore the + // fakeGamma parameter. (It's only used when we fall-back to bitmap text). SkGlyphCache* cache = blob->setupCache(runIndex, props, SkPaint::FakeGamma::Off, dfPaint, nullptr); SkPaint::GlyphCacheProc glyphCacheProc = dfPaint.getGlyphCacheProc(true); @@ -415,7 +420,7 @@ void GrTextUtils::DrawDFPosText(GrAtlasTextBlob* blob, int runIndex, if (fallbackTxt.count()) { blob->initOverride(runIndex); GrTextUtils::DrawBmpPosText(blob, runIndex, fontCache, props, - origPaint, origPaint.getColor(), viewMatrix, + origPaint, origPaint.getColor(), fakeGamma, viewMatrix, fallbackTxt.begin(), fallbackTxt.count(), fallbackPos.begin(), scalarsPerPosition, offset); } |