Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Unified Diff: src/core/SkDraw.cpp

Issue 41213003: Hook in rough distance field support for fonts (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/gpu/GrDistanceFieldTextContext.h ('k') | src/core/SkDrawProcs.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkDraw.cpp
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index d2d618090e39d4e085bbf5cf8174721bbe990b93..3e8f95fec699a0e878251b10940502c36f212df9 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1680,11 +1680,24 @@ void SkDraw::drawText(const char text[], size_t byteLength,
SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc();
- SkAutoGlyphCache autoCache(paint, &fDevice->fLeakyProperties, fMatrix);
+ const SkMatrix* ctm = fMatrix;
+ const SkPaint* paintRef = &paint;
+ SkPaint paintCopy;
+ uint32_t procFlags = fProcs ? fProcs->fFlags : 0;
+ if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) {
+ paintCopy = paint;
+ paintCopy.setTextSize(32);
bungeman-skia 2013/10/24 19:50:48 32 is quite a magic number. If you want a 'canonic
+ paintCopy.setLCDRenderText(false);
+ paintRef = &paintCopy;
+ }
+ if (procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag) {
+ ctm = NULL;
+ }
+ SkAutoGlyphCache autoCache(*paintRef, &fDevice->fLeakyProperties, ctm);
SkGlyphCache* cache = autoCache.getCache();
// transform our starting point
- {
+ if (!(procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag)) {
SkPoint loc;
fMatrix->mapXY(x, y, &loc);
x = loc.fX;
@@ -1742,16 +1755,31 @@ void SkDraw::drawText(const char text[], size_t byteLength,
SkFixed fx = SkScalarToFixed(x) + d1g.fHalfSampleX;
SkFixed fy = SkScalarToFixed(y) + d1g.fHalfSampleY;
+ SkFixed fscale;
+ if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) {
+ SkScalar sscale = paint.getTextSize()/32.f;
+ fscale = SkScalarToFixed(sscale);
+ }
while (text < stop) {
const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fyMask);
- fx += autokern.adjust(glyph);
+ if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) {
+ fx += SkFixedMul_portable(autokern.adjust(glyph), fscale);
+ } else {
+ fx += autokern.adjust(glyph);
+ }
if (glyph.fWidth) {
proc(d1g, fx, fy, glyph);
}
- fx += glyph.fAdvanceX;
- fy += glyph.fAdvanceY;
+
+ if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) {
+ fx += SkFixedMul_portable(glyph.fAdvanceX, fscale);
+ fy += SkFixedMul_portable(glyph.fAdvanceY, fscale);
+ } else {
+ fx += glyph.fAdvanceX;
+ fy += glyph.fAdvanceY;
+ }
}
}
@@ -1909,7 +1937,19 @@ void SkDraw::drawPosText(const char text[], size_t byteLength,
}
SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc();
- SkAutoGlyphCache autoCache(paint, &fDevice->fLeakyProperties, fMatrix);
+ const SkMatrix* ctm = fMatrix;
+ const SkPaint* paintRef = &paint;
+ SkPaint paintCopy;
+ uint32_t procFlags = fProcs ? fProcs->fFlags : 0;
+ if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) {
+ paintCopy = paint;
+ paintCopy.setTextSize(32);
+ paintRef = &paintCopy;
+ }
+ if (procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag) {
+ ctm = NULL;
+ }
+ SkAutoGlyphCache autoCache(*paintRef, &fDevice->fLeakyProperties, ctm);
SkGlyphCache* cache = autoCache.getCache();
SkAAClipBlitterWrapper wrapper;
@@ -1951,7 +1991,12 @@ void SkDraw::drawPosText(const char text[], size_t byteLength,
if (SkPaint::kLeft_Align == paint.getTextAlign()) {
while (text < stop) {
- tmsProc(tms, pos);
+ if (procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag) {
+ tms.fLoc.fX = *pos;
+ tms.fLoc.fY = *(pos+1);
+ } else {
+ tmsProc(tms, pos);
+ }
SkFixed fx = SkScalarToFixed(tms.fLoc.fX) + d1g.fHalfSampleX;
SkFixed fy = SkScalarToFixed(tms.fLoc.fY) + d1g.fHalfSampleY;
« no previous file with comments | « include/gpu/GrDistanceFieldTextContext.h ('k') | src/core/SkDrawProcs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698