| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the QtOpenGL module of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | //
|
|---|
| 43 | // W A R N I N G
|
|---|
| 44 | // -------------
|
|---|
| 45 | //
|
|---|
| 46 | // This file is not part of the Qt API. It exists purely as an
|
|---|
| 47 | // implementation detail. This header file may change from version to
|
|---|
| 48 | // version without notice, or even be removed.
|
|---|
| 49 | //
|
|---|
| 50 | // We mean it.
|
|---|
| 51 | //
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 | #ifndef QGL_ENGINE_SHADER_SOURCE_H
|
|---|
| 55 | #define QGL_ENGINE_SHADER_SOURCE_H
|
|---|
| 56 |
|
|---|
| 57 | #include "qglengineshadermanager_p.h"
|
|---|
| 58 |
|
|---|
| 59 | QT_BEGIN_HEADER
|
|---|
| 60 |
|
|---|
| 61 | QT_BEGIN_NAMESPACE
|
|---|
| 62 |
|
|---|
| 63 | QT_MODULE(OpenGL)
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | static const char* const qglslMainVertexShader = "\
|
|---|
| 67 | uniform highp float depth;\
|
|---|
| 68 | void setPosition();\
|
|---|
| 69 | void main(void)\
|
|---|
| 70 | {\
|
|---|
| 71 | setPosition();\
|
|---|
| 72 | gl_Position.z = depth * gl_Position.w;\
|
|---|
| 73 | }";
|
|---|
| 74 |
|
|---|
| 75 | static const char* const qglslMainWithTexCoordsVertexShader = "\
|
|---|
| 76 | attribute highp vec2 textureCoordArray; \
|
|---|
| 77 | varying highp vec2 textureCoords; \
|
|---|
| 78 | uniform highp float depth;\
|
|---|
| 79 | void setPosition();\
|
|---|
| 80 | void main(void) \
|
|---|
| 81 | {\
|
|---|
| 82 | setPosition();\
|
|---|
| 83 | gl_Position.z = depth * gl_Position.w;\
|
|---|
| 84 | textureCoords = textureCoordArray; \
|
|---|
| 85 | }";
|
|---|
| 86 |
|
|---|
| 87 | static const char* const qglslMainWithTexCoordsAndOpacityVertexShader = "\
|
|---|
| 88 | attribute highp vec2 textureCoordArray; \
|
|---|
| 89 | attribute lowp float opacityArray; \
|
|---|
| 90 | varying highp vec2 textureCoords; \
|
|---|
| 91 | varying lowp float opacity; \
|
|---|
| 92 | uniform highp float depth; \
|
|---|
| 93 | void setPosition(); \
|
|---|
| 94 | void main(void) \
|
|---|
| 95 | { \
|
|---|
| 96 | setPosition(); \
|
|---|
| 97 | gl_Position.z = depth * gl_Position.w; \
|
|---|
| 98 | textureCoords = textureCoordArray; \
|
|---|
| 99 | opacity = opacityArray; \
|
|---|
| 100 | }";
|
|---|
| 101 |
|
|---|
| 102 | // NOTE: We let GL do the perspective correction so texture lookups in the fragment
|
|---|
| 103 | // shader are also perspective corrected.
|
|---|
| 104 | static const char* const qglslPositionOnlyVertexShader = "\
|
|---|
| 105 | attribute highp vec2 vertexCoordsArray;\
|
|---|
| 106 | uniform highp mat3 pmvMatrix;\
|
|---|
| 107 | void setPosition(void)\
|
|---|
| 108 | {\
|
|---|
| 109 | vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \
|
|---|
| 110 | gl_Position = vec4(transformedPos.xy, 0.0, transformedPos.z); \
|
|---|
| 111 | }";
|
|---|
| 112 |
|
|---|
| 113 | static const char* const qglslUntransformedPositionVertexShader = "\
|
|---|
| 114 | attribute highp vec4 vertexCoordsArray;\
|
|---|
| 115 | void setPosition(void)\
|
|---|
| 116 | {\
|
|---|
| 117 | gl_Position = vertexCoordsArray;\
|
|---|
| 118 | }";
|
|---|
| 119 |
|
|---|
| 120 | // Pattern Brush - This assumes the texture size is 8x8 and thus, the inverted size is 0.125
|
|---|
| 121 | static const char* const qglslPositionWithPatternBrushVertexShader = "\
|
|---|
| 122 | attribute highp vec2 vertexCoordsArray; \
|
|---|
| 123 | uniform highp mat3 pmvMatrix; \
|
|---|
| 124 | uniform mediump vec2 halfViewportSize; \
|
|---|
| 125 | uniform highp vec2 invertedTextureSize; \
|
|---|
| 126 | uniform highp mat3 brushTransform; \
|
|---|
| 127 | varying highp vec2 patternTexCoords; \
|
|---|
| 128 | void setPosition(void) { \
|
|---|
| 129 | vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \
|
|---|
| 130 | gl_Position.xy = transformedPos.xy / transformedPos.z; \
|
|---|
| 131 | mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \
|
|---|
| 132 | mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1.0); \
|
|---|
| 133 | mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \
|
|---|
| 134 | gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \
|
|---|
| 135 | patternTexCoords.xy = (hTexCoords.xy * 0.125) * invertedHTexCoordsZ; \
|
|---|
| 136 | }";
|
|---|
| 137 |
|
|---|
| 138 | static const char* const qglslAffinePositionWithPatternBrushVertexShader
|
|---|
| 139 | = qglslPositionWithPatternBrushVertexShader;
|
|---|
| 140 |
|
|---|
| 141 | static const char* const qglslPatternBrushSrcFragmentShader = "\
|
|---|
| 142 | uniform lowp sampler2D brushTexture;\
|
|---|
| 143 | uniform lowp vec4 patternColor; \
|
|---|
| 144 | varying highp vec2 patternTexCoords;\
|
|---|
| 145 | lowp vec4 srcPixel() { \
|
|---|
| 146 | return patternColor * (1.0 - texture2D(brushTexture, patternTexCoords).r); \
|
|---|
| 147 | }\n";
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 | // Linear Gradient Brush
|
|---|
| 151 | static const char* const qglslPositionWithLinearGradientBrushVertexShader = "\
|
|---|
| 152 | attribute highp vec2 vertexCoordsArray; \
|
|---|
| 153 | uniform highp mat3 pmvMatrix; \
|
|---|
| 154 | uniform mediump vec2 halfViewportSize; \
|
|---|
| 155 | uniform highp vec3 linearData; \
|
|---|
| 156 | uniform highp mat3 brushTransform; \
|
|---|
| 157 | varying mediump float index; \
|
|---|
| 158 | void setPosition() { \
|
|---|
| 159 | vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \
|
|---|
| 160 | gl_Position.xy = transformedPos.xy / transformedPos.z; \
|
|---|
| 161 | mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \
|
|---|
| 162 | mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \
|
|---|
| 163 | mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \
|
|---|
| 164 | gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \
|
|---|
| 165 | index = (dot(linearData.xy, hTexCoords.xy) * linearData.z) * invertedHTexCoordsZ; \
|
|---|
| 166 | }";
|
|---|
| 167 |
|
|---|
| 168 | static const char* const qglslAffinePositionWithLinearGradientBrushVertexShader
|
|---|
| 169 | = qglslPositionWithLinearGradientBrushVertexShader;
|
|---|
| 170 |
|
|---|
| 171 | static const char* const qglslLinearGradientBrushSrcFragmentShader = "\
|
|---|
| 172 | uniform lowp sampler2D brushTexture; \
|
|---|
| 173 | varying mediump float index; \
|
|---|
| 174 | lowp vec4 srcPixel() { \
|
|---|
| 175 | mediump vec2 val = vec2(index, 0.5); \
|
|---|
| 176 | return texture2D(brushTexture, val); \
|
|---|
| 177 | }\n";
|
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 | // Conical Gradient Brush
|
|---|
| 181 | static const char* const qglslPositionWithConicalGradientBrushVertexShader = "\
|
|---|
| 182 | attribute highp vec2 vertexCoordsArray;\
|
|---|
| 183 | uniform highp mat3 pmvMatrix;\
|
|---|
| 184 | uniform mediump vec2 halfViewportSize; \
|
|---|
| 185 | uniform highp mat3 brushTransform; \
|
|---|
| 186 | varying highp vec2 A; \
|
|---|
| 187 | void setPosition(void)\
|
|---|
| 188 | {\
|
|---|
| 189 | vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \
|
|---|
| 190 | gl_Position.xy = transformedPos.xy / transformedPos.z; \
|
|---|
| 191 | mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \
|
|---|
| 192 | mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \
|
|---|
| 193 | mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \
|
|---|
| 194 | gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \
|
|---|
| 195 | A = hTexCoords.xy * invertedHTexCoordsZ; \
|
|---|
| 196 | }";
|
|---|
| 197 |
|
|---|
| 198 | static const char* const qglslAffinePositionWithConicalGradientBrushVertexShader
|
|---|
| 199 | = qglslPositionWithConicalGradientBrushVertexShader;
|
|---|
| 200 |
|
|---|
| 201 | static const char* const qglslConicalGradientBrushSrcFragmentShader = "\n\
|
|---|
| 202 | #define INVERSE_2PI 0.1591549430918953358 \n\
|
|---|
| 203 | uniform lowp sampler2D brushTexture; \n\
|
|---|
| 204 | uniform mediump float angle; \
|
|---|
| 205 | varying highp vec2 A; \
|
|---|
| 206 | lowp vec4 srcPixel() { \
|
|---|
| 207 | highp float t; \
|
|---|
| 208 | if (abs(A.y) == abs(A.x)) \
|
|---|
| 209 | t = (atan(-A.y + 0.002, A.x) + angle) * INVERSE_2PI; \
|
|---|
| 210 | else \
|
|---|
| 211 | t = (atan(-A.y, A.x) + angle) * INVERSE_2PI; \
|
|---|
| 212 | return texture2D(brushTexture, vec2(t - floor(t), 0.5)); \
|
|---|
| 213 | }";
|
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 | // Radial Gradient Brush
|
|---|
| 217 | static const char* const qglslPositionWithRadialGradientBrushVertexShader = "\
|
|---|
| 218 | attribute highp vec2 vertexCoordsArray;\
|
|---|
| 219 | uniform highp mat3 pmvMatrix;\
|
|---|
| 220 | uniform mediump vec2 halfViewportSize; \
|
|---|
| 221 | uniform highp mat3 brushTransform; \
|
|---|
| 222 | uniform highp vec2 fmp; \
|
|---|
| 223 | varying highp float b; \
|
|---|
| 224 | varying highp vec2 A; \
|
|---|
| 225 | void setPosition(void) \
|
|---|
| 226 | {\
|
|---|
| 227 | vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \
|
|---|
| 228 | gl_Position.xy = transformedPos.xy / transformedPos.z; \
|
|---|
| 229 | mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \
|
|---|
| 230 | mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \
|
|---|
| 231 | mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \
|
|---|
| 232 | gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \
|
|---|
| 233 | A = hTexCoords.xy * invertedHTexCoordsZ; \
|
|---|
| 234 | b = 2.0 * dot(A, fmp); \
|
|---|
| 235 | }";
|
|---|
| 236 |
|
|---|
| 237 | static const char* const qglslAffinePositionWithRadialGradientBrushVertexShader
|
|---|
| 238 | = qglslPositionWithRadialGradientBrushVertexShader;
|
|---|
| 239 |
|
|---|
| 240 | static const char* const qglslRadialGradientBrushSrcFragmentShader = "\
|
|---|
| 241 | uniform lowp sampler2D brushTexture; \
|
|---|
| 242 | uniform highp float fmp2_m_radius2; \
|
|---|
| 243 | uniform highp float inverse_2_fmp2_m_radius2; \
|
|---|
| 244 | varying highp float b; \
|
|---|
| 245 | varying highp vec2 A; \
|
|---|
| 246 | lowp vec4 srcPixel() { \
|
|---|
| 247 | highp float c = -dot(A, A); \
|
|---|
| 248 | highp vec2 val = vec2((-b + sqrt(b*b - 4.0*fmp2_m_radius2*c)) * inverse_2_fmp2_m_radius2, 0.5); \
|
|---|
| 249 | return texture2D(brushTexture, val); \
|
|---|
| 250 | }";
|
|---|
| 251 |
|
|---|
| 252 |
|
|---|
| 253 | // Texture Brush
|
|---|
| 254 | static const char* const qglslPositionWithTextureBrushVertexShader = "\
|
|---|
| 255 | attribute highp vec2 vertexCoordsArray; \
|
|---|
| 256 | uniform highp mat3 pmvMatrix; \
|
|---|
| 257 | uniform mediump vec2 halfViewportSize; \
|
|---|
| 258 | uniform highp vec2 invertedTextureSize; \
|
|---|
| 259 | uniform highp mat3 brushTransform; \
|
|---|
| 260 | varying highp vec2 textureCoords; \
|
|---|
| 261 | void setPosition(void) { \
|
|---|
| 262 | vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \
|
|---|
| 263 | gl_Position.xy = transformedPos.xy / transformedPos.z; \
|
|---|
| 264 | mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \
|
|---|
| 265 | mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \
|
|---|
| 266 | mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \
|
|---|
| 267 | gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \
|
|---|
| 268 | textureCoords.xy = (hTexCoords.xy * invertedTextureSize) * gl_Position.w; \
|
|---|
| 269 | }";
|
|---|
| 270 |
|
|---|
| 271 | static const char* const qglslAffinePositionWithTextureBrushVertexShader
|
|---|
| 272 | = qglslPositionWithTextureBrushVertexShader;
|
|---|
| 273 |
|
|---|
| 274 | #if defined(QT_OPENGL_ES_2)
|
|---|
| 275 | // OpenGL ES does not support GL_REPEAT wrap modes for NPOT textures. So instead,
|
|---|
| 276 | // we emulate GL_REPEAT by only taking the fractional part of the texture coords.
|
|---|
| 277 | // TODO: Special case POT textures which don't need this emulation
|
|---|
| 278 | static const char* const qglslTextureBrushSrcFragmentShader = "\
|
|---|
| 279 | varying highp vec2 textureCoords; \
|
|---|
| 280 | uniform lowp sampler2D brushTexture; \
|
|---|
| 281 | lowp vec4 srcPixel() { \
|
|---|
| 282 | return texture2D(brushTexture, fract(textureCoords)); \
|
|---|
| 283 | }";
|
|---|
| 284 | #else
|
|---|
| 285 | static const char* const qglslTextureBrushSrcFragmentShader = "\
|
|---|
| 286 | varying highp vec2 textureCoords; \
|
|---|
| 287 | uniform lowp sampler2D brushTexture; \
|
|---|
| 288 | lowp vec4 srcPixel() { \
|
|---|
| 289 | return texture2D(brushTexture, textureCoords); \
|
|---|
| 290 | }";
|
|---|
| 291 | #endif
|
|---|
| 292 |
|
|---|
| 293 | static const char* const qglslTextureBrushSrcWithPatternFragmentShader = "\
|
|---|
| 294 | varying highp vec2 textureCoords; \
|
|---|
| 295 | uniform lowp vec4 patternColor; \
|
|---|
| 296 | uniform lowp sampler2D brushTexture; \
|
|---|
| 297 | lowp vec4 srcPixel() { \
|
|---|
| 298 | return patternColor * (1.0 - texture2D(brushTexture, textureCoords).r); \
|
|---|
| 299 | }";
|
|---|
| 300 |
|
|---|
| 301 | // Solid Fill Brush
|
|---|
| 302 | static const char* const qglslSolidBrushSrcFragmentShader = "\
|
|---|
| 303 | uniform lowp vec4 fragmentColor; \
|
|---|
| 304 | lowp vec4 srcPixel() { \
|
|---|
| 305 | return fragmentColor; \
|
|---|
| 306 | }";
|
|---|
| 307 |
|
|---|
| 308 | static const char* const qglslImageSrcFragmentShader = "\
|
|---|
| 309 | varying highp vec2 textureCoords; \
|
|---|
| 310 | uniform lowp sampler2D imageTexture; \
|
|---|
| 311 | lowp vec4 srcPixel() { \
|
|---|
| 312 | return texture2D(imageTexture, textureCoords); \
|
|---|
| 313 | }";
|
|---|
| 314 |
|
|---|
| 315 | static const char* const qglslCustomSrcFragmentShader = "\
|
|---|
| 316 | varying highp vec2 textureCoords; \
|
|---|
| 317 | uniform lowp sampler2D imageTexture; \
|
|---|
| 318 | lowp vec4 customShader(lowp sampler2D texture, highp vec2 coords); \
|
|---|
| 319 | lowp vec4 srcPixel() { \
|
|---|
| 320 | return customShader(imageTexture, textureCoords); \
|
|---|
| 321 | }";
|
|---|
| 322 |
|
|---|
| 323 | static const char* const qglslImageSrcWithPatternFragmentShader = "\
|
|---|
| 324 | varying highp vec2 textureCoords; \
|
|---|
| 325 | uniform lowp vec4 patternColor; \
|
|---|
| 326 | uniform lowp sampler2D imageTexture; \
|
|---|
| 327 | lowp vec4 srcPixel() { \
|
|---|
| 328 | return patternColor * (1.0 - texture2D(imageTexture, textureCoords).r); \
|
|---|
| 329 | }\n";
|
|---|
| 330 |
|
|---|
| 331 | static const char* const qglslNonPremultipliedImageSrcFragmentShader = "\
|
|---|
| 332 | varying highp vec2 textureCoords; \
|
|---|
| 333 | uniform lowp sampler2D imageTexture; \
|
|---|
| 334 | lowp vec4 srcPixel() { \
|
|---|
| 335 | lowp vec4 sample = texture2D(imageTexture, textureCoords); \
|
|---|
| 336 | sample.rgb = sample.rgb * sample.a; \
|
|---|
| 337 | return sample; \
|
|---|
| 338 | }";
|
|---|
| 339 |
|
|---|
| 340 | static const char* const qglslShockingPinkSrcFragmentShader = "\
|
|---|
| 341 | lowp vec4 srcPixel() { \
|
|---|
| 342 | return vec4(0.98, 0.06, 0.75, 1.0); \
|
|---|
| 343 | }";
|
|---|
| 344 |
|
|---|
| 345 | static const char* const qglslMainFragmentShader_ImageArrays = "\
|
|---|
| 346 | varying lowp float opacity; \
|
|---|
| 347 | lowp vec4 srcPixel(); \
|
|---|
| 348 | void main() { \
|
|---|
| 349 | gl_FragColor = srcPixel() * opacity; \
|
|---|
| 350 | }";
|
|---|
| 351 |
|
|---|
| 352 | static const char* const qglslMainFragmentShader_CMO = "\
|
|---|
| 353 | uniform lowp float globalOpacity; \
|
|---|
| 354 | lowp vec4 srcPixel(); \
|
|---|
| 355 | lowp vec4 applyMask(lowp vec4); \
|
|---|
| 356 | lowp vec4 compose(lowp vec4); \
|
|---|
| 357 | void main() { \
|
|---|
| 358 | gl_FragColor = applyMask(compose(srcPixel()*globalOpacity))); \
|
|---|
| 359 | }";
|
|---|
| 360 |
|
|---|
| 361 | static const char* const qglslMainFragmentShader_CM = "\
|
|---|
| 362 | lowp vec4 srcPixel(); \
|
|---|
| 363 | lowp vec4 applyMask(lowp vec4); \
|
|---|
| 364 | lowp vec4 compose(lowp vec4); \
|
|---|
| 365 | void main() { \
|
|---|
| 366 | gl_FragColor = applyMask(compose(srcPixel())); \
|
|---|
| 367 | }";
|
|---|
| 368 |
|
|---|
| 369 | static const char* const qglslMainFragmentShader_MO = "\
|
|---|
| 370 | uniform lowp float globalOpacity; \
|
|---|
| 371 | lowp vec4 srcPixel(); \
|
|---|
| 372 | lowp vec4 applyMask(lowp vec4); \
|
|---|
| 373 | void main() { \
|
|---|
| 374 | gl_FragColor = applyMask(srcPixel()*globalOpacity); \
|
|---|
| 375 | }";
|
|---|
| 376 |
|
|---|
| 377 | static const char* const qglslMainFragmentShader_M = "\
|
|---|
| 378 | lowp vec4 srcPixel(); \
|
|---|
| 379 | lowp vec4 applyMask(lowp vec4); \
|
|---|
| 380 | void main() { \
|
|---|
| 381 | gl_FragColor = applyMask(srcPixel()); \
|
|---|
| 382 | }";
|
|---|
| 383 |
|
|---|
| 384 | static const char* const qglslMainFragmentShader_CO = "\
|
|---|
| 385 | uniform lowp float globalOpacity; \
|
|---|
| 386 | lowp vec4 srcPixel(); \
|
|---|
| 387 | lowp vec4 compose(lowp vec4); \
|
|---|
| 388 | void main() { \
|
|---|
| 389 | gl_FragColor = compose(srcPixel()*globalOpacity); \
|
|---|
| 390 | }";
|
|---|
| 391 |
|
|---|
| 392 | static const char* const qglslMainFragmentShader_C = "\
|
|---|
| 393 | lowp vec4 srcPixel(); \
|
|---|
| 394 | lowp vec4 compose(lowp vec4); \
|
|---|
| 395 | void main() { \
|
|---|
| 396 | gl_FragColor = compose(srcPixel()); \
|
|---|
| 397 | }";
|
|---|
| 398 |
|
|---|
| 399 | static const char* const qglslMainFragmentShader_O = "\
|
|---|
| 400 | uniform lowp float globalOpacity; \
|
|---|
| 401 | lowp vec4 srcPixel(); \
|
|---|
| 402 | void main() { \
|
|---|
| 403 | gl_FragColor = srcPixel()*globalOpacity; \
|
|---|
| 404 | }";
|
|---|
| 405 |
|
|---|
| 406 | static const char* const qglslMainFragmentShader = "\
|
|---|
| 407 | lowp vec4 srcPixel(); \
|
|---|
| 408 | void main() { \
|
|---|
| 409 | gl_FragColor = srcPixel(); \
|
|---|
| 410 | }";
|
|---|
| 411 |
|
|---|
| 412 | static const char* const qglslMaskFragmentShader = "\
|
|---|
| 413 | varying highp vec2 textureCoords;\
|
|---|
| 414 | uniform lowp sampler2D maskTexture;\
|
|---|
| 415 | lowp vec4 applyMask(lowp vec4 src) \
|
|---|
| 416 | {\
|
|---|
| 417 | lowp vec4 mask = texture2D(maskTexture, textureCoords); \
|
|---|
| 418 | return src * mask.a; \
|
|---|
| 419 | }";
|
|---|
| 420 |
|
|---|
| 421 | // For source over with subpixel antialiasing, the final color is calculated per component as follows
|
|---|
|
|---|