[cairo] API to disable subpixel antialiasing per-surface

Robert O'Callahan robert at ocallahan.org
Mon Jan 10 04:58:19 PST 2011


When drawing to RGBA surfaces, we often want to disable subpixel
antialiasing and use grayscale antialiasing instead, because however one
crams three mask alpha values into a single destination alpha value, the
results are often bad.

Using cairo_font_options_set_antialias to disable subpixel antialiasing is
problematic. There is no way to request "the default, unless it's subpixel,
in which case grayscale". More importantly, it's difficult (in our
application at least) to route information about the target surface to all
the places where we might create fonts, where we'd need to call
cairo_font_options_set_antialias with the right options. This is especially
tricky because we cache fonts, so drawing the same objects to different
surfaces could require us to destroy and recreate fonts just to switch their
antialiasing mode.

A much simpler and more elegant solution is to add a new cairo surface API
that lets us disable subpixel antialiasing for all rendering to a given
surface, and let the surface backend text rendering code be responsible for
disabling subpixel antialiasing. This can be implemented with a very small
amount of code. To preserve cairo API compatibility, subpixel antialiasing
must be enabled by default (even for RGBA surfaces).

The attached patch (not properly formatted for the cairo git repository,
sorry) implements proposed new APIs cairo_surface_set_subpixel_antialiasing
and cairo_surface_get_subpixel_antialiasing. Comments welcome.

Thanks,
Rob
-- 
"Now the Bereans were of more noble character than the Thessalonians, for
they received the message with great eagerness and examined the Scriptures
every day to see if what Paul said was true." [Acts 17:11]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20110111/9403729e/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch
Type: application/octet-stream
Size: 19027 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20110111/9403729e/attachment-0001.obj>


More information about the cairo mailing list