diff options
author | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2009-09-08 12:30:19 (GMT) |
---|---|---|
committer | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2009-09-21 14:21:18 (GMT) |
commit | 1b34feacef7a2d3ac005449a7cfbcb08a6bbf947 (patch) | |
tree | 939e0efa6c753c6fa963044a364942953c09f05a /src/opengl/gl2paintengineex/qglengineshadersource_p.h | |
parent | 423cbcf1a26ce208d5440ffa0c7cd150ccfd8b3a (diff) | |
download | Qt-1b34feacef7a2d3ac005449a7cfbcb08a6bbf947.zip Qt-1b34feacef7a2d3ac005449a7cfbcb08a6bbf947.tar.gz Qt-1b34feacef7a2d3ac005449a7cfbcb08a6bbf947.tar.bz2 |
Resubmit support for subpixel antialiasing on text in the GL2 engine.
The antialiasing is currently not gamma corrected and is disabled on
OpenGL ES 2.0.
Reviewed-by: Samuel
Diffstat (limited to 'src/opengl/gl2paintengineex/qglengineshadersource_p.h')
-rw-r--r-- | src/opengl/gl2paintengineex/qglengineshadersource_p.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index 6bcf010..8ae86d3 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -401,6 +401,39 @@ static const char* const qglslMaskFragmentShader = "\ return src * mask.a; \ }"; +// For source over with subpixel antialiasing, the final color is calculated per component as follows +// (.a is alpha component, .c is red, green or blue component): +// alpha = src.a * mask.c * opacity +// dest.c = dest.c * (1 - alpha) + src.c * alpha +// +// In the first pass, calculate: dest.c = dest.c * (1 - alpha) with blend funcs: zero, 1 - source color +// In the second pass, calculate: dest.c = dest.c + src.c * alpha with blend funcs: one, one +// +// If source is a solid color (src is constant), only the first pass is needed, with blend funcs: constant, 1 - source color + +// For source composition with subpixel antialiasing, the final color is calculated per component as follows: +// alpha = src.a * mask.c * opacity +// dest.c = dest.c * (1 - mask.c) + src.c * alpha +// + +static const char* const qglslRgbMaskFragmentShaderPass1 = "\ + varying highp vec2 textureCoords;\ + uniform lowp sampler2D maskTexture;\ + lowp vec4 applyMask(lowp vec4 src) \ + {\ + lowp vec4 mask = texture2D(maskTexture, textureCoords); \ + return src.a * mask; \ + }"; + +static const char* const qglslRgbMaskFragmentShaderPass2 = "\ + varying highp vec2 textureCoords;\ + uniform lowp sampler2D maskTexture;\ + lowp vec4 applyMask(lowp vec4 src) \ + {\ + lowp vec4 mask = texture2D(maskTexture, textureCoords); \ + return src * mask; \ + }"; + /* Left to implement: RgbMaskFragmentShader, |