diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2011-05-03 13:06:13 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2011-05-03 14:54:53 (GMT) |
commit | 79ba7cceca5e4029876ace2121edd25b08ae14ce (patch) | |
tree | 9a05d87d68d3ba09053fabd1cfa3343de8da903d /src/gui | |
parent | 782535ac548c582542bd1c17207e288e816870a8 (diff) | |
download | Qt-79ba7cceca5e4029876ace2121edd25b08ae14ce.zip Qt-79ba7cceca5e4029876ace2121edd25b08ae14ce.tar.gz Qt-79ba7cceca5e4029876ace2121edd25b08ae14ce.tar.bz2 |
Support gamma correction of text on GL
If the SRGB framebuffer extension in GL is available, we can support
gamma correction of text with a gamma of 2.1. On Mac this is
sufficient for gamma correcting subpixel antialiased text. Gray
antialiasing should not be gamma corrected on Mac.
On Windows, the user can potentially set the gamma value to anything
between 1.0 and 2.2 (or something like that). We support anything
that resembles 1.0 closely enough by pushing the text out without
any correction (like before). We also support anything that resembles
2.1 (the gamma hardcoded in GL's SRGB extension) by turning on the
extension before blending the text. In between the two, we'll use
gray antialiasing to avoid differing too much from the raster engine
(which is our reference in this.)
For gray antialiasing on Windows, we use a constant gamma of 2.3 which
has been determined by experimentation. Since this is close enough to
2.1 we do gamma correction with SRGB extension.
The distance limit of 0.2 is determined by some experimentation.
Reviewed-by: Samuel
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qapplication_win.cpp | 13 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper.cpp | 10 |
2 files changed, 14 insertions, 9 deletions
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 6658300..a3a9ff1 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -237,6 +237,7 @@ static void resolveAygLibs() # define FE_FONTSMOOTHINGCLEARTYPE 0x0002 #endif +Q_GUI_EXPORT qreal qt_fontsmoothing_gamma; Q_GUI_EXPORT bool qt_cleartype_enabled; Q_GUI_EXPORT bool qt_win_owndc_required; // CS_OWNDC is required if we use the GL graphicssystem as default @@ -653,8 +654,18 @@ static void qt_win_read_cleartype_settings() if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0)) qt_cleartype_enabled = (result == FE_FONTSMOOTHINGCLEARTYPE); #endif -} + int winSmooth; + if (SystemParametersInfo(SPI_GETFONTSMOOTHINGCONTRAST, 0, &winSmooth, 0)) { + qt_fontsmoothing_gamma = winSmooth / qreal(1000.0); + } else { + qt_fontsmoothing_gamma = 1.0; + } + + // Safeguard ourselves against corrupt registry values... + if (qt_fontsmoothing_gamma > 5 || qt_fontsmoothing_gamma < 1) + qt_fontsmoothing_gamma = qreal(1.4); +} static void qt_set_windows_resources() { diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index ae9993e..360292c 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -7068,14 +7068,8 @@ void qt_build_pow_tables() { #endif #ifdef Q_WS_WIN - int winSmooth; - if (SystemParametersInfo(0x200C /* SPI_GETFONTSMOOTHINGCONTRAST */, 0, &winSmooth, 0)) - smoothing = winSmooth / qreal(1000.0); - - // Safeguard ourselves against corrupt registry values... - if (smoothing > 5 || smoothing < 1) - smoothing = qreal(1.4); - + extern qreal qt_fontsmoothing_gamma; // qapplication_win.cpp + smoothing = qt_fontsmoothing_gamma; #endif #ifdef Q_WS_X11 |