From 7fb30f11a05583f75337f10ebfbe1f07307bfddf Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Fri, 16 Nov 2018 21:39:41 -0500 Subject: [PATCH] use font for settings Bug: skia: Change-Id: Ia1ebd888bf0f0ce9c0c6dfdceff92be59db02a85 Reviewed-on: https://skia-review.googlesource.com/c/171650 Reviewed-by: Mike Reed Commit-Queue: Mike Reed --- src/core/SkFont.cpp | 10 +++++++--- src/core/SkScalerContext.cpp | 22 ++++++++++------------ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/core/SkFont.cpp b/src/core/SkFont.cpp index 78f4f9a04b78d..4adae4733be30 100644 --- a/src/core/SkFont.cpp +++ b/src/core/SkFont.cpp @@ -96,6 +96,10 @@ SkScalar SkFont::setupForAsPaths(SkPaint* paint) { fFlags = (fFlags & ~flagsToIgnore) | kSubpixel_PrivFlag; this->setHinting(kNo_SkFontHinting); + if (this->getEdging() == Edging::kSubpixelAntiAlias) { + this->setEdging(Edging::kAntiAlias); + } + if (paint) { paint->setStyle(SkPaint::kFill_Style); paint->setPathEffect(nullptr); @@ -379,9 +383,9 @@ SkFont SkFont::LEGACY_ExtractFromPaint(const SkPaint& paint) { Edging edging = Edging::kAlias; if (paint.isAntiAlias()) { edging = Edging::kAntiAlias; - } - if (paint.isLCDRenderText()) { - edging = Edging::kSubpixelAntiAlias; + if (paint.isLCDRenderText()) { + edging = Edging::kSubpixelAntiAlias; + } } SkFont font(sk_ref_sp(paint.getTypeface()), paint.getTextSize(), paint.getTextScaleX(), diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp index a0e77b44a449c..551a7696c7873 100644 --- a/src/core/SkScalerContext.cpp +++ b/src/core/SkScalerContext.cpp @@ -854,18 +854,16 @@ static SkScalar sk_relax(SkScalar x) { return n / 1024.0f; } -static SkMask::Format compute_mask_format(const SkPaint& paint) { - uint32_t flags = paint.getFlags(); - - // Antialiasing being disabled trumps all other settings. - if (!(flags & SkPaint::kAntiAlias_Flag)) { - return SkMask::kBW_Format; - } - - if (flags & SkPaint::kLCDRenderText_Flag) { - return SkMask::kLCD16_Format; +static SkMask::Format compute_mask_format(const SkFont& font) { + switch (font.getEdging()) { + case SkFont::Edging::kAlias: + return SkMask::kBW_Format; + case SkFont::Edging::kAntiAlias: + return SkMask::kA8_Format; + case SkFont::Edging::kSubpixelAntiAlias: + return SkMask::kLCD16_Format; } - + SkASSERT(false); return SkMask::kA8_Format; } @@ -976,7 +974,7 @@ void SkScalerContext::MakeRecAndEffects(const SkFont& font, const SkPaint& paint rec->fStrokeCap = 0; } - rec->fMaskFormat = SkToU8(compute_mask_format(paint)); + rec->fMaskFormat = SkToU8(compute_mask_format(font)); if (SkMask::kLCD16_Format == rec->fMaskFormat) { if (too_big_for_lcd(*rec, checkPost2x2)) {