From 0bf5408286ea3dacb197c220e1033dea3eeef2a8 Mon Sep 17 00:00:00 2001 From: Bruce Wang Date: Wed, 18 Jul 2018 12:36:56 -0400 Subject: Implement Subpixel mode for color format image. Change-Id: I4b76b1def8458fec3c5d94fa8c4e1dd48c74e376 Reviewed-on: https://skia-review.googlesource.com/142165 Commit-Queue: Ben Wagner Reviewed-by: Ben Wagner --- src/ports/SkScalerContext_win_dw.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/ports/SkScalerContext_win_dw.cpp b/src/ports/SkScalerContext_win_dw.cpp index 8f9a761614..dac3c827c1 100644 --- a/src/ports/SkScalerContext_win_dw.cpp +++ b/src/ports/SkScalerContext_win_dw.cpp @@ -594,7 +594,14 @@ void SkScalerContext_DW::generateColorMetrics(SkGlyph* glyph) { } bounds.join(path.getBounds()); } - HRV(fSkXform.mapRect(&bounds)); + SkMatrix matrix = fSkXform; +#ifndef SK_IGNORE_EMOJI_SUBPIXEL_FIX + if (this->isSubpixel()) { + matrix.postTranslate(SkFixedToScalar(glyph->getSubXFixed()), + SkFixedToScalar(glyph->getSubYFixed())); + } +#endif + matrix.mapRect(&bounds); // Round float bound values into integer. SkIRect ibounds = bounds.roundOut(); @@ -980,6 +987,12 @@ void SkScalerContext_DW::generateColorGlyphImage(const SkGlyph& glyph) { SkMatrix matrix = fSkXform; matrix.postTranslate(-SkIntToScalar(glyph.fLeft), -SkIntToScalar(glyph.fTop)); +#ifndef SK_IGNORE_EMOJI_SUBPIXEL_FIX + if (this->isSubpixel()) { + matrix.postTranslate(SkFixedToScalar(glyph.getSubXFixed()), + SkFixedToScalar(glyph.getSubYFixed())); + } +#endif SkRasterClip rc(SkIRect::MakeWH(glyph.fWidth, glyph.fHeight)); SkDraw draw; draw.fDst = SkPixmap(SkImageInfo::MakeN32(glyph.fWidth, glyph.fHeight, kPremul_SkAlphaType), -- cgit v1.2.3