From 39ce0ac09a375aab18659b1a4ed0c503b0b81a4c Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Fri, 8 Apr 2011 15:42:19 +0000 Subject: [PATCH] unbias fy in the gpu glyphproc, since skia has pre-added 1/2 to the value (assuming we would call floor to get a rounded value.) apply finalFYMask not to the initial fy, but to the fyMask (so it is always applied in the loop) in drawText. git-svn-id: http://skia.googlecode.com/svn/trunk@1084 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/core/SkDraw.cpp | 2 +- src/gpu/SkGpuDevice.cpp | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index 4cc068d609..14e5a803cb 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -1628,7 +1628,7 @@ void SkDraw::drawText(const char text[], size_t byteLength, // apply the bias here, so we don't have to add 1/2 in the loop fx += SK_FixedHalf; fy += SK_FixedHalf; - fy &= finalFYMask; + fyMask &= finalFYMask; SkAutoKern autokern; SkDraw1Glyph d1g; diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 7b70b50c62..2d50c3652d 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1261,8 +1261,18 @@ static void SkGPU_Draw1Glyph(const SkDraw1Glyph& state, if (NULL == procs->fFontScaler) { procs->fFontScaler = get_gr_font_scaler(state.fCache); } + + /* + * Skia calls us with fx,fy already biased by 1/2. It does this to speed + * up rounding these, so that all of its procs (like us) can just call + * SkFixedFloor and get the "rounded" value. + * + * We take advantage of that for fx, where we pass a rounded value, but + * we want the fractional fy, so we have to unbias it first. + */ procs->fTextContext->drawPackedGlyph(GrGlyph::Pack(glyph.getGlyphID(), fx, 0), - SkIntToFixed(SkFixedFloor(fx)), fy, + SkIntToFixed(SkFixedFloor(fx)), + fy - SK_FixedHalf, procs->fFontScaler); }