- Timestamp:
- Mar 8, 2010, 12:52:58 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.2 (added) merged: 650 /branches/vendor/nokia/qt/current merged: 649 /branches/vendor/nokia/qt/4.6.1 removed
- Property svn:mergeinfo changed
-
trunk/src/opengl/gl2paintengineex/qglengineshadersource_p.h
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 64 64 65 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 }"; 66 static const char* const qglslMainVertexShader = "\n\ 67 void setPosition(); \n\ 68 void main(void) \n\ 69 { \n\ 70 setPosition(); \n\ 71 }\n"; 72 73 static const char* const qglslMainWithTexCoordsVertexShader = "\n\ 74 attribute highp vec2 textureCoordArray; \n\ 75 varying highp vec2 textureCoords; \n\ 76 void setPosition(); \n\ 77 void main(void) \n\ 78 { \n\ 79 setPosition(); \n\ 80 textureCoords = textureCoordArray; \n\ 81 }\n"; 82 83 static const char* const qglslMainWithTexCoordsAndOpacityVertexShader = "\n\ 84 attribute highp vec2 textureCoordArray; \n\ 85 attribute lowp float opacityArray; \n\ 86 varying highp vec2 textureCoords; \n\ 87 varying lowp float opacity; \n\ 88 void setPosition(); \n\ 89 void main(void) \n\ 90 { \n\ 91 setPosition(); \n\ 92 textureCoords = textureCoordArray; \n\ 93 opacity = opacityArray; \n\ 94 }\n"; 101 95 102 96 // NOTE: We let GL do the perspective correction so texture lookups in the fragment 103 97 // 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 }"; 98 static const char* const qglslPositionOnlyVertexShader = "\n\ 99 attribute highp vec2 vertexCoordsArray; \n\ 100 attribute highp vec3 pmvMatrix1; \n\ 101 attribute highp vec3 pmvMatrix2; \n\ 102 attribute highp vec3 pmvMatrix3; \n\ 103 void setPosition(void) \n\ 104 { \n\ 105 highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ 106 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ 107 gl_Position = vec4(transformedPos.xy, 0.0, transformedPos.z); \n\ 108 }\n"; 109 110 static const char* const qglslUntransformedPositionVertexShader = "\n\ 111 attribute highp vec4 vertexCoordsArray; \n\ 112 void setPosition(void) \n\ 113 { \n\ 114 gl_Position = vertexCoordsArray; \n\ 115 }\n"; 119 116 120 117 // 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 }"; 118 static const char* const qglslPositionWithPatternBrushVertexShader = "\n\ 119 attribute highp vec2 vertexCoordsArray; \n\ 120 attribute highp vec3 pmvMatrix1; \n\ 121 attribute highp vec3 pmvMatrix2; \n\ 122 attribute highp vec3 pmvMatrix3; \n\ 123 uniform mediump vec2 halfViewportSize; \n\ 124 uniform highp vec2 invertedTextureSize; \n\ 125 uniform highp mat3 brushTransform; \n\ 126 varying highp vec2 patternTexCoords; \n\ 127 void setPosition(void) \n\ 128 { \n\ 129 highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ 130 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ 131 gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ 132 mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ 133 mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1.0); \n\ 134 mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ 135 gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ 136 patternTexCoords.xy = (hTexCoords.xy * 0.125) * invertedHTexCoordsZ; \n\ 137 }\n"; 137 138 138 139 static const char* const qglslAffinePositionWithPatternBrushVertexShader 139 140 = qglslPositionWithPatternBrushVertexShader; 140 141 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); \ 142 static const char* const qglslPatternBrushSrcFragmentShader = "\n\ 143 uniform lowp sampler2D brushTexture; \n\ 144 uniform lowp vec4 patternColor; \n\ 145 varying highp vec2 patternTexCoords;\n\ 146 lowp vec4 srcPixel() \n\ 147 { \n\ 148 return patternColor * (1.0 - texture2D(brushTexture, patternTexCoords).r); \n\ 147 149 }\n"; 148 150 149 151 150 152 // 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 }"; 153 static const char* const qglslPositionWithLinearGradientBrushVertexShader = "\n\ 154 attribute highp vec2 vertexCoordsArray; \n\ 155 attribute highp vec3 pmvMatrix1; \n\ 156 attribute highp vec3 pmvMatrix2; \n\ 157 attribute highp vec3 pmvMatrix3; \n\ 158 uniform mediump vec2 halfViewportSize; \n\ 159 uniform highp vec3 linearData; \n\ 160 uniform highp mat3 brushTransform; \n\ 161 varying mediump float index; \n\ 162 void setPosition() \n\ 163 { \n\ 164 highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ 165 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ 166 gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ 167 mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ 168 mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ 169 mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ 170 gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ 171 index = (dot(linearData.xy, hTexCoords.xy) * linearData.z) * invertedHTexCoordsZ; \n\ 172 }\n"; 167 173 168 174 static const char* const qglslAffinePositionWithLinearGradientBrushVertexShader 169 175 = qglslPositionWithLinearGradientBrushVertexShader; 170 176 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 static const char* const qglslLinearGradientBrushSrcFragmentShader = "\n\ 178 uniform lowp sampler2D brushTexture; \n\ 179 varying mediump float index; \n\ 180 lowp vec4 srcPixel() \n\ 181 { \n\ 182 mediump vec2 val = vec2(index, 0.5); \n\ 183 return texture2D(brushTexture, val); \n\ 177 184 }\n"; 178 185 179 186 180 187 // 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 }"; 188 static const char* const qglslPositionWithConicalGradientBrushVertexShader = "\n\ 189 attribute highp vec2 vertexCoordsArray; \n\ 190 attribute highp vec3 pmvMatrix1; \n\ 191 attribute highp vec3 pmvMatrix2; \n\ 192 attribute highp vec3 pmvMatrix3; \n\ 193 uniform mediump vec2 halfViewportSize; \n\ 194 uniform highp mat3 brushTransform; \n\ 195 varying highp vec2 A; \n\ 196 void setPosition(void) \n\ 197 { \n\ 198 highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ 199 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ 200 gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ 201 mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ 202 mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ 203 mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ 204 gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ 205 A = hTexCoords.xy * invertedHTexCoordsZ; \n\ 206 }\n"; 197 207 198 208 static const char* const qglslAffinePositionWithConicalGradientBrushVertexShader … … 201 211 static const char* const qglslConicalGradientBrushSrcFragmentShader = "\n\ 202 212 #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 }"; 213 uniform lowp sampler2D brushTexture; \n\ 214 uniform mediump float angle; \n\ 215 varying highp vec2 A; \n\ 216 lowp vec4 srcPixel() \n\ 217 { \n\ 218 highp float t; \n\ 219 if (abs(A.y) == abs(A.x)) \n\ 220 t = (atan(-A.y + 0.002, A.x) + angle) * INVERSE_2PI; \n\ 221 else \n\ 222 t = (atan(-A.y, A.x) + angle) * INVERSE_2PI; \n\ 223 return texture2D(brushTexture, vec2(t - floor(t), 0.5)); \n\ 224 }\n"; 214 225 215 226 216 227 // 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 }"; 228 static const char* const qglslPositionWithRadialGradientBrushVertexShader = "\n\ 229 attribute highp vec2 vertexCoordsArray;\n\ 230 attribute highp vec3 pmvMatrix1; \n\ 231 attribute highp vec3 pmvMatrix2; \n\ 232 attribute highp vec3 pmvMatrix3; \n\ 233 uniform mediump vec2 halfViewportSize; \n\ 234 uniform highp mat3 brushTransform; \n\ 235 uniform highp vec2 fmp; \n\ 236 varying highp float b; \n\ 237 varying highp vec2 A; \n\ 238 void setPosition(void) \n\ 239 {\n\ 240 highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ 241 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ 242 gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ 243 mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ 244 mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ 245 mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ 246 gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ 247 A = hTexCoords.xy * invertedHTexCoordsZ; \n\ 248 b = 2.0 * dot(A, fmp); \n\ 249 }\n"; 236 250 237 251 static const char* const qglslAffinePositionWithRadialGradientBrushVertexShader 238 252 = qglslPositionWithRadialGradientBrushVertexShader; 239 253 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 }"; 254 static const char* const qglslRadialGradientBrushSrcFragmentShader = "\n\ 255 uniform lowp sampler2D brushTexture; \n\ 256 uniform highp float fmp2_m_radius2; \n\ 257 uniform highp float inverse_2_fmp2_m_radius2; \n\ 258 varying highp float b; \n\ 259 varying highp vec2 A; \n\ 260 lowp vec4 srcPixel() \n\ 261 { \n\ 262 highp float c = -dot(A, A); \n\ 263 highp vec2 val = vec2((-b + sqrt(b*b - 4.0*fmp2_m_radius2*c)) * inverse_2_fmp2_m_radius2, 0.5); \n\ 264 return texture2D(brushTexture, val); \n\ 265 }\n"; 251 266 252 267 253 268 // 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 }"; 269 static const char* const qglslPositionWithTextureBrushVertexShader = "\n\ 270 attribute highp vec2 vertexCoordsArray; \n\ 271 attribute highp vec3 pmvMatrix1; \n\ 272 attribute highp vec3 pmvMatrix2; \n\ 273 attribute highp vec3 pmvMatrix3; \n\ 274 uniform mediump vec2 halfViewportSize; \n\ 275 uniform highp vec2 invertedTextureSize; \n\ 276 uniform highp mat3 brushTransform; \n\ 277 varying highp vec2 textureCoords; \n\ 278 void setPosition(void) \n\ 279 { \n\ 280 highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ 281 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ 282 gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ 283 mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ 284 mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ 285 mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ 286 gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ 287 textureCoords.xy = (hTexCoords.xy * invertedTextureSize) * gl_Position.w; \n\ 288 }\n"; 270 289 271 290 static const char* const qglslAffinePositionWithTextureBrushVertexShader … … 276 295 // we emulate GL_REPEAT by only taking the fractional part of the texture coords. 277 296 // 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 } ";297 static const char* const qglslTextureBrushSrcFragmentShader = "\ 298 varying highp vec2 textureCoords; \ 299 uniform lowp sampler2D brushTexture; \ 300 lowp vec4 srcPixel() { \ 301 return texture2D(brushTexture, fract(textureCoords)); \ 302 }"; 284 303 #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 }"; 304 static const char* const qglslTextureBrushSrcFragmentShader = "\n\ 305 varying highp vec2 textureCoords; \n\ 306 uniform lowp sampler2D brushTexture; \n\ 307 lowp vec4 srcPixel() \n\ 308 { \n\ 309 return texture2D(brushTexture, textureCoords); \n\ 310 }\n"; 291 311 #endif 292 312 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 }"; 313 static const char* const qglslTextureBrushSrcWithPatternFragmentShader = "\n\ 314 varying highp vec2 textureCoords; \n\ 315 uniform lowp vec4 patternColor; \n\ 316 uniform lowp sampler2D brushTexture; \n\ 317 lowp vec4 srcPixel() \n\ 318 { \n\ 319 return patternColor * (1.0 - texture2D(brushTexture, textureCoords).r); \n\ 320 }\n"; 300 321 301 322 // 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 }"; 323 static const char* const qglslSolidBrushSrcFragmentShader = "\n\ 324 uniform lowp vec4 fragmentColor; \n\ 325 lowp vec4 srcPixel() \n\ 326 { \n\ 327 return fragmentColor; \n\ 328 }\n"; 329 330 static const char* const qglslImageSrcFragmentShader = "\n\ 331 varying highp vec2 textureCoords; \n\ 332 uniform lowp sampler2D imageTexture; \n\ 333 lowp vec4 srcPixel() \n\ 334 { \n\ 335 return texture2D(imageTexture, textureCoords); \n\ 336 }\n"; 337 338 static const char* const qglslCustomSrcFragmentShader = "\n\ 339 varying highp vec2 textureCoords; \n\ 340 uniform lowp sampler2D imageTexture; \n\ 341 lowp vec4 customShader(lowp sampler2D texture, highp vec2 coords); \n\ 342 lowp vec4 srcPixel() \n\ 343 { \n\ 344 return customShader(imageTexture, textureCoords); \n\ 345 }\n"; 346 347 static const char* const qglslImageSrcWithPatternFragmentShader = "\n\ 348 varying highp vec2 textureCoords; \n\ 349 uniform lowp vec4 patternColor; \n\ 350 uniform lowp sampler2D imageTexture; \n\ 351 lowp vec4 srcPixel() \n\ 352 { \n\ 353 return patternColor * (1.0 - texture2D(imageTexture, textureCoords).r); \n\ 354 }\n"; 355 356 static const char* const qglslNonPremultipliedImageSrcFragmentShader = "\n\ 357 varying highp vec2 textureCoords; \n\ 358 uniform lowp sampler2D imageTexture; \n\ 359 lowp vec4 srcPixel() \n\ 360 { \n\ 361 lowp vec4 sample = texture2D(imageTexture, textureCoords); \n\ 362 sample.rgb = sample.rgb * sample.a; \n\ 363 return sample; \n\ 364 }\n"; 365 366 static const char* const qglslShockingPinkSrcFragmentShader = "\n\ 367 lowp vec4 srcPixel() \n\ 368 { \n\ 369 return vec4(0.98, 0.06, 0.75, 1.0); \n\ 370 }\n"; 371 372 static const char* const qglslMainFragmentShader_ImageArrays = "\n\ 373 varying lowp float opacity; \n\ 374 lowp vec4 srcPixel(); \n\ 375 void main() \n\ 376 { \n\ 377 gl_FragColor = srcPixel() * opacity; \n\ 378 }\n"; 379 380 static const char* const qglslMainFragmentShader_CMO = "\n\ 381 uniform lowp float globalOpacity; \n\ 382 lowp vec4 srcPixel(); \n\ 383 lowp vec4 applyMask(lowp vec4); \n\ 384 lowp vec4 compose(lowp vec4); \n\ 385 void main() \n\ 386 { \n\ 387 gl_FragColor = applyMask(compose(srcPixel()*globalOpacity))); \n\ 388 }\n"; 389 390 static const char* const qglslMainFragmentShader_CM = "\n\ 391 lowp vec4 srcPixel(); \n\ 392 lowp vec4 applyMask(lowp vec4); \n\ 393 lowp vec4 compose(lowp vec4); \n\ 394 void main() \n\ 395 { \n\ 396 gl_FragColor = applyMask(compose(srcPixel())); \n\ 397 }\n"; 398 399 static const char* const qglslMainFragmentShader_MO = "\n\ 400 uniform lowp float globalOpacity; \n\ 401 lowp vec4 srcPixel(); \n\ 402 lowp vec4 applyMask(lowp vec4); \n\ 403 void main() \n\ 404 { \n\ 405 gl_FragColor = applyMask(srcPixel()*globalOpacity); \n\ 406 }\n"; 407 408 static const char* const qglslMainFragmentShader_M = "\n\ 409 lowp vec4 srcPixel(); \n\ 410 lowp vec4 applyMask(lowp vec4); \n\ 411 void main() \n\ 412 { \n\ 413 gl_FragColor = applyMask(srcPixel()); \n\ 414 }\n"; 415 416 static const char* const qglslMainFragmentShader_CO = "\n\ 417 uniform lowp float globalOpacity; \n\ 418 lowp vec4 srcPixel(); \n\ 419 lowp vec4 compose(lowp vec4); \n\ 420 void main() \n\ 421 { \n\ 422 gl_FragColor = compose(srcPixel()*globalOpacity); \n\ 423 }\n"; 424 425 static const char* const qglslMainFragmentShader_C = "\n\ 426 lowp vec4 srcPixel(); \n\ 427 lowp vec4 compose(lowp vec4); \n\ 428 void main() \n\ 429 { \n\ 430 gl_FragColor = compose(srcPixel()); \n\ 431 }\n"; 432 433 static const char* const qglslMainFragmentShader_O = "\n\ 434 uniform lowp float globalOpacity; \n\ 435 lowp vec4 srcPixel(); \n\ 436 void main() \n\ 437 { \n\ 438 gl_FragColor = srcPixel()*globalOpacity; \n\ 439 }\n"; 440 441 static const char* const qglslMainFragmentShader = "\n\ 442 lowp vec4 srcPixel(); \n\ 443 void main() \n\ 444 { \n\ 445 gl_FragColor = srcPixel(); \n\ 446 }\n"; 447 448 static const char* const qglslMaskFragmentShader = "\n\ 449 varying highp vec2 textureCoords;\n\ 450 uniform lowp sampler2D maskTexture;\n\ 451 lowp vec4 applyMask(lowp vec4 src) \n\ 452 {\n\ 453 lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\ 454 return src * mask.a; \n\ 455 }\n"; 420 456 421 457 // For source over with subpixel antialiasing, the final color is calculated per component as follows … … 434 470 // 435 471 436 static const char* const qglslRgbMaskFragmentShaderPass1 = "\ 437 varying highp vec2 textureCoords;\438 uniform lowp sampler2D maskTexture;\439 lowp vec4 applyMask(lowp vec4 src) \ 440 { \441 lowp vec4 mask = texture2D(maskTexture, textureCoords); \ 442 return src.a * mask; \ 443 } ";444 445 static const char* const qglslRgbMaskFragmentShaderPass2 = "\ 446 varying highp vec2 textureCoords;\447 uniform lowp sampler2D maskTexture;\448 lowp vec4 applyMask(lowp vec4 src) \ 449 { \450 lowp vec4 mask = texture2D(maskTexture, textureCoords); \ 451 return src * mask; \ 452 } ";472 static const char* const qglslRgbMaskFragmentShaderPass1 = "\ 473 varying \ 474 uniform \ 475 lowp vec4 applyMask(lowp vec4 src) \ 476 {\ 477 lowp vec4 mask = texture2D(maskTexture, textureCoords); \ 478 return src.a * mask; \ 479 }"; 480 481 static const char* const qglslRgbMaskFragmentShaderPass2 = "\ 482 varying \ 483 uniform \ 484 lowp vec4 applyMask(lowp vec4 src) \ 485 {\ 486 lowp vec4 mask = texture2D(maskTexture, textureCoords); \ 487 return src * mask; \ 488 }"; 453 489 454 490 /*
Note:
See TracChangeset
for help on using the changeset viewer.