Changeset 651 for trunk/src/opengl/gl2paintengineex
- Timestamp:
- Mar 8, 2010, 12:52:58 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
- 2 copied
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/qgl2pexvertexarray.cpp
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/opengl/gl2paintengineex/qglcustomshaderstage.cpp
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/opengl/gl2paintengineex/qglcustomshaderstage_p.h
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 185 185 simpleShaderProg->addShader(fragShader); 186 186 simpleShaderProg->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); 187 simpleShaderProg->bindAttributeLocation("pmvMatrix1", QT_PMV_MATRIX_1_ATTR); 188 simpleShaderProg->bindAttributeLocation("pmvMatrix2", QT_PMV_MATRIX_2_ATTR); 189 simpleShaderProg->bindAttributeLocation("pmvMatrix3", QT_PMV_MATRIX_3_ATTR); 187 190 simpleShaderProg->link(); 188 191 if (!simpleShaderProg->isLinked()) { … … 217 220 } 218 221 222 } 223 224 QGLEngineSharedShaders::~QGLEngineSharedShaders() 225 { 226 QList<QGLEngineShaderProg*>::iterator itr; 227 for (itr = cachedPrograms.begin(); itr != cachedPrograms.end(); ++itr) 228 delete *itr; 229 230 if (blitShaderProg) { 231 delete blitShaderProg; 232 blitShaderProg = 0; 233 } 234 235 if (simpleShaderProg) { 236 delete simpleShaderProg; 237 simpleShaderProg = 0; 238 } 219 239 } 220 240 … … 308 328 if (newProg->useOpacityAttribute) 309 329 newProg->program->bindAttributeLocation("opacityArray", QT_OPACITY_ATTR); 330 if (newProg->usePmvMatrix) { 331 newProg->program->bindAttributeLocation("pmvMatrix1", QT_PMV_MATRIX_1_ATTR); 332 newProg->program->bindAttributeLocation("pmvMatrix2", QT_PMV_MATRIX_2_ATTR); 333 newProg->program->bindAttributeLocation("pmvMatrix3", QT_PMV_MATRIX_3_ATTR); 334 } 310 335 311 336 newProg->program->link(); … … 394 419 } 395 420 396 GLuint QGLEngineShaderManager::getUniformLocation( constUniform id)421 GLuint QGLEngineShaderManager::getUniformLocation(Uniform id) 397 422 { 398 423 if (!currentShaderProg) … … 408 433 "globalOpacity", 409 434 "depth", 410 "pmvMatrix",411 435 "maskTexture", 412 436 "fragmentColor", … … 429 453 430 454 431 void QGLEngineShaderManager::optimiseForBrushTransform( constQTransform::TransformationType transformType)455 void QGLEngineShaderManager::optimiseForBrushTransform(QTransform::TransformationType transformType) 432 456 { 433 457 Q_UNUSED(transformType); // Currently ignored … … 506 530 return currentShaderProg->program; 507 531 else 508 return simpleProgram(); 532 return sharedShaders->simpleProgram(); 533 } 534 535 void QGLEngineShaderManager::useSimpleProgram() 536 { 537 sharedShaders->simpleProgram()->bind(); 538 QGLContextPrivate* ctx_d = ctx->d_func(); 539 ctx_d->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, true); 540 ctx_d->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, false); 541 ctx_d->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, false); 542 shaderProgNeedsChanging = true; 543 } 544 545 void QGLEngineShaderManager::useBlitProgram() 546 { 547 sharedShaders->blitProgram()->bind(); 548 QGLContextPrivate* ctx_d = ctx->d_func(); 549 ctx_d->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, true); 550 ctx_d->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, true); 551 ctx_d->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, false); 552 shaderProgNeedsChanging = true; 509 553 } 510 554 … … 707 751 requiredProgram.useTextureCoords = texCoords; 708 752 requiredProgram.useOpacityAttribute = (opacityMode == AttributeOpacity); 753 requiredProgram.usePmvMatrix = true; 709 754 710 755 // At this point, requiredProgram is fully populated so try to find the program in the cache … … 717 762 } 718 763 764 // Make sure all the vertex attribute arrays the program uses are enabled (and the ones it 765 // doesn't use are disabled) 766 QGLContextPrivate* ctx_d = ctx->d_func(); 767 ctx_d->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, true); 768 ctx_d->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, currentShaderProg->useTextureCoords); 769 ctx_d->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, currentShaderProg->useOpacityAttribute); 770 719 771 shaderProgNeedsChanging = false; 720 772 return true; -
trunk/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 254 254 static const GLuint QT_TEXTURE_COORDS_ATTR = 1; 255 255 static const GLuint QT_OPACITY_ATTR = 2; 256 static const GLuint QT_PMV_MATRIX_1_ATTR = 3; 257 static const GLuint QT_PMV_MATRIX_2_ATTR = 4; 258 static const GLuint QT_PMV_MATRIX_3_ATTR = 5; 256 259 257 260 class QGLEngineShaderProg; … … 345 348 346 349 QGLEngineSharedShaders(const QGLContext *context); 350 ~QGLEngineSharedShaders(); 347 351 348 352 QGLShaderProgram *simpleProgram() { return simpleShaderProg; } … … 397 401 bool useTextureCoords; 398 402 bool useOpacityAttribute; 403 bool usePmvMatrix; 399 404 400 405 bool operator==(const QGLEngineShaderProg& other) { … … 431 436 GlobalOpacity, 432 437 Depth, 433 PmvMatrix,434 438 MaskTexture, 435 439 FragmentColor, … … 455 459 // 1) May not have to apply perspective-correction 456 460 // 2) Can use lower precision for matrix 457 void optimiseForBrushTransform( constQTransform::TransformationType transformType);461 void optimiseForBrushTransform(QTransform::TransformationType transformType); 458 462 void setSrcPixelType(Qt::BrushStyle); 459 463 void setSrcPixelType(PixelSrcType); // For non-brush sources, like pixmaps & images … … 464 468 void removeCustomStage(); 465 469 466 GLuint getUniformLocation( constUniform id);470 GLuint getUniformLocation(Uniform id); 467 471 468 472 void setDirty(); // someone has manually changed the current shader program 469 473 bool useCorrectShaderProg(); // returns true if the shader program needed to be changed 474 475 void useSimpleProgram(); 476 void useBlitProgram(); 470 477 471 478 QGLShaderProgram* currentProgram(); // Returns pointer to the shader the manager has chosen -
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) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 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 = "\n\ 298 varying highp vec2 textureCoords; \n\ 299 uniform lowp sampler2D brushTexture; \n\ 300 lowp vec4 srcPixel() { \n\ 301 return texture2D(brushTexture, fract(textureCoords)); \n\ 302 }\n"; 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 = "\n\ 473 varying highp vec2 textureCoords;\n\ 474 uniform lowp sampler2D maskTexture;\n\ 475 lowp vec4 applyMask(lowp vec4 src) \n\ 476 { \n\ 477 lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\ 478 return src.a * mask; \n\ 479 }\n"; 480 481 static const char* const qglslRgbMaskFragmentShaderPass2 = "\n\ 482 varying highp vec2 textureCoords;\n\ 483 uniform lowp sampler2D maskTexture;\n\ 484 lowp vec4 applyMask(lowp vec4 src) \n\ 485 { \n\ 486 lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\ 487 return src * mask; \n\ 488 }\n"; 453 489 454 490 /* -
trunk/src/opengl/gl2paintengineex/qglgradientcache.cpp
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/opengl/gl2paintengineex/qglgradientcache_p.h
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 76 76 #include <private/qpainter_p.h> 77 77 #include <private/qfontengine_p.h> 78 #include <private/qtextureglyphcache_p.h>79 78 #include <private/qpixmapdata_gl_p.h> 80 79 #include <private/qdatabuffer_p.h> … … 83 82 #include "qglengineshadermanager_p.h" 84 83 #include "qgl2pexvertexarray_p.h" 85 86 84 #include "qtriangulatingstroker_p.h" 85 #include "qtextureglyphcache_gl_p.h" 87 86 88 87 #include <QDebug> … … 91 90 92 91 //#define QT_GL_NO_SCISSOR_TEST 93 94 static const GLuint GL_STENCIL_HIGH_BIT = 0x80;95 static const GLuint QT_BRUSH_TEXTURE_UNIT = 0;96 static const GLuint QT_IMAGE_TEXTURE_UNIT = 0; //Can be the same as brush texture unit97 static const GLuint QT_MASK_TEXTURE_UNIT = 1;98 static const GLuint QT_BACKGROUND_TEXTURE_UNIT = 2;99 100 #ifdef Q_WS_WIN101 extern Q_GUI_EXPORT bool qt_cleartype_enabled;102 #endif103 104 class QGLTextureGlyphCache : public QObject, public QTextureGlyphCache105 {106 Q_OBJECT107 public:108 QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix);109 ~QGLTextureGlyphCache();110 111 virtual void createTextureData(int width, int height);112 virtual void resizeTextureData(int width, int height);113 virtual void fillTexture(const Coord &c, glyph_t glyph);114 virtual int glyphMargin() const;115 116 inline GLuint texture() const { return m_texture; }117 118 inline int width() const { return m_width; }119 inline int height() const { return m_height; }120 121 inline void setPaintEnginePrivate(QGL2PaintEngineExPrivate *p) { pex = p; }122 123 124 public Q_SLOTS:125 void contextDestroyed(const QGLContext *context) {126 if (context == ctx) {127 QList<const QGLContext *> shares = qgl_share_reg()->shares(ctx);128 if (shares.isEmpty()) {129 glDeleteFramebuffers(1, &m_fbo);130 if (m_width || m_height)131 glDeleteTextures(1, &m_texture);132 ctx = 0;133 } else {134 // since the context holding the texture is shared, and135 // about to be destroyed, we have to transfer ownership136 // of the texture to one of the share contexts137 ctx = const_cast<QGLContext *>((ctx == shares.at(0)) ? shares.at(1) : shares.at(0));138 }139 }140 }141 142 private:143 QGLContext *ctx;144 145 QGL2PaintEngineExPrivate *pex;146 147 GLuint m_texture;148 GLuint m_fbo;149 150 int m_width;151 int m_height;152 153 QGLShaderProgram *m_program;154 };155 156 QGLTextureGlyphCache::QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix)157 : QTextureGlyphCache(type, matrix)158 , ctx(context)159 , m_width(0)160 , m_height(0)161 {162 glGenFramebuffers(1, &m_fbo);163 connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext*)),164 SLOT(contextDestroyed(const QGLContext*)));165 }166 167 QGLTextureGlyphCache::~QGLTextureGlyphCache()168 {169 if (ctx) {170 QGLShareContextScope scope(ctx);171 glDeleteFramebuffers(1, &m_fbo);172 173 if (m_width || m_height)174 glDeleteTextures(1, &m_texture);175 }176 }177 178 void QGLTextureGlyphCache::createTextureData(int width, int height)179 {180 glGenTextures(1, &m_texture);181 glBindTexture(GL_TEXTURE_2D, m_texture);182 183 m_width = width;184 m_height = height;185 186 QVarLengthArray<uchar> data(width * height);187 for (int i = 0; i < data.size(); ++i)188 data[i] = 0;189 190 if (m_type == QFontEngineGlyphCache::Raster_RGBMask)191 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &data[0]);192 else193 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &data[0]);194 195 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);196 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);197 }198 199 void QGLTextureGlyphCache::resizeTextureData(int width, int height)200 {201 // ### the QTextureGlyphCache API needs to be reworked to allow202 // ### resizeTextureData to fail203 204 int oldWidth = m_width;205 int oldHeight = m_height;206 207 GLuint oldTexture = m_texture;208 createTextureData(width, height);209 210 glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo);211 212 GLuint tmp_texture;213 glGenTextures(1, &tmp_texture);214 glBindTexture(GL_TEXTURE_2D, tmp_texture);215 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, oldWidth, oldHeight, 0,216 GL_RGBA, GL_UNSIGNED_BYTE, NULL);217 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);218 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);219 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);220 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);221 glBindTexture(GL_TEXTURE_2D, 0);222 glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,223 GL_TEXTURE_2D, tmp_texture, 0);224 225 glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);226 glBindTexture(GL_TEXTURE_2D, oldTexture);227 228 pex->transferMode(BrushDrawingMode);229 230 glDisable(GL_STENCIL_TEST);231 glDisable(GL_DEPTH_TEST);232 glDisable(GL_SCISSOR_TEST);233 glDisable(GL_BLEND);234 235 glViewport(0, 0, oldWidth, oldHeight);236 237 float vertexCoordinateArray[] = { -1, -1, 1, -1, 1, 1, -1, 1 };238 float textureCoordinateArray[] = { 0, 0, 1, 0, 1, 1, 0, 1 };239 240 glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR);241 glEnableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);242 243 glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray);244 glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray);245 246 pex->shaderManager->blitProgram()->bind();247 pex->shaderManager->blitProgram()->setUniformValue("imageTexture", QT_IMAGE_TEXTURE_UNIT);248 pex->shaderManager->setDirty();249 250 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);251 252 glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR);253 glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);254 255 glBindTexture(GL_TEXTURE_2D, m_texture);256 257 #ifdef QT_OPENGL_ES_2258 QDataBuffer<uchar> buffer(4*oldWidth*oldHeight);259 buffer.resize(4*oldWidth*oldHeight);260 glReadPixels(0, 0, oldWidth, oldHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer.data());261 262 // do an in-place conversion from GL_RGBA to GL_ALPHA263 for (int i=0; i<oldWidth*oldHeight; ++i)264 buffer.data()[i] = buffer.at(4*i + 3);265 266 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, oldWidth, oldHeight,267 GL_ALPHA, GL_UNSIGNED_BYTE, buffer.data());268 #else269 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, oldWidth, oldHeight);270 #endif271 272 glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,273 GL_RENDERBUFFER_EXT, 0);274 glDeleteTextures(1, &tmp_texture);275 glDeleteTextures(1, &oldTexture);276 277 glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo);278 279 glViewport(0, 0, pex->width, pex->height);280 pex->updateClipScissorTest();281 }282 283 void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph)284 {285 QImage mask = textureMapForGlyph(glyph);286 const int maskWidth = mask.width();287 const int maskHeight = mask.height();288 289 if (mask.format() == QImage::Format_Mono) {290 mask = mask.convertToFormat(QImage::Format_Indexed8);291 for (int y = 0; y < maskHeight; ++y) {292 uchar *src = (uchar *) mask.scanLine(y);293 for (int x = 0; x < maskWidth; ++x)294 src[x] = -src[x]; // convert 0 and 1 into 0 and 255295 }296 }297 298 299 glBindTexture(GL_TEXTURE_2D, m_texture);300 if (mask.format() == QImage::Format_RGB32) {301 glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_BGRA, GL_UNSIGNED_BYTE, mask.bits());302 } else {303 #ifdef QT_OPENGL_ES2304 glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_ALPHA, GL_UNSIGNED_BYTE, mask.bits());305 #else306 // glTexSubImage2D() might cause some garbage to appear in the texture if the mask width is307 // not a multiple of four bytes. The bug appeared on a computer with 32-bit Windows Vista308 // and nVidia GeForce 8500GT. GL_UNPACK_ALIGNMENT is set to four bytes, 'mask' has a309 // multiple of four bytes per line, and most of the glyph shows up correctly in the310 // texture, which makes me think that this is a driver bug.311 // One workaround is to make sure the mask width is a multiple of four bytes, for instance312 // by converting it to a format with four bytes per pixel. Another is to copy one line at a313 // time.314 315 for (int i = 0; i < maskHeight; ++i)316 glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, maskWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, mask.scanLine(i));317 #endif318 }319 }320 321 int QGLTextureGlyphCache::glyphMargin() const322 {323 #if defined(Q_WS_MAC)324 return 2;325 #elif defined (Q_WS_X11)326 return 0;327 #else328 return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0;329 #endif330 }331 92 332 93 extern QImage qt_imageForBrush(int brushStyle, bool invert); … … 404 165 void QGL2PaintEngineExPrivate::useSimpleShader() 405 166 { 406 shaderManager->simpleProgram()->bind(); 407 shaderManager->setDirty(); 167 shaderManager->useSimpleProgram(); 408 168 409 169 if (matrixDirty) 410 170 updateMatrix(); 411 412 if (simpleShaderMatrixUniformDirty) {413 const GLuint location = shaderManager->simpleProgram()->uniformLocation("pmvMatrix");414 glUniformMatrix3fv(location, 1, GL_FALSE, (GLfloat*)pmvMatrix);415 simpleShaderMatrixUniformDirty = false;416 }417 171 } 418 172 … … 633 387 matrixDirty = false; 634 388 635 // The actual data has been updated so both shader program's uniforms need updating 636 simpleShaderMatrixUniformDirty = true; 637 shaderMatrixUniformDirty = true; 389 // Set the PMV matrix attribute. As we use an attributes rather than uniforms, we only 390 // need to do this once for every matrix change and persists across all shader programs. 391 glVertexAttrib3fv(QT_PMV_MATRIX_1_ATTR, pmvMatrix[0]); 392 glVertexAttrib3fv(QT_PMV_MATRIX_2_ATTR, pmvMatrix[1]); 393 glVertexAttrib3fv(QT_PMV_MATRIX_3_ATTR, pmvMatrix[2]); 638 394 639 395 dasher.setInvScale(inverseScale); … … 751 507 glUseProgram(0); 752 508 509 // Disable all the vertex attribute arrays: 510 for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) 511 glDisableVertexAttribArray(i); 512 753 513 #ifndef QT_OPENGL_ES_2 754 514 // be nice to people who mix OpenGL 1.x code with QPainter commands … … 796 556 glDepthFunc(GL_LESS); 797 557 glClearDepth(1); 558 glStencilMask(0xff); 559 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); 560 glStencilFunc(GL_ALWAYS, 0, 0xff); 561 glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR); 562 glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR); 563 glDisableVertexAttribArray(QT_OPACITY_ATTR); 564 #ifndef QT_OPENGL_ES_2 565 glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // color may have been changed by glVertexAttrib() 566 #endif 798 567 } 799 568 … … 810 579 811 580 if (mode == TextDrawingMode || mode == ImageDrawingMode || mode == ImageArrayDrawingMode) { 812 glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);813 glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR);814 glDisableVertexAttribArray(QT_OPACITY_ATTR);815 816 581 lastTextureUsed = GLuint(-1); 817 582 } 818 583 819 584 if (newMode == TextDrawingMode) { 820 glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); 821 glEnableVertexAttribArray(QT_TEXTURE_COORDS_ATTR); 822 823 glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray.data()); 824 glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray.data()); 585 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinateArray.data()); 586 setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinateArray.data()); 825 587 } 826 588 827 589 if (newMode == ImageDrawingMode) { 828 glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); 829 glEnableVertexAttribArray(QT_TEXTURE_COORDS_ATTR); 830 831 glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, staticVertexCoordinateArray); 832 glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, staticTextureCoordinateArray); 590 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, staticVertexCoordinateArray); 591 setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, staticTextureCoordinateArray); 833 592 } 834 593 835 594 if (newMode == ImageArrayDrawingMode) { 836 glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); 837 glEnableVertexAttribArray(QT_TEXTURE_COORDS_ATTR); 838 glEnableVertexAttribArray(QT_OPACITY_ATTR); 839 840 glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray.data()); 841 glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray.data()); 842 glVertexAttribPointer(QT_OPACITY_ATTR, 1, GL_FLOAT, GL_FALSE, 0, opacityArray.data()); 595 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinateArray.data()); 596 setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinateArray.data()); 597 setVertexAttributePointer(QT_OPACITY_ATTR, (GLfloat*)opacityArray.data()); 843 598 } 844 599 … … 953 708 954 709 prepareForDraw(currentBrush.isOpaque()); 955 glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR);956 710 #ifdef QT_OPENGL_CACHE_AS_VBOS 957 711 glBindBuffer(GL_ARRAY_BUFFER, cache->vbo); 958 glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, false, 0, 0);712 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, 0); 959 713 #else 960 glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, false, 0, cache->vertices);714 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, cache->vertices); 961 715 #endif 962 716 glDrawArrays(cache->primitiveType, 0, cache->vertexCount); … … 1078 832 #if 0 1079 833 glStencilOp(GL_KEEP, GL_KEEP, GL_INVERT); // Simply invert the stencil bit 1080 glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); 1081 glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, data); 834 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, data); 1082 835 glDrawArrays(GL_TRIANGLE_STRIP, 0, count); 1083 glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR);1084 836 #else 1085 837 … … 1091 843 glStencilFunc(GL_ALWAYS, GL_STENCIL_HIGH_BIT, 0xff); 1092 844 } 1093 glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); 1094 glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, data); 845 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, data); 1095 846 glDrawArrays(GL_TRIANGLE_STRIP, 0, count); 1096 glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR);1097 847 #endif 1098 848 } … … 1185 935 // The shader program has changed so mark all uniforms as dirty: 1186 936 brushUniformsDirty = true; 1187 shaderMatrixUniformDirty = true;1188 937 opacityUniformDirty = true; 1189 938 } … … 1191 940 if (brushUniformsDirty && mode != ImageDrawingMode && mode != ImageArrayDrawingMode) 1192 941 updateBrushUniforms(); 1193 1194 if (shaderMatrixUniformDirty) {1195 glUniformMatrix3fv(location(QGLEngineShaderManager::PmvMatrix), 1, GL_FALSE, (GLfloat*)pmvMatrix);1196 shaderMatrixUniformDirty = false;1197 }1198 942 1199 943 if (opacityMode == QGLEngineShaderManager::UniformOpacity && opacityUniformDirty) { … … 1207 951 void QGL2PaintEngineExPrivate::composite(const QGLRect& boundingRect) 1208 952 { 1209 // Setup a vertex array for the bounding rect: 1210 GLfloat rectVerts[] = { 1211 boundingRect.left, boundingRect.top, 1212 boundingRect.left, boundingRect.bottom, 1213 boundingRect.right, boundingRect.bottom, 1214 boundingRect.right, boundingRect.top 1215 }; 1216 1217 glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); 1218 glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, rectVerts); 1219 953 setCoords(staticVertexCoordinateArray, boundingRect); 954 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, staticVertexCoordinateArray); 1220 955 glDrawArrays(GL_TRIANGLE_FAN, 0, 4); 1221 1222 glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR);1223 956 } 1224 957 … … 1228 961 { 1229 962 // Now setup the pointer to the vertex array: 1230 glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); 1231 glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, data); 963 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)data); 1232 964 1233 965 int previousStop = 0; … … 1242 974 previousStop = stop; 1243 975 } 1244 glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR);1245 976 } 1246 977 … … 1329 1060 if (opaque) { 1330 1061 prepareForDraw(opaque); 1331 glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); 1332 glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, false, 0, stroker.vertices()); 1062 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, stroker.vertices()); 1333 1063 glDrawArrays(GL_TRIANGLE_STRIP, 0, stroker.vertexCount() / 2); 1334 1064 … … 1337 1067 // d->prepareForDraw(true); 1338 1068 // glDrawArrays(GL_LINE_STRIP, 0, d->stroker.vertexCount() / 2); 1339 1340 glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR);1341 1069 1342 1070 } else { … … 1553 1281 GLfloat dy = 1.0 / cache->height(); 1554 1282 1555 QGLPoint *oldVertexCoordinateDataPtr = vertexCoordinateArray.data();1556 QGLPoint *oldTextureCoordinateDataPtr = textureCoordinateArray.data();1557 1558 1283 vertexCoordinateArray.clear(); 1559 1284 textureCoordinateArray.clear(); … … 1568 1293 } 1569 1294 1570 if (vertexCoordinateArray.data() != oldVertexCoordinateDataPtr) 1571 glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray.data()); 1572 if (textureCoordinateArray.data() != oldTextureCoordinateDataPtr) 1573 glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray.data()); 1295 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinateArray.data()); 1296 setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinateArray.data()); 1574 1297 1575 1298 if (addOffset) { … … 1833 1556 #if !defined(QT_OPENGL_ES_2) 1834 1557 #if defined(Q_WS_WIN) 1558 extern Q_GUI_EXPORT bool qt_cleartype_enabled; 1835 1559 if (qt_cleartype_enabled) 1836 1560 #endif … … 1900 1624 d->needsSync = false; 1901 1625 d->shaderManager->setDirty(); 1626 d->ctx->d_func()->syncGlState(); 1627 for (int i = 0; i < 3; ++i) 1628 d->vertexAttribPointers[i] = (GLfloat*)-1; // Assume the pointers are clobbered 1902 1629 setState(state()); 1903 1630 } … … 2225 1952 renderHintsChanged(); 2226 1953 2227 if (old_state == s || old_state->matrixChanged) {1954 if (old_state == s || old_state->matrixChanged) 2228 1955 d->matrixDirty = true; 2229 d->simpleShaderMatrixUniformDirty = true;2230 d->shaderMatrixUniformDirty = true;2231 }2232 1956 2233 1957 if (old_state == s || old_state->compositionModeChanged) … … 2291 2015 2292 2016 QT_END_NAMESPACE 2293 2294 #include "qpaintengineex_opengl2.moc" -
trunk/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 74 74 QT_BEGIN_NAMESPACE 75 75 76 #define GL_STENCIL_HIGH_BIT GLuint(0x80) 77 #define QT_BRUSH_TEXTURE_UNIT GLuint(0) 78 #define QT_IMAGE_TEXTURE_UNIT GLuint(0) //Can be the same as brush texture unit 79 #define QT_MASK_TEXTURE_UNIT GLuint(1) 80 #define QT_BACKGROUND_TEXTURE_UNIT GLuint(2) 81 76 82 class QGL2PaintEngineExPrivate; 77 83 … … 191 197 void drawCachedGlyphs(const QPointF &p, QFontEngineGlyphCache::Type glyphType, const QTextItemInt &ti); 192 198 199 // Calls glVertexAttributePointer if the pointer has changed 200 inline void setVertexAttributePointer(unsigned int arrayIndex, const GLfloat *pointer); 201 193 202 // draws whatever is in the vertex array: 194 203 void drawVertexArrays(const float *data, int *stops, int stopCount, GLenum primitive); … … 224 233 void regenerateClip(); 225 234 void systemStateChanged(); 235 226 236 227 237 static QGLEngineShaderManager* shaderManagerForEngine(QGL2PaintEngineEx *engine) { return engine->d_func()->shaderManager; } … … 243 253 bool brushTextureDirty; 244 254 bool brushUniformsDirty; 245 bool simpleShaderMatrixUniformDirty;246 bool shaderMatrixUniformDirty;247 255 bool opacityUniformDirty; 248 256 … … 286 294 QSet<QVectorPath::CacheEntry *> pathCaches; 287 295 QVector<GLuint> unusedVBOSToClean; 296 297 const GLfloat *vertexAttribPointers[3]; 288 298 }; 289 299 300 301 void QGL2PaintEngineExPrivate::setVertexAttributePointer(unsigned int arrayIndex, const GLfloat *pointer) 302 { 303 Q_ASSERT(arrayIndex < 3); 304 if (pointer == vertexAttribPointers[arrayIndex]) 305 return; 306 307 vertexAttribPointers[arrayIndex] = pointer; 308 if (arrayIndex == QT_OPACITY_ATTR) 309 glVertexAttribPointer(arrayIndex, 1, GL_FLOAT, GL_FALSE, 0, pointer); 310 else 311 glVertexAttribPointer(arrayIndex, 2, GL_FLOAT, GL_FALSE, 0, pointer); 312 } 313 290 314 QT_END_NAMESPACE 291 315 -
trunk/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com)
Note:
See TracChangeset
for help on using the changeset viewer.