Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 6c069da

Browse files
committed
[[ Bug 19675 ]] Disable LCD text rendering when backing layer is not opaque
1 parent 3b77f53 commit 6c069da

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

libgraphics/include/graphics.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,9 @@ uint32_t MCGContextGetHeight(MCGContextRef context);
885885
// invalid and all further operations will be no-ops.
886886
bool MCGContextIsValid(MCGContextRef context);
887887

888+
// Returns whether the current context layer is fully opaque or contains a transparency channel.
889+
bool MCGContextIsLayerOpaque(MCGContextRef context);
890+
888891
// Graphics state operations
889892
void MCGContextSave(MCGContextRef context);
890893
void MCGContextRestore(MCGContextRef context);

libgraphics/src/context.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,11 @@ bool MCGContextIsValid(MCGContextRef self)
572572
return self != NULL && self -> is_valid;
573573
}
574574

575+
bool MCGContextIsLayerOpaque(MCGContextRef self)
576+
{
577+
return SkAlphaTypeIsOpaque(self->layer->canvas->imageInfo().alphaType());
578+
}
579+
575580
////////////////////////////////////////////////////////////////////////////////
576581
// Graphics state operations
577582

libgraphics/src/directwrite-skia.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,10 @@ void MCGContextDrawPlatformText(MCGContextRef self, const unichar_t *p_text, uin
379379
t_paint.setColor(MCGColorToSkColor(self->state->fill_color));
380380
t_paint.setBlendMode(MCGBlendModeToSkBlendMode(self->state->blend_mode));
381381

382+
// disable LCD rendering when backing layer may be transparent
383+
if (!MCGContextIsLayerOpaque(self))
384+
t_paint.setLCDRenderText(false);
385+
382386
// Force anti-aliasing on so that we get nicely-rendered text
383387
t_paint.setAntiAlias(true);
384388

0 commit comments

Comments
 (0)