Compare to the correct hinting.
Without this change no-hinting subpixel-antialias requests on Mac 10.14 will not be gamma adjusted when they should be. Bug: chromium:933137 Change-Id: I666f9f37ac849ed76a6b6aaab4966f4dd9fb5fb3 Reviewed-on: https://skia-review.googlesource.com/c/194188 Commit-Queue: Ben Wagner <bungeman@google.com> Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
parent
8c2ccf4764
commit
86c9c95b2e
@ -149,8 +149,7 @@ DEF_GM( return new TypefaceStylesGM(true); )
|
||||
static void draw_typeface_rendering_gm(SkCanvas* canvas, sk_sp<SkTypeface> face,
|
||||
char character = 'A') {
|
||||
struct AliasType {
|
||||
bool antiAlias;
|
||||
bool subpixelAntitalias;
|
||||
SkFont::Edging edging;
|
||||
bool inLayer;
|
||||
} constexpr aliasTypes[] {
|
||||
#ifndef SK_BUILD_FOR_IOS
|
||||
@ -164,24 +163,12 @@ static void draw_typeface_rendering_gm(SkCanvas* canvas, sk_sp<SkTypeface> face,
|
||||
// 0x330b19d8 <+88>: ldr r0, [r4, #0x4]
|
||||
// Disable testing embedded bitmaps on iOS for now.
|
||||
// See https://bug.skia.org/5530 .
|
||||
{ false, false, false }, // aliased
|
||||
{ SkFont::Edging::kAlias , false },
|
||||
#endif
|
||||
{ true, false, false }, // anti-aliased
|
||||
{ true, true , false }, // subpixel anti-aliased
|
||||
{ true, false, true }, // anti-aliased in layer (flat pixel geometry)
|
||||
{ true, true , true }, // subpixel anti-aliased in layer (flat pixel geometry)
|
||||
};
|
||||
|
||||
auto compute_edging = [](AliasType at) {
|
||||
if (at.antiAlias) {
|
||||
if (at.subpixelAntitalias) {
|
||||
return SkFont::Edging::kSubpixelAntiAlias;
|
||||
} else {
|
||||
return SkFont::Edging::kAntiAlias;
|
||||
}
|
||||
} else {
|
||||
return SkFont::Edging::kAlias;
|
||||
}
|
||||
{ SkFont::Edging::kAntiAlias , false },
|
||||
{ SkFont::Edging::kSubpixelAntiAlias, false },
|
||||
{ SkFont::Edging::kAntiAlias , true },
|
||||
{ SkFont::Edging::kSubpixelAntiAlias, true },
|
||||
};
|
||||
|
||||
// The hintgasp.ttf is designed for the following sizes to be different.
|
||||
@ -229,7 +216,7 @@ static void draw_typeface_rendering_gm(SkCanvas* canvas, sk_sp<SkTypeface> face,
|
||||
font.setSubpixel(subpixel.requested);
|
||||
|
||||
for (const AliasType& alias : aliasTypes) {
|
||||
font.setEdging(compute_edging(alias));
|
||||
font.setEdging(alias.edging);
|
||||
SkAutoCanvasRestore acr(canvas, false);
|
||||
if (alias.inLayer) {
|
||||
canvas->saveLayer(nullptr, &paint);
|
||||
@ -292,7 +279,7 @@ static void draw_typeface_rendering_gm(SkCanvas* canvas, sk_sp<SkTypeface> face,
|
||||
|
||||
font.setEmbolden(fakeBold);
|
||||
for (const AliasType& alias : aliasTypes) {
|
||||
font.setEdging(compute_edging(alias));
|
||||
font.setEdging(alias.edging);
|
||||
SkAutoCanvasRestore acr(canvas, false);
|
||||
if (alias.inLayer) {
|
||||
canvas->saveLayer(nullptr, &paint);
|
||||
@ -343,7 +330,7 @@ static void draw_typeface_rendering_gm(SkCanvas* canvas, sk_sp<SkTypeface> face,
|
||||
y += dy;
|
||||
x = 5;
|
||||
|
||||
font.setEdging(compute_edging(alias));
|
||||
font.setEdging(alias.edging);
|
||||
SkAutoCanvasRestore acr(canvas, false);
|
||||
if (alias.inLayer) {
|
||||
canvas->saveLayer(nullptr, &paint);
|
||||
|
@ -2230,16 +2230,17 @@ void SkTypeface_Mac::onFilterRec(SkScalerContextRec* rec) const {
|
||||
SmoothBehavior smoothBehavior = smooth_behavior();
|
||||
|
||||
// Only two levels of hinting are supported.
|
||||
// kNo_Hinting means avoid CoreGraphics outline dilation.
|
||||
// kNormal_Hinting means CoreGraphics outline dilation is allowed.
|
||||
// If there is no lcd support, hinting (dilation) cannot be supported.
|
||||
SkFontHinting hinting = rec->getHinting();
|
||||
if (kSlight_SkFontHinting == hinting || smoothBehavior == SmoothBehavior::none) {
|
||||
hinting = kNo_SkFontHinting;
|
||||
} else if (kFull_SkFontHinting == hinting) {
|
||||
hinting = kNormal_SkFontHinting;
|
||||
// kNo_Hinting means avoid CoreGraphics outline dilation (smoothing).
|
||||
// kNormal_Hinting means CoreGraphics outline dilation (smoothing) is allowed.
|
||||
if (kSlight_SkFontHinting == rec->getHinting()) {
|
||||
rec->setHinting(kNo_SkFontHinting);
|
||||
} else if (kFull_SkFontHinting == rec->getHinting()) {
|
||||
rec->setHinting(kNormal_SkFontHinting);
|
||||
}
|
||||
// If smoothing has no effect, don't request it.
|
||||
if (smoothBehavior == SmoothBehavior::none) {
|
||||
rec->setHinting(kNo_SkFontHinting);
|
||||
}
|
||||
rec->setHinting(hinting);
|
||||
|
||||
// FIXME: lcd smoothed un-hinted rasterization unsupported.
|
||||
// Tracked by http://code.google.com/p/skia/issues/detail?id=915 .
|
||||
@ -2259,7 +2260,6 @@ void SkTypeface_Mac::onFilterRec(SkScalerContextRec* rec) const {
|
||||
// [LCD][no-hint]: curently unable to honor, and must pick which to respect.
|
||||
// Currenly side with LCD, effectively ignoring the hinting setting.
|
||||
// [LCD][yes-hint]: generate LCD using CoreGraphic's LCD output.
|
||||
|
||||
if (rec->fMaskFormat == SkMask::kLCD16_Format) {
|
||||
if (smoothBehavior == SmoothBehavior::subpixel) {
|
||||
//CoreGraphics creates 555 masks for smoothed text anyway.
|
||||
@ -2267,7 +2267,7 @@ void SkTypeface_Mac::onFilterRec(SkScalerContextRec* rec) const {
|
||||
rec->setHinting(kNormal_SkFontHinting);
|
||||
} else {
|
||||
rec->fMaskFormat = SkMask::kA8_Format;
|
||||
if (smoothBehavior == SmoothBehavior::some) {
|
||||
if (smoothBehavior != SmoothBehavior::none) {
|
||||
rec->setHinting(kNormal_SkFontHinting);
|
||||
}
|
||||
}
|
||||
@ -2282,7 +2282,7 @@ void SkTypeface_Mac::onFilterRec(SkScalerContextRec* rec) const {
|
||||
|
||||
// Unhinted A8 masks (those not derived from LCD masks) must respect SK_GAMMA_APPLY_TO_A8.
|
||||
// All other masks can use regular gamma.
|
||||
if (SkMask::kA8_Format == rec->fMaskFormat && kNo_SkFontHinting == hinting) {
|
||||
if (SkMask::kA8_Format == rec->fMaskFormat && kNo_SkFontHinting == rec->getHinting()) {
|
||||
#ifndef SK_GAMMA_APPLY_TO_A8
|
||||
// SRGBTODO: Is this correct? Do we want contrast boost?
|
||||
rec->ignorePreBlend();
|
||||
|
Loading…
Reference in New Issue
Block a user