Changeset 651 for trunk/src/opengl
- Timestamp:
- Mar 8, 2010, 12:52:58 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 68 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) -
trunk/src/opengl/opengl.pro
r561 r651 55 55 gl2paintengineex/qglengineshadersource_p.h \ 56 56 gl2paintengineex/qglcustomshaderstage_p.h \ 57 gl2paintengineex/qtriangulatingstroker_p.h 57 gl2paintengineex/qtriangulatingstroker_p.h \ 58 gl2paintengineex/qtextureglyphcache_gl_p.h 58 59 59 60 SOURCES += qglshaderprogram.cpp \ … … 68 69 gl2paintengineex/qpaintengineex_opengl2.cpp \ 69 70 gl2paintengineex/qglcustomshaderstage.cpp \ 70 gl2paintengineex/qtriangulatingstroker.cpp 71 gl2paintengineex/qtriangulatingstroker.cpp \ 72 gl2paintengineex/qtextureglyphcache_gl.cpp 71 73 72 74 } -
trunk/src/opengl/qgl.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) … … 125 125 Q_GLOBAL_STATIC(QGLDefaultOverlayFormat, defaultOverlayFormatInstance) 126 126 127 QGLExtensions::Extensions QGLExtensions::glExtensions = 0;128 bool QGLExtensions::nvidiaFboNeedsFinish = false;129 130 127 Q_GLOBAL_STATIC(QGLSignalProxy, theSignalProxy) 131 128 QGLSignalProxy *QGLSignalProxy::instance() … … 155 152 static bool mac_x1600_check_done = false; 156 153 if (!mac_x1600_check_done) { 157 QGLWidget *tmp = 0; 158 if (!QGLContext::currentContext()) { 159 tmp = new QGLWidget(); 160 tmp->makeCurrent(); 161 } 154 QGLTemporaryContext *tmp = 0; 155 if (!QGLContext::currentContext()) 156 tmp = new QGLTemporaryContext(); 162 157 if (strstr((char *) glGetString(GL_RENDERER), "X1600")) 163 158 engineType = QPaintEngine::OpenGL; … … 179 174 // use GL 2.0. 180 175 if ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) 181 && (QGLExtensions::glExtensions & QGLExtensions::FragmentShader)176 && (QGLExtensions::glExtensions() & QGLExtensions::FragmentShader) 182 177 && qgetenv("QT_GL_USE_OPENGL1ENGINE").isEmpty()) 183 178 engineType = QPaintEngine::OpenGL2; … … 1251 1246 static OpenGLVersionFlags defaultVersionFlags = OpenGL_Version_None; 1252 1247 QGLContext *currentCtx = const_cast<QGLContext *>(QGLContext::currentContext()); 1253 QGL Widget *dummy= 0;1248 QGLTemporaryContext *tmpContext = 0; 1254 1249 1255 1250 if (currentCtx && currentCtx->d_func()->version_flags_cached) … … 1262 1257 if (!hasOpenGL()) 1263 1258 return defaultVersionFlags; 1264 dummy = new QGLWidget; 1265 dummy->makeCurrent(); // glGetString() needs a current context 1259 tmpContext = new QGLTemporaryContext; 1266 1260 cachedDefault = true; 1267 1261 } … … 1274 1268 currentCtx->d_func()->version_flags = versionFlags; 1275 1269 } 1276 if ( dummy) {1270 if (tmpContext) { 1277 1271 defaultVersionFlags = versionFlags; 1278 delete dummy;1272 delete tmpContext; 1279 1273 } 1280 1274 … … 1437 1431 } 1438 1432 1433 const QGLContext *qt_gl_transfer_context(const QGLContext *ctx) 1434 { 1435 if (!ctx) 1436 return 0; 1437 QList<const QGLContext *> shares 1438 (QGLContextPrivate::contextGroup(ctx)->shares()); 1439 if (shares.size() >= 2) 1440 return (ctx == shares.at(0)) ? shares.at(1) : shares.at(0); 1441 else 1442 return 0; 1443 } 1444 1439 1445 QGLContextPrivate::~QGLContextPrivate() 1440 1446 { … … 1482 1488 version_flags_cached = false; 1483 1489 version_flags = QGLFormat::OpenGL_Version_None; 1490 extension_flags_cached = false; 1491 extension_flags = 0; 1484 1492 current_fbo = 0; 1485 1493 default_fbo = 0; 1486 1494 active_engine = 0; 1495 for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) 1496 vertexAttributeArraysEnabledState[i] = false; 1487 1497 } 1488 1498 … … 1542 1552 QImage qt_gl_read_texture(const QSize &size, bool alpha_format, bool include_alpha) 1543 1553 { 1544 QImage img(size, alpha_format ? QImage::Format_ARGB32 : QImage::Format_RGB32);1554 QImage img(size, alpha_format ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); 1545 1555 int w = size.width(); 1546 1556 int h = size.height(); … … 1581 1591 qt_gl_texture_cache = this; 1582 1592 1583 QImagePixmapCleanupHooks::instance()->addPixmapModificationHook(cleanupTextures); 1584 #ifdef Q_WS_X11 1585 QImagePixmapCleanupHooks::instance()->addPixmapDestructionHook(cleanupPixmapSurfaces); 1586 #endif 1593 QImagePixmapCleanupHooks::instance()->addPixmapDataModificationHook(cleanupTextures); 1594 QImagePixmapCleanupHooks::instance()->addPixmapDataDestructionHook(cleanupBeforePixmapDestruction); 1587 1595 QImagePixmapCleanupHooks::instance()->addImageHook(imageCleanupHook); 1588 1596 } … … 1592 1600 qt_gl_texture_cache = 0; 1593 1601 1594 QImagePixmapCleanupHooks::instance()->removePixmapModificationHook(cleanupTextures); 1595 #ifdef Q_WS_X11 1596 QImagePixmapCleanupHooks::instance()->removePixmapDestructionHook(cleanupPixmapSurfaces); 1597 #endif 1602 QImagePixmapCleanupHooks::instance()->removePixmapDataModificationHook(cleanupTextures); 1603 QImagePixmapCleanupHooks::instance()->removePixmapDataDestructionHook(cleanupBeforePixmapDestruction); 1598 1604 QImagePixmapCleanupHooks::instance()->removeImageHook(imageCleanupHook); 1599 1605 } … … 1663 1669 1664 1670 1665 void QGLTextureCache::cleanupTextures(QPixmap * pixmap)1671 void QGLTextureCache::cleanupTextures(QPixmapData* pmd) 1666 1672 { 1667 1673 // ### remove when the GL texture cache becomes thread-safe 1668 1674 if (qApp->thread() == QThread::currentThread()) { 1669 const qint64 cacheKey = p ixmap->cacheKey();1675 const qint64 cacheKey = pmd->cacheKey(); 1670 1676 QGLTexture *texture = instance()->getTexture(cacheKey); 1671 1677 if (texture && texture->options & QGLContext::MemoryManagedBindOption) … … 1674 1680 } 1675 1681 1682 void QGLTextureCache::cleanupBeforePixmapDestruction(QPixmapData* pmd) 1683 { 1684 // Remove any bound textures first: 1685 cleanupTextures(pmd); 1686 Q_ASSERT(instance()->getTexture(pmd->cacheKey()) == 0); 1687 1676 1688 #if defined(Q_WS_X11) 1677 void QGLTextureCache::cleanupPixmapSurfaces(QPixmap* pixmap) 1678 { 1679 // Remove any bound textures first: 1680 cleanupTextures(pixmap); 1681 1682 QPixmapData *pd = pixmap->data_ptr().data(); 1683 if (pd->classId() == QPixmapData::X11Class) { 1684 Q_ASSERT(pd->ref == 1); // Make sure reference counting isn't broken 1685 QGLContextPrivate::destroyGlSurfaceForPixmap(pd); 1686 } 1687 } 1688 #endif 1689 if (pmd->classId() == QPixmapData::X11Class) { 1690 Q_ASSERT(pmd->ref == 0); // Make sure reference counting isn't broken 1691 QGLContextPrivate::destroyGlSurfaceForPixmap(pmd); 1692 } 1693 #endif 1694 } 1689 1695 1690 1696 void QGLTextureCache::deleteIfEmpty() … … 1730 1736 #endif 1731 1737 1732 Q_GLOBAL_STATIC(QGLShareRegister, _qgl_share_reg)1733 Q_OPENGL_EXPORT QGLShareRegister* qgl_share_reg()1734 {1735 return _qgl_share_reg();1736 }1737 1738 1738 /*! 1739 1739 \class QGLContext … … 1874 1874 { 1875 1875 } 1876 1877 #define ctx q_ptr 1878 void QGLContextPrivate::setVertexAttribArrayEnabled(int arrayIndex, bool enabled) 1879 { 1880 Q_ASSERT(arrayIndex < QT_GL_VERTEX_ARRAY_TRACKED_COUNT); 1881 Q_ASSERT(glEnableVertexAttribArray); 1882 1883 if (vertexAttributeArraysEnabledState[arrayIndex] && !enabled) 1884 glDisableVertexAttribArray(arrayIndex); 1885 1886 if (!vertexAttributeArraysEnabledState[arrayIndex] && enabled) 1887 glEnableVertexAttribArray(arrayIndex); 1888 1889 vertexAttributeArraysEnabledState[arrayIndex] = enabled; 1890 } 1891 1892 void QGLContextPrivate::syncGlState() 1893 { 1894 Q_ASSERT(glEnableVertexAttribArray); 1895 for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) { 1896 if (vertexAttributeArraysEnabledState[i]) 1897 glEnableVertexAttribArray(i); 1898 else 1899 glDisableVertexAttribArray(i); 1900 } 1901 1902 } 1903 #undef ctx 1904 1876 1905 1877 1906 /*! … … 2111 2140 2112 2141 QImage img = image; 2113 if (!(QGLExtensions::glExtensions & QGLExtensions::NPOTTextures)2142 if (!(QGLExtensions::glExtensions() & QGLExtensions::NPOTTextures) 2114 2143 && !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0) 2115 2144 && (target == GL_TEXTURE_2D && (tx_w != image.width() || tx_h != image.height()))) … … 2133 2162 #endif 2134 2163 if (glFormat.directRendering() 2135 && (QGLExtensions::glExtensions & QGLExtensions::GenerateMipmap)2164 && (QGLExtensions::glExtensions() & QGLExtensions::GenerateMipmap) 2136 2165 && target == GL_TEXTURE_2D 2137 2166 && (options & QGLContext::MipmapBindOption)) … … 2161 2190 GLenum externalFormat; 2162 2191 GLuint pixel_type; 2163 if (QGLExtensions::glExtensions & QGLExtensions::BGRATextureFormat) {2192 if (QGLExtensions::glExtensions() & QGLExtensions::BGRATextureFormat) { 2164 2193 externalFormat = GL_BGRA; 2165 pixel_type = GL_UNSIGNED_INT_8_8_8_8_REV; 2194 if (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_2) 2195 pixel_type = GL_UNSIGNED_INT_8_8_8_8_REV; 2196 else 2197 pixel_type = GL_UNSIGNED_BYTE; 2166 2198 } else { 2167 2199 externalFormat = GL_RGBA; … … 2242 2274 } 2243 2275 #ifdef QT_OPENGL_ES 2244 // OpenGL/ES requires that the internal and external formats be identical. 2245 // This is typically used to convert GL_RGBA into GL_BGRA. 2246 // Also, we need to use GL_UNSIGNED_BYTE when the format is GL_BGRA. 2276 // OpenGL/ES requires that the internal and external formats be 2277 // identical. 2247 2278 internalFormat = externalFormat; 2248 if (pixel_type == GL_UNSIGNED_INT_8_8_8_8_REV)2249 pixel_type = GL_UNSIGNED_BYTE;2250 2279 #endif 2251 2280 #ifdef QGL_BIND_TEXTURE_DEBUG … … 2955 2984 } 2956 2985 if (d->sharing) // ok, we managed to share 2957 qgl_share_reg()->addShare(this, shareContext);2986 QGLContextGroup::addShare(this, shareContext); 2958 2987 return d->valid; 2959 2988 } … … 4361 4390 text is drawn. 4362 4391 4392 \note This function can only be used inside a 4393 QPainter::beginNativePainting()/QPainter::endNativePainting() block 4394 if the default OpenGL paint engine is QPaintEngine::OpenGL. To make 4395 QPaintEngine::OpenGL the default GL engine, call 4396 QGL::setPreferredPaintEngine(QPaintEngine::OpenGL) before the 4397 QApplication constructor. 4398 4363 4399 \l{Overpainting Example}{Overpaint} with QPainter::drawText() instead. 4364 4400 */ … … 4832 4868 #endif // QT3_SUPPORT 4833 4869 4834 void QGLExtensions::init_extensions() 4870 /* 4871 Returns the GL extensions for the current context. 4872 */ 4873 QGLExtensions::Extensions QGLExtensions::currentContextExtensions() 4835 4874 { 4836 4875 QGLExtensionMatcher extensions(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS))); 4876 Extensions glExtensions; 4837 4877 4838 4878 if (extensions.match("GL_ARB_texture_rectangle")) … … 4895 4935 if (extensions.match("GL_EXT_bgra")) 4896 4936 glExtensions |= BGRATextureFormat; 4937 4938 return glExtensions; 4939 } 4940 4941 /* 4942 Returns the GL extensions for the current QGLContext. If there is no 4943 current QGLContext, a default context will be created and the extensions 4944 for that context will be returned instead. 4945 */ 4946 QGLExtensions::Extensions QGLExtensions::glExtensions() 4947 { 4948 QGLTemporaryContext *tmpContext = 0; 4949 static bool cachedDefault = false; 4950 static Extensions defaultExtensions = 0; 4951 QGLContext *currentCtx = const_cast<QGLContext *>(QGLContext::currentContext()); 4952 4953 if (currentCtx && currentCtx->d_func()->extension_flags_cached) 4954 return currentCtx->d_func()->extension_flags; 4955 4956 if (!currentCtx) { 4957 if (cachedDefault) { 4958 return defaultExtensions; 4959 } else { 4960 tmpContext = new QGLTemporaryContext; 4961 cachedDefault = true; 4962 } 4963 } 4964 4965 Extensions extensionFlags = currentContextExtensions(); 4966 if (currentCtx) { 4967 currentCtx->d_func()->extension_flags_cached = true; 4968 currentCtx->d_func()->extension_flags = extensionFlags; 4969 } else { 4970 defaultExtensions = extensionFlags; 4971 } 4972 4973 if (tmpContext) 4974 delete tmpContext; 4975 4976 return extensionFlags; 4897 4977 } 4898 4978 … … 4906 4986 glDevice.setWidget(q); 4907 4987 4908 QGLExtensions::init();4909 4988 glcx = 0; 4910 4989 autoSwap = true; … … 4916 4995 if (!glcx) 4917 4996 glcx = new QGLContext(QGLFormat::defaultFormat(), q); 4918 4919 q->setAttribute(Qt::WA_NoSystemBackground);4920 4997 } 4921 4998 … … 4941 5018 #endif 4942 5019 4943 void QGL ShareRegister::addShare(const QGLContext *context, const QGLContext *share) {5020 void QGLContextGroup::addShare(const QGLContext *context, const QGLContext *share) { 4944 5021 Q_ASSERT(context && share); 4945 5022 if (context->d_ptr->group == share->d_ptr->group) … … 4962 5039 } 4963 5040 4964 QList<const QGLContext *> QGLShareRegister::shares(const QGLContext *context) { 4965 return context->d_ptr->group->m_shares; 4966 } 4967 4968 void QGLShareRegister::removeShare(const QGLContext *context) { 5041 void QGLContextGroup::removeShare(const QGLContext *context) { 4969 5042 // Remove the context from the group. 4970 5043 QGLContextGroup *group = context->d_ptr->group; … … 5161 5234 #if !defined(QT_OPENGL_ES) 5162 5235 if (!glCompressedTexImage2D) { 5163 if (!(QGLExtensions::glExtensions & QGLExtensions::TextureCompression)) {5236 if (!(QGLExtensions::glExtensions() & QGLExtensions::TextureCompression)) { 5164 5237 qWarning("QGLContext::bindTexture(): The GL implementation does " 5165 5238 "not support texture compression extensions."); … … 5200 5273 5201 5274 // Bail out if the necessary extension is not present. 5202 if (!(QGLExtensions::glExtensions & QGLExtensions::DDSTextureCompression)) {5275 if (!(QGLExtensions::glExtensions() & QGLExtensions::DDSTextureCompression)) { 5203 5276 qWarning("QGLContext::bindTexture(): DDS texture compression is not supported."); 5204 5277 return QSize(); … … 5310 5383 // Bail out if the necessary extension is not present. 5311 5384 if (textureFormat == GL_ETC1_RGB8_OES) { 5312 if (!(QGLExtensions::glExtensions &5385 if (!(QGLExtensions::glExtensions() & 5313 5386 QGLExtensions::ETC1TextureCompression)) { 5314 5387 qWarning("QGLContext::bindTexture(): ETC1 texture compression is not supported."); … … 5316 5389 } 5317 5390 } else { 5318 if (!(QGLExtensions::glExtensions &5391 if (!(QGLExtensions::glExtensions() & 5319 5392 QGLExtensions::PVRTCTextureCompression)) { 5320 5393 qWarning("QGLContext::bindTexture(): PVRTC texture compression is not supported."); -
trunk/src/opengl/qgl.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) … … 394 394 friend class QGL2PaintEngineEx; 395 395 friend class QGL2PaintEngineExPrivate; 396 friend class QGLEngineShaderManager; 396 397 friend class QGLWindowSurface; 397 398 friend class QGLPixmapData; 398 399 friend class QGLPixmapFilterBase; 399 400 friend class QGLTextureGlyphCache; 400 friend class QGL ShareRegister;401 friend class QGLContextGroup; 401 402 friend class QGLSharedResourceGuard; 402 403 friend class QGLPixmapBlurFilter; 404 friend class QGLExtensions; 403 405 friend QGLFormat::OpenGLVersionFlags QGLFormat::openGLVersionFlags(); 404 406 #ifdef Q_WS_MAC -
trunk/src/opengl/qgl_cl_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/qgl_egl.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) … … 153 153 d->transpColor = QColor(); 154 154 d->initDone = false; 155 qgl_share_reg()->removeShare(this);155 QGLContextGroup::removeShare(this); 156 156 } 157 157 -
trunk/src/opengl/qgl_egl_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/qgl_mac.mm
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) … … 116 116 extern QRegion qt_mac_convert_mac_region(RgnHandle); //qregion_mac.cpp 117 117 extern void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding=0, int len=-1); //qglobal.cpp 118 119 /* 120 QGLTemporaryContext implementation 121 */ 122 123 class QGLTemporaryContextPrivate 124 { 125 public: 126 #ifndef QT_MAC_USE_COCOA 127 AGLContext ctx; 128 #else 129 NSOpenGLContext *ctx; 130 #endif 131 }; 132 133 QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) 134 : d(new QGLTemporaryContextPrivate) 135 { 136 d->ctx = 0; 137 #ifndef QT_MAC_USE_COCOA 138 GLint attribs[] = {AGL_RGBA, AGL_NONE}; 139 AGLPixelFormat fmt = aglChoosePixelFormat(0, 0, attribs); 140 if (!fmt) { 141 qDebug("QGLTemporaryContext: Couldn't find any RGB visuals"); 142 return; 143 } 144 d->ctx = aglCreateContext(fmt, 0); 145 if (!d->ctx) 146 qDebug("QGLTemporaryContext: Unable to create context"); 147 else 148 aglSetCurrentContext(d->ctx); 149 aglDestroyPixelFormat(fmt); 150 #else 151 QMacCocoaAutoReleasePool pool; 152 NSOpenGLPixelFormatAttribute attribs[] = { 0 }; 153 NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs]; 154 if (!fmt) { 155 qWarning("QGLTemporaryContext: Cannot find any visuals"); 156 return; 157 } 158 159 d->ctx = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:0]; 160 if (!d->ctx) 161 qWarning("QGLTemporaryContext: Cannot create context"); 162 else 163 [d->ctx makeCurrentContext]; 164 [fmt release]; 165 #endif 166 } 167 168 QGLTemporaryContext::~QGLTemporaryContext() 169 { 170 if (d->ctx) { 171 #ifndef QT_MAC_USE_COCOA 172 aglSetCurrentContext(0); 173 aglDestroyContext(d->ctx); 174 #else 175 [NSOpenGLContext clearCurrentContext]; 176 [d->ctx release]; 177 #endif 178 } 179 } 118 180 119 181 bool QGLFormat::hasOpenGL() … … 477 539 d->transpColor = QColor(); 478 540 d->initDone = false; 479 qgl_share_reg()->removeShare(this);541 QGLContextGroup::removeShare(this); 480 542 } 481 543 … … 607 669 } 608 670 } else if (d->paintDevice->devType() == QInternal::Pixmap) { 609 QPixmap *pm = (QPixmap *)d->paintDevice; 610 PixMapHandle mac_pm = GetGWorldPixMap((GWorldPtr)pm->macQDHandle()); 611 aglSetOffScreen((AGLContext)d->cx, pm->width(), pm->height(), 612 GetPixRowBytes(mac_pm), GetPixBaseAddr(mac_pm)); 671 QPixmap *pm = reinterpret_cast<QPixmap *>(d->paintDevice); 672 673 unsigned long qdformat = k32ARGBPixelFormat; 674 if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) 675 qdformat = k32BGRAPixelFormat; 676 Rect rect; 677 SetRect(&rect, 0, 0, pm->width(), pm->height()); 678 679 GWorldPtr gworld; 680 NewGWorldFromPtr(&gworld, qdformat, &rect, 0, 0, 0, 681 reinterpret_cast<char *>(qt_mac_pixmap_get_base(pm)), 682 qt_mac_pixmap_get_bytes_per_line(pm)); 683 684 PixMapHandle pixmapHandle = GetGWorldPixMap(gworld); 685 aglSetOffScreen(reinterpret_cast<AGLContext>(d->cx), pm->width(), pm->height(), 686 GetPixRowBytes(pixmapHandle), GetPixBaseAddr(pixmapHandle)); 613 687 } else { 614 688 qWarning("QGLContext::updatePaintDevice(): Not sure how to render OpenGL on this device!"); … … 907 981 } 908 982 909 910 void QGLExtensions::init()911 {912 static bool init_done = false;913 914 if (init_done)915 return;916 init_done = true;917 918 #ifndef QT_MAC_USE_COCOA919 GLint attribs[] = { AGL_RGBA, AGL_NONE };920 AGLPixelFormat fmt = aglChoosePixelFormat(0, 0, attribs);921 if (!fmt) {922 qDebug("QGLExtensions: Couldn't find any RGB visuals");923 return;924 }925 AGLContext ctx = aglCreateContext(fmt, 0);926 if (!ctx) {927 qDebug("QGLExtensions: Unable to create context");928 } else {929 aglSetCurrentContext(ctx);930 init_extensions();931 aglSetCurrentContext(0);932 aglDestroyContext(ctx);933 }934 aglDestroyPixelFormat(fmt);935 #else936 QMacCocoaAutoReleasePool pool;937 NSOpenGLPixelFormatAttribute attribs[] = { 0 };938 NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];939 if (!fmt) {940 qWarning("QGLExtensions: Cannot find any visuals");941 return;942 }943 944 NSOpenGLContext *ctx = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:0];945 if (!ctx) {946 qWarning("QGLExtensions: Cannot create context");947 } else {948 [ctx makeCurrentContext];949 init_extensions();950 [NSOpenGLContext clearCurrentContext];951 [ctx release];952 }953 [fmt release];954 #endif955 }956 957 983 #endif 958 984 -
trunk/src/opengl/qgl_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) … … 223 223 224 224 // QGLContextPrivate has the responsibility of creating context groups. 225 // QGLContextPrivate and QGLShareRegister will both maintain the reference counter and destroy225 // QGLContextPrivate maintains the reference counter and destroys 226 226 // context groups when needed. 227 // QGLShareRegister has the responsibility of keeping the context pointer up to date.228 227 class QGLContextGroup 229 228 { … … 234 233 const QGLContext *context() const {return m_context;} 235 234 bool isSharing() const { return m_shares.size() >= 2; } 235 QList<const QGLContext *> shares() const { return m_shares; } 236 236 237 237 void addGuard(QGLSharedResourceGuard *guard); 238 238 void removeGuard(QGLSharedResourceGuard *guard); 239 240 static void addShare(const QGLContext *context, const QGLContext *share); 241 static void removeShare(const QGLContext *context); 239 242 private: 240 243 QGLContextGroup(const QGLContext *context) : m_context(context), m_guards(0), m_refs(1) { } … … 250 253 void cleanupResources(const QGLContext *ctx); 251 254 252 friend class QGLShareRegister;253 255 friend class QGLContext; 254 256 friend class QGLContextPrivate; … … 256 258 }; 257 259 258 class QGLTexture; 259 260 class QGLContextPrivate 261 { 262 Q_DECLARE_PUBLIC(QGLContext) 263 public: 264 explicit QGLContextPrivate(QGLContext *context) : internal_context(false), q_ptr(context) {group = new QGLContextGroup(context);} 265 ~QGLContextPrivate(); 266 QGLTexture *bindTexture(const QImage &image, GLenum target, GLint format, 267 QGLContext::BindOptions options); 268 QGLTexture *bindTexture(const QImage &image, GLenum target, GLint format, const qint64 key, 269 QGLContext::BindOptions options); 270 QGLTexture *bindTexture(const QPixmap &pixmap, GLenum target, GLint format, 271 QGLContext::BindOptions options); 272 QGLTexture *textureCacheLookup(const qint64 key, GLenum target); 273 void init(QPaintDevice *dev, const QGLFormat &format); 274 QImage convertToGLFormat(const QImage &image, bool force_premul, GLenum texture_format); 275 int maxTextureSize(); 276 277 void cleanup(); 278 279 #if defined(Q_WS_WIN) 280 HGLRC rc; 281 HDC dc; 282 WId win; 283 int pixelFormatId; 284 QGLCmap* cmap; 285 HBITMAP hbitmap; 286 HDC hbitmap_hdc; 287 #endif 288 #if defined(QT_OPENGL_ES) 289 QEglContext *eglContext; 290 EGLSurface eglSurface; 291 void destroyEglSurfaceForDevice(); 292 #elif defined(Q_WS_X11) || defined(Q_WS_MAC) 293 void* cx; 294 #endif 295 #if defined(Q_WS_X11) || defined(Q_WS_MAC) 296 void* vi; 297 #endif 298 #if defined(Q_WS_X11) 299 void* pbuf; 300 quint32 gpm; 301 int screen; 302 QHash<QPixmapData*, QPixmap> boundPixmaps; 303 QGLTexture *bindTextureFromNativePixmap(QPixmapData*, const qint64 key, 304 QGLContext::BindOptions options); 305 static void destroyGlSurfaceForPixmap(QPixmapData*); 306 static void unbindPixmapFromTexture(QPixmapData*); 307 #endif 308 #if defined(Q_WS_MAC) 309 bool update; 310 void *tryFormat(const QGLFormat &format); 311 void clearDrawable(); 312 #endif 313 QGLFormat glFormat; 314 QGLFormat reqFormat; 315 GLuint fbo; 316 317 uint valid : 1; 318 uint sharing : 1; 319 uint initDone : 1; 320 uint crWin : 1; 321 uint internal_context : 1; 322 uint version_flags_cached : 1; 323 QPaintDevice *paintDevice; 324 QColor transpColor; 325 QGLContext *q_ptr; 326 QGLFormat::OpenGLVersionFlags version_flags; 327 328 QGLContextGroup *group; 329 GLint max_texture_size; 330 331 GLuint current_fbo; 332 GLuint default_fbo; 333 QPaintEngine *active_engine; 334 335 static inline QGLContextGroup *contextGroup(const QGLContext *ctx) { return ctx->d_ptr->group; } 336 337 #ifdef Q_WS_WIN 338 static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *ctx) { return ctx->d_ptr->group->extensionFuncs(); } 339 #endif 340 341 #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) 342 static QGLExtensionFuncs qt_extensionFuncs; 343 static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *) { return qt_extensionFuncs; } 344 #endif 345 346 static void setCurrentContext(QGLContext *context); 347 }; 348 349 // ### make QGLContext a QObject in 5.0 and remove the proxy stuff 350 class Q_OPENGL_EXPORT QGLSignalProxy : public QObject 351 { 352 Q_OBJECT 353 public: 354 QGLSignalProxy() : QObject() {} 355 void emitAboutToDestroyContext(const QGLContext *context) { 356 emit aboutToDestroyContext(context); 357 } 358 static QGLSignalProxy *instance(); 359 Q_SIGNALS: 360 void aboutToDestroyContext(const QGLContext *context); 361 }; 260 // Get the context that resources for "ctx" will transfer to once 261 // "ctx" is destroyed. Returns null if nothing is sharing with ctx. 262 Q_OPENGL_EXPORT const QGLContext *qt_gl_transfer_context(const QGLContext *); 362 263 363 264 // GL extension definitions … … 387 288 Q_DECLARE_FLAGS(Extensions, Extension) 388 289 389 static Extensions glExtensions; 390 static bool nvidiaFboNeedsFinish; 391 static void init(); // sys dependent 392 static void init_extensions(); // general: called by init() 290 static Extensions glExtensions(); 291 292 private: 293 static Extensions currentContextExtensions(); 294 }; 295 296 /* 297 QGLTemporaryContext - the main objective of this class is to have a way of 298 creating a GL context and making it current, without going via QGLWidget 299 and friends. At certain points during GL initialization we need a current 300 context in order decide what GL features are available, and to resolve GL 301 extensions. Having a light-weight way of creating such a context saves 302 initial application startup time, and it doesn't wind up creating recursive 303 conflicts. 304 The class currently uses a private d pointer to hide the platform specific 305 types. This could possibly been done inline with #ifdef'ery, but it causes 306 major headaches on e.g. X11 due to namespace pollution. 307 */ 308 class QGLTemporaryContextPrivate; 309 class QGLTemporaryContext { 310 public: 311 QGLTemporaryContext(bool directRendering = true, QWidget *parent = 0); 312 ~QGLTemporaryContext(); 313 314 private: 315 QScopedPointer<QGLTemporaryContextPrivate> d; 316 }; 317 318 class QGLTexture; 319 320 // This probably needs to grow to GL_MAX_VERTEX_ATTRIBS, but 3 is ok for now as that's 321 // all the GL2 engine uses: 322 #define QT_GL_VERTEX_ARRAY_TRACKED_COUNT 3 323 324 class QGLContextPrivate 325 { 326 Q_DECLARE_PUBLIC(QGLContext) 327 public: 328 explicit QGLContextPrivate(QGLContext *context) : internal_context(false), q_ptr(context) {group = new QGLContextGroup(context);} 329 ~QGLContextPrivate(); 330 QGLTexture *bindTexture(const QImage &image, GLenum target, GLint format, 331 QGLContext::BindOptions options); 332 QGLTexture *bindTexture(const QImage &image, GLenum target, GLint format, const qint64 key, 333 QGLContext::BindOptions options); 334 QGLTexture *bindTexture(const QPixmap &pixmap, GLenum target, GLint format, 335 QGLContext::BindOptions options); 336 QGLTexture *textureCacheLookup(const qint64 key, GLenum target); 337 void init(QPaintDevice *dev, const QGLFormat &format); 338 QImage convertToGLFormat(const QImage &image, bool force_premul, GLenum texture_format); 339 int maxTextureSize(); 340 341 void cleanup(); 342 343 void setVertexAttribArrayEnabled(int arrayIndex, bool enabled = true); 344 void syncGlState(); // Makes sure the GL context's state is what we think it is 345 346 #if defined(Q_WS_WIN) 347 HGLRC rc; 348 HDC dc; 349 WId win; 350 int pixelFormatId; 351 QGLCmap* cmap; 352 HBITMAP hbitmap; 353 HDC hbitmap_hdc; 354 #endif 355 #if defined(QT_OPENGL_ES) 356 QEglContext *eglContext; 357 EGLSurface eglSurface; 358 void destroyEglSurfaceForDevice(); 359 #elif defined(Q_WS_X11) || defined(Q_WS_MAC) 360 void* cx; 361 #endif 362 #if defined(Q_WS_X11) || defined(Q_WS_MAC) 363 void* vi; 364 #endif 365 #if defined(Q_WS_X11) 366 void* pbuf; 367 quint32 gpm; 368 int screen; 369 QHash<QPixmapData*, QPixmap> boundPixmaps; 370 QGLTexture *bindTextureFromNativePixmap(QPixmapData*, const qint64 key, 371 QGLContext::BindOptions options); 372 static void destroyGlSurfaceForPixmap(QPixmapData*); 373 static void unbindPixmapFromTexture(QPixmapData*); 374 #endif 375 #if defined(Q_WS_MAC) 376 bool update; 377 void *tryFormat(const QGLFormat &format); 378 void clearDrawable(); 379 #endif 380 QGLFormat glFormat; 381 QGLFormat reqFormat; 382 GLuint fbo; 383 384 uint valid : 1; 385 uint sharing : 1; 386 uint initDone : 1; 387 uint crWin : 1; 388 uint internal_context : 1; 389 uint version_flags_cached : 1; 390 uint extension_flags_cached : 1; 391 QPaintDevice *paintDevice; 392 QColor transpColor; 393 QGLContext *q_ptr; 394 QGLFormat::OpenGLVersionFlags version_flags; 395 QGLExtensions::Extensions extension_flags; 396 397 QGLContextGroup *group; 398 GLint max_texture_size; 399 400 GLuint current_fbo; 401 GLuint default_fbo; 402 QPaintEngine *active_engine; 403 404 bool vertexAttributeArraysEnabledState[QT_GL_VERTEX_ARRAY_TRACKED_COUNT]; 405 406 static inline QGLContextGroup *contextGroup(const QGLContext *ctx) { return ctx->d_ptr->group; } 407 408 #ifdef Q_WS_WIN 409 static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *ctx) { return ctx->d_ptr->group->extensionFuncs(); } 410 #endif 411 412 #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) 413 static QGLExtensionFuncs qt_extensionFuncs; 414 static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *) { return qt_extensionFuncs; } 415 #endif 416 417 static void setCurrentContext(QGLContext *context); 418 }; 419 420 // ### make QGLContext a QObject in 5.0 and remove the proxy stuff 421 class Q_OPENGL_EXPORT QGLSignalProxy : public QObject 422 { 423 Q_OBJECT 424 public: 425 QGLSignalProxy() : QObject() {} 426 void emitAboutToDestroyContext(const QGLContext *context) { 427 emit aboutToDestroyContext(context); 428 } 429 static QGLSignalProxy *instance(); 430 Q_SIGNALS: 431 void aboutToDestroyContext(const QGLContext *context); 393 432 }; 394 433 395 434 Q_DECLARE_OPERATORS_FOR_FLAGS(QGLExtensions::Extensions) 396 397 398 class Q_OPENGL_EXPORT QGLShareRegister399 {400 public:401 QGLShareRegister() {}402 ~QGLShareRegister() {}403 404 void addShare(const QGLContext *context, const QGLContext *share);405 QList<const QGLContext *> shares(const QGLContext *context);406 void removeShare(const QGLContext *context);407 };408 409 extern Q_OPENGL_EXPORT QGLShareRegister* qgl_share_reg();410 435 411 436 // Temporarily make a context current if not already current or … … 498 523 }; 499 524 500 class Q GLTextureCache {525 class Q_AUTOTEST_EXPORT QGLTextureCache { 501 526 public: 502 527 QGLTextureCache(); … … 515 540 static void deleteIfEmpty(); 516 541 static void imageCleanupHook(qint64 cacheKey); 517 static void cleanupTextures(QPixmap* pixmap); 518 #ifdef Q_WS_X11 519 // X11 needs to catch pixmap data destruction to delete EGL/GLX pixmap surfaces 520 static void cleanupPixmapSurfaces(QPixmap* pixmap); 521 #endif 542 static void cleanupTextures(QPixmapData* pixmap); 543 static void cleanupBeforePixmapDestruction(QPixmapData* pixmap); 522 544 523 545 private: … … 532 554 inline GLenum qt_gl_preferredTextureFormat() 533 555 { 534 return (QGLExtensions::glExtensions & QGLExtensions::BGRATextureFormat) && QSysInfo::ByteOrder == QSysInfo::LittleEndian556 return (QGLExtensions::glExtensions() & QGLExtensions::BGRATextureFormat) && QSysInfo::ByteOrder == QSysInfo::LittleEndian 535 557 ? GL_BGRA : GL_RGBA; 536 558 } … … 541 563 return GL_TEXTURE_2D; 542 564 #else 543 return (QGLExtensions::glExtensions & QGLExtensions::TextureRectangle)565 return (QGLExtensions::glExtensions() & QGLExtensions::TextureRectangle) 544 566 && !qt_gl_preferGL2Engine() 545 567 ? GL_TEXTURE_RECTANGLE_NV … … 613 635 614 636 615 // This class can be used to match GL extensions with doing any mallocs. The637 // This class can be used to match GL extensions without doing any mallocs. The 616 638 // class assumes that the GL extension string ends with a space character, 617 639 // which it should do on all conformant platforms. Create the object and pass -
trunk/src/opengl/qgl_qws.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) … … 82 82 else 83 83 return 0; 84 } 85 86 /* 87 QGLTemporaryContext implementation 88 */ 89 90 class QGLTemporaryContextPrivate 91 { 92 public: 93 QGLWidget *widget; 94 }; 95 96 QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) 97 : d(new QGLTemporaryContextPrivate) 98 { 99 d->widget = new QGLWidget; 100 d->widget->makeCurrent(); 101 } 102 103 QGLTemporaryContext::~QGLTemporaryContext() 104 { 105 delete d->widget; 84 106 } 85 107 … … 312 334 } 313 335 314 void QGLExtensions::init()315 {316 static bool init_done = false;317 318 if (init_done)319 return;320 init_done = true;321 322 // We need a context current to initialize the extensions,323 // but getting a valid EGLNativeWindowType this early can be324 // problematic under QWS. So use a pbuffer instead.325 //326 // Unfortunately OpenGL/ES 2.0 systems don't normally327 // support pbuffers, so we have no choice but to try328 // our luck with a window on those systems.329 #if defined(QT_OPENGL_ES_2)330 QGLWidget tmpWidget;331 tmpWidget.makeCurrent();332 333 init_extensions();334 335 tmpWidget.doneCurrent();336 #else337 QGLPixelBuffer pbuffer(16, 16);338 pbuffer.makeCurrent();339 340 init_extensions();341 342 pbuffer.doneCurrent();343 #endif344 }345 346 336 QT_END_NAMESPACE -
trunk/src/opengl/qgl_win.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) … … 552 552 QVarLengthArray<int> iValues(40); 553 553 int i = 0; 554 bool has_sample_buffers = QGLExtensions::glExtensions & QGLExtensions::SampleBuffers;554 bool has_sample_buffers = QGLExtensions::glExtensions() & QGLExtensions::SampleBuffers; 555 555 556 556 iAttributes[i++] = WGL_DOUBLE_BUFFER_ARB; // 0 … … 629 629 630 630 /* 631 Creates a temporary GL context and makes it current 632 - cleans up when the object is destructed. 631 QGLTemporaryContext implementation 633 632 */ 634 633 635 634 Q_GUI_EXPORT const QString qt_getRegisteredWndClass(); 636 635 637 class QGLTemp Context636 class QGLTemporaryContextPrivate 638 637 { 639 638 public: 640 QGLTempContext(bool directRendering, QWidget *parent = 0)641 {642 QString windowClassName = qt_getRegisteredWndClass();643 if (parent && !parent->internalWinId())644 parent = parent->nativeParentWidget();645 646 dmy_id = CreateWindow((const wchar_t *)windowClassName.utf16(),647 0, 0, 0, 0, 1, 1,648 parent ? parent->winId() : 0, 0, qWinAppInst(), 0);649 650 dmy_pdc = GetDC(dmy_id);651 PIXELFORMATDESCRIPTOR dmy_pfd;652 memset(&dmy_pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));653 dmy_pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);654 dmy_pfd.nVersion = 1;655 dmy_pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;656 dmy_pfd.iPixelType = PFD_TYPE_RGBA;657 if (!directRendering)658 dmy_pfd.dwFlags |= PFD_GENERIC_FORMAT;659 660 int dmy_pf = ChoosePixelFormat(dmy_pdc, &dmy_pfd);661 SetPixelFormat(dmy_pdc, dmy_pf, &dmy_pfd);662 dmy_rc = wglCreateContext(dmy_pdc);663 old_dc = wglGetCurrentDC();664 old_context = wglGetCurrentContext();665 wglMakeCurrent(dmy_pdc, dmy_rc);666 }667 668 ~QGLTempContext() {669 wglMakeCurrent(dmy_pdc, 0);670 wglDeleteContext(dmy_rc);671 ReleaseDC(dmy_id, dmy_pdc);672 DestroyWindow(dmy_id);673 if (old_dc && old_context)674 wglMakeCurrent(old_dc, old_context);675 }676 677 639 HDC dmy_pdc; 678 640 HGLRC dmy_rc; … … 681 643 WId dmy_id; 682 644 }; 645 646 QGLTemporaryContext::QGLTemporaryContext(bool directRendering, QWidget *parent) 647 : d(new QGLTemporaryContextPrivate) 648 { 649 QString windowClassName = qt_getRegisteredWndClass(); 650 if (parent && !parent->internalWinId()) 651 parent = parent->nativeParentWidget(); 652 653 d->dmy_id = CreateWindow((const wchar_t *)windowClassName.utf16(), 654 0, 0, 0, 0, 1, 1, 655 parent ? parent->winId() : 0, 0, qWinAppInst(), 0); 656 657 d->dmy_pdc = GetDC(d->dmy_id); 658 PIXELFORMATDESCRIPTOR dmy_pfd; 659 memset(&dmy_pfd, 0, sizeof(PIXELFORMATDESCRIPTOR)); 660 dmy_pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); 661 dmy_pfd.nVersion = 1; 662 dmy_pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW; 663 dmy_pfd.iPixelType = PFD_TYPE_RGBA; 664 if (!directRendering) 665 dmy_pfd.dwFlags |= PFD_GENERIC_FORMAT; 666 667 int dmy_pf = ChoosePixelFormat(d->dmy_pdc, &dmy_pfd); 668 SetPixelFormat(d->dmy_pdc, dmy_pf, &dmy_pfd); 669 d->dmy_rc = wglCreateContext(d->dmy_pdc); 670 d->old_dc = wglGetCurrentDC(); 671 d->old_context = wglGetCurrentContext(); 672 wglMakeCurrent(d->dmy_pdc, d->dmy_rc); 673 } 674 675 QGLTemporaryContext::~QGLTemporaryContext() 676 { 677 wglMakeCurrent(d->dmy_pdc, 0); 678 wglDeleteContext(d->dmy_rc); 679 ReleaseDC(d->dmy_id, d->dmy_pdc); 680 DestroyWindow(d->dmy_id); 681 if (d->old_dc && d->old_context) 682 wglMakeCurrent(d->old_dc, d->old_context); 683 } 683 684 684 685 bool QGLContext::chooseContext(const QGLContext* shareContext) … … 722 723 } 723 724 724 // NB! the QGLTemp Context object is needed for the725 // NB! the QGLTemporaryContext object is needed for the 725 726 // wglGetProcAddress() calls to succeed and are absolutely 726 727 // necessary - don't remove! 727 QGLTemp Context tmp_ctx(d->glFormat.directRendering(), widget);728 QGLTemporaryContext tmp_ctx(d->glFormat.directRendering(), widget); 728 729 729 730 if (!myDc) { … … 966 967 } 967 968 int si = 0; 968 bool trySampleBuffers = QGLExtensions::glExtensions & QGLExtensions::SampleBuffers;969 bool trySampleBuffers = QGLExtensions::glExtensions() & QGLExtensions::SampleBuffers; 969 970 if (trySampleBuffers && d->glFormat.sampleBuffers()) { 970 971 iAttributes[i++] = WGL_SAMPLE_BUFFERS_ARB; … … 1146 1147 d->cmap = 0; 1147 1148 d->initDone = false; 1148 qgl_share_reg()->removeShare(this);1149 QGLContextGroup::removeShare(this); 1149 1150 } 1150 1151 … … 1472 1473 } 1473 1474 1474 void QGLExtensions::init()1475 {1476 static bool init_done = false;1477 1478 if (init_done)1479 return;1480 init_done = true;1481 QGLTempContext temp_ctx(QGLFormat::defaultFormat().directRendering());1482 init_extensions();1483 }1484 1485 1475 QT_END_NAMESPACE -
trunk/src/opengl/qgl_wince.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) … … 96 96 #include <qcolor.h> 97 97 98 99 98 /* 99 QGLTemporaryContext implementation 100 */ 101 102 class QGLTemporaryContextPrivate 103 { 104 public: 105 QGLWidget *widget; 106 }; 107 108 QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) 109 : d(new QGLTemporaryContextPrivate) 110 { 111 d->widget = new QGLWidget; 112 d->widget->makeCurrent(); 113 } 114 115 QGLTemporaryContext::~QGLTemporaryContext() 116 { 117 delete d->widget; 118 } 100 119 101 120 /***************************************************************************** … … 628 647 } 629 648 630 void QGLExtensions::init()631 {632 static bool init_done = false;633 634 if (init_done)635 return;636 init_done = true;637 638 // We need a context current to initialize the extensions.639 QGLWidget tmpWidget;640 tmpWidget.makeCurrent();641 642 init_extensions();643 644 tmpWidget.doneCurrent();645 }646 647 649 QT_END_NAMESPACE -
trunk/src/opengl/qgl_x11.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) … … 550 550 bool triedSample = false; 551 551 if (fmt.sampleBuffers()) 552 fmt.setSampleBuffers(QGLExtensions::glExtensions & QGLExtensions::SampleBuffers);552 fmt.setSampleBuffers(QGLExtensions::glExtensions() & QGLExtensions::SampleBuffers); 553 553 while(!fail && !(vis = tryVisual(fmt, bufDepths[i]))) { 554 554 if (!fmt.rgba() && bufDepths[i] > 1) { … … 826 826 d->transpColor = QColor(); 827 827 d->initDone = false; 828 qgl_share_reg()->removeShare(this);828 QGLContextGroup::removeShare(this); 829 829 } 830 830 … … 1133 1133 } 1134 1134 1135 /* 1136 QGLTemporaryContext implementation 1137 */ 1138 1139 class QGLTemporaryContextPrivate { 1140 public: 1141 bool initialized; 1142 Window drawable; 1143 GLXContext context; 1144 GLXDrawable oldDrawable; 1145 GLXContext oldContext; 1146 }; 1147 1148 QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) 1149 : d(new QGLTemporaryContextPrivate) 1150 { 1151 d->initialized = false; 1152 d->oldDrawable = 0; 1153 d->oldContext = 0; 1154 int screen = 0; 1155 1156 int attribs[] = {GLX_RGBA, XNone}; 1157 XVisualInfo *vi = glXChooseVisual(X11->display, screen, attribs); 1158 if (!vi) { 1159 qWarning("QGLTempContext: No GL capable X visuals available."); 1160 return; 1161 } 1162 1163 int useGL; 1164 glXGetConfig(X11->display, vi, GLX_USE_GL, &useGL); 1165 if (!useGL) { 1166 XFree(vi); 1167 return; 1168 } 1169 1170 d->oldDrawable = glXGetCurrentDrawable(); 1171 d->oldContext = glXGetCurrentContext(); 1172 1173 XSetWindowAttributes a; 1174 a.colormap = qt_gl_choose_cmap(X11->display, vi); 1175 d->drawable = XCreateWindow(X11->display, RootWindow(X11->display, screen), 1176 0, 0, 1, 1, 0, 1177 vi->depth, InputOutput, vi->visual, 1178 CWColormap, &a); 1179 d->context = glXCreateContext(X11->display, vi, 0, True); 1180 if (d->context && glXMakeCurrent(X11->display, d->drawable, d->context)) { 1181 d->initialized = true; 1182 } else { 1183 qWarning("QGLTempContext: Unable to create GL context."); 1184 XDestroyWindow(X11->display, d->drawable); 1185 } 1186 XFree(vi); 1187 } 1188 1189 QGLTemporaryContext::~QGLTemporaryContext() 1190 { 1191 if (d->initialized) { 1192 glXMakeCurrent(X11->display, 0, 0); 1193 glXDestroyContext(X11->display, d->context); 1194 XDestroyWindow(X11->display, d->drawable); 1195 } 1196 if (d->oldDrawable && d->oldContext) 1197 glXMakeCurrent(X11->display, d->oldDrawable, d->oldContext); 1198 } 1199 1135 1200 /***************************************************************************** 1136 1201 QGLOverlayWidget (Internal overlay class for X11) … … 1567 1632 } 1568 1633 1569 void QGLExtensions::init()1570 {1571 static bool init_done = false;1572 1573 if (init_done)1574 return;1575 init_done = true;1576 1577 QGLWidget dmy;1578 dmy.makeCurrent();1579 init_extensions();1580 1581 // nvidia 9x.xx unix drivers contain a bug which requires us to call glFinish before releasing an fbo1582 // to avoid painting artifacts1583 const QByteArray versionString(reinterpret_cast<const char*>(glGetString(GL_VERSION)));1584 const int pos = versionString.indexOf("NVIDIA");1585 if (pos >= 0) {1586 const float nvidiaDriverVersion = versionString.mid(pos + strlen("NVIDIA")).toFloat();1587 nvidiaFboNeedsFinish = nvidiaDriverVersion >= 90.0 && nvidiaDriverVersion < 100.0;1588 }1589 }1590 1591 1634 // Solaris defines glXBindTexImageEXT as part of the GL library 1592 1635 #if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) … … 1604 1647 1605 1648 // Check to see if we have NPOT texture support 1606 if ( !(QGLExtensions::glExtensions & QGLExtensions::NPOTTextures) &&1649 if ( !(QGLExtensions::glExtensions() & QGLExtensions::NPOTTextures) && 1607 1650 !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)) 1608 1651 { 1609 1652 return false; // Can't use TFP without NPOT 1610 1653 } 1654 1611 1655 const QX11Info *xinfo = qt_x11Info(paintDevice); 1612 QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen())); 1656 Display *display = xinfo ? xinfo->display() : X11->display; 1657 int screen = xinfo ? xinfo->screen() : X11->defaultScreen; 1658 1659 QGLExtensionMatcher extensions(glXQueryExtensionsString(display, screen)); 1613 1660 if (extensions.match("GLX_EXT_texture_from_pixmap")) { 1614 1661 glXBindTexImageEXT = (qt_glXBindTexImageEXT) qglx_getProcAddress("glXBindTexImageEXT"); -
trunk/src/opengl/qgl_x11egl.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) … … 53 53 QT_BEGIN_NAMESPACE 54 54 55 56 bool qt_egl_setup_x11_visual(XVisualInfo &vi, EGLDisplay display, EGLConfig config, 57 const QX11Info &x11Info, bool useArgbVisual); 58 59 /* 60 QGLTemporaryContext implementation 61 */ 62 63 class QGLTemporaryContextPrivate 64 { 65 public: 66 bool initialized; 67 Window window; 68 EGLContext context; 69 EGLSurface surface; 70 EGLDisplay display; 71 }; 72 73 QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) 74 : d(new QGLTemporaryContextPrivate) 75 { 76 d->initialized = false; 77 d->window = 0; 78 d->context = 0; 79 d->surface = 0; 80 int screen = 0; 81 82 d->display = eglGetDisplay(EGLNativeDisplayType(X11->display)); 83 84 if (!eglInitialize(d->display, NULL, NULL)) { 85 qWarning("QGLTemporaryContext: Unable to initialize EGL display."); 86 return; 87 } 88 89 EGLConfig config; 90 int numConfigs = 0; 91 EGLint attribs[] = { 92 EGL_SURFACE_TYPE, EGL_WINDOW_BIT, 93 #ifdef QT_OPENGL_ES_2 94 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, 95 #endif 96 EGL_NONE 97 }; 98 99 eglChooseConfig(d->display, attribs, &config, 1, &numConfigs); 100 if (!numConfigs) { 101 qWarning("QGLTemporaryContext: No EGL configurations available."); 102 return; 103 } 104 105 XVisualInfo visualInfo; 106 XVisualInfo *vi; 107 int numVisuals; 108 EGLint id = 0; 109 110 eglGetConfigAttrib(d->display, config, EGL_NATIVE_VISUAL_ID, &id); 111 if (id == 0) { 112 // EGL_NATIVE_VISUAL_ID is optional and might not be supported 113 // on some implementations - we'll have to do it the hard way 114 QX11Info xinfo; 115 qt_egl_setup_x11_visual(visualInfo, d->display, config, xinfo, false); 116 } else { 117 visualInfo.visualid = id; 118 } 119 vi = XGetVisualInfo(X11->display, VisualIDMask, &visualInfo, &numVisuals); 120 if (!vi || numVisuals < 1) { 121 qWarning("QGLTemporaryContext: Unable to get X11 visual info id."); 122 return; 123 } 124 125 d->window = XCreateWindow(X11->display, RootWindow(X11->display, screen), 126 0, 0, 1, 1, 0, 127 vi->depth, InputOutput, vi->visual, 128 0, 0); 129 130 d->surface = eglCreateWindowSurface(d->display, config, (EGLNativeWindowType) d->window, NULL); 131 132 if (d->surface == EGL_NO_SURFACE) { 133 qWarning("QGLTemporaryContext: Error creating EGL surface."); 134 XFree(vi); 135 XDestroyWindow(X11->display, d->window); 136 return; 137 } 138 139 EGLint contextAttribs[] = { 140 #ifdef QT_OPENGL_ES_2 141 EGL_CONTEXT_CLIENT_VERSION, 2, 142 #endif 143 EGL_NONE 144 }; 145 d->context = eglCreateContext(d->display, config, 0, contextAttribs); 146 if (d->context != EGL_NO_CONTEXT 147 && eglMakeCurrent(d->display, d->surface, d->surface, d->context)) 148 { 149 d->initialized = true; 150 } else { 151 qWarning("QGLTemporaryContext: Error creating EGL context."); 152 eglDestroySurface(d->display, d->surface); 153 XDestroyWindow(X11->display, d->window); 154 } 155 XFree(vi); 156 } 157 158 QGLTemporaryContext::~QGLTemporaryContext() 159 { 160 if (d->initialized) { 161 eglMakeCurrent(d->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); 162 eglDestroyContext(d->display, d->context); 163 eglDestroySurface(d->display, d->surface); 164 XDestroyWindow(X11->display, d->window); 165 } 166 } 167 55 168 bool QGLFormat::hasOpenGLOverlays() 56 169 { … … 240 353 // If EGL does not know the visual ID, so try to select an appropriate one ourselves, first 241 354 // using XRender if we're supposed to have an alpha, then falling back to XGetVisualInfo 242 355 243 356 #if !defined(QT_NO_XRENDER) 244 357 if (vi.visualid == 0 && useArgbVisual) { … … 438 551 } 439 552 440 void QGLExtensions::init()441 {442 static bool init_done = false;443 444 if (init_done)445 return;446 init_done = true;447 448 // We need a context current to initialize the extensions.449 QGLWidget tmpWidget;450 tmpWidget.makeCurrent();451 452 init_extensions();453 454 tmpWidget.doneCurrent();455 }456 457 553 // Re-creates the EGL surface if the window ID has changed or if force is true 458 554 void QGLWidgetPrivate::recreateEglSurface(bool force) -
trunk/src/opengl/qglcolormap.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/qglcolormap.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/qglextensions.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/qglextensions_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/qglframebufferobject.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) … … 397 397 fbo_guard.setContext(ctx); 398 398 399 bool ext_detected = (QGLExtensions::glExtensions & QGLExtensions::FramebufferObject);399 bool ext_detected = (QGLExtensions::glExtensions() & QGLExtensions::FramebufferObject); 400 400 if (!ext_detected || (ext_detected && !qt_resolve_framebufferobject_extensions(ctx))) 401 401 return; … … 467 467 468 468 if (attachment == QGLFramebufferObject::CombinedDepthStencil 469 && (QGLExtensions::glExtensions & QGLExtensions::PackedDepthStencil)) {469 && (QGLExtensions::glExtensions() & QGLExtensions::PackedDepthStencil)) { 470 470 // depth and stencil buffer needs another extension 471 471 glGenRenderbuffers(1, &depth_stencil_buffer); … … 1029 1029 bool QGLFramebufferObject::hasOpenGLFramebufferObjects() 1030 1030 { 1031 QGLExtensions::init(); 1032 return (QGLExtensions::glExtensions & QGLExtensions::FramebufferObject); 1031 return (QGLExtensions::glExtensions() & QGLExtensions::FramebufferObject); 1033 1032 } 1034 1033 … … 1189 1188 bool QGLFramebufferObject::hasOpenGLFramebufferBlit() 1190 1189 { 1191 QGLExtensions::init(); 1192 return (QGLExtensions::glExtensions & QGLExtensions::FramebufferBlit); 1190 return (QGLExtensions::glExtensions() & QGLExtensions::FramebufferBlit); 1193 1191 } 1194 1192 … … 1230 1228 GLenum filter) 1231 1229 { 1232 if (!(QGLExtensions::glExtensions & QGLExtensions::FramebufferBlit))1230 if (!(QGLExtensions::glExtensions() & QGLExtensions::FramebufferBlit)) 1233 1231 return; 1234 1232 -
trunk/src/opengl/qglframebufferobject.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/qglframebufferobject_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/qglpaintdevice.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/qglpaintdevice_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/qglpixelbuffer.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) … … 128 128 qctx->d_func()->sharing = (shareWidget != 0); 129 129 if (shareWidget != 0 && shareWidget->d_func()->glcx) { 130 qgl_share_reg()->addShare(qctx, shareWidget->d_func()->glcx);130 QGLContextGroup::addShare(qctx, shareWidget->d_func()->glcx); 131 131 shareWidget->d_func()->glcx->d_func()->sharing = true; 132 132 } -
trunk/src/opengl/qglpixelbuffer.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/qglpixelbuffer_egl.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/qglpixelbuffer_mac.mm
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) … … 93 93 GLenum target = GL_TEXTURE_2D; 94 94 95 if ((QGLExtensions::glExtensions & QGLExtensions::TextureRectangle)95 if ((QGLExtensions::glExtensions() & QGLExtensions::TextureRectangle) 96 96 && (size.width() != nearest_gl_texture_size(size.width()) 97 97 || size.height() != nearest_gl_texture_size(size.height()))) … … 224 224 GLenum target = GL_TEXTURE_2D; 225 225 226 if ((QGLExtensions::glExtensions & QGLExtensions::TextureRectangle)226 if ((QGLExtensions::glExtensions() & QGLExtensions::TextureRectangle) 227 227 && (size.width() != nearest_gl_texture_size(size.width()) 228 228 || size.height() != nearest_gl_texture_size(size.height()))) -
trunk/src/opengl/qglpixelbuffer_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) … … 155 155 QGLPixelBufferPrivate(QGLPixelBuffer *q) : q_ptr(q), invalid(true), qctx(0), pbuf(0), ctx(0) 156 156 { 157 QGLExtensions::init();158 157 #ifdef Q_WS_WIN 159 158 dc = 0; -
trunk/src/opengl/qglpixelbuffer_win.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) … … 222 222 if ((f.redBufferSize() > 8 || f.greenBufferSize() > 8 223 223 || f.blueBufferSize() > 8 || f.alphaBufferSize() > 8) 224 && (QGLExtensions::glExtensions & QGLExtensions::NVFloatBuffer))224 && (QGLExtensions::glExtensions() & QGLExtensions::NVFloatBuffer)) 225 225 { 226 226 attribs[i++] = WGL_FLOAT_COMPONENTS_NV; … … 369 369 { 370 370 bool ret = false; 371 QGLWidget *dmy = 0; 372 if (!QGLContext::currentContext()) { 373 dmy = new QGLWidget; 374 dmy->makeCurrent(); 375 } 371 QGLTemporaryContext *tmpContext = 0; 372 if (!QGLContext::currentContext()) 373 tmpContext = new QGLTemporaryContext; 376 374 PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = 377 375 (PFNWGLGETEXTENSIONSSTRINGARBPROC) wglGetProcAddress("wglGetExtensionsStringARB"); … … 383 381 } 384 382 } 385 if ( dmy)386 delete dmy;383 if (tmpContext) 384 delete tmpContext; 387 385 return ret; 388 386 } -
trunk/src/opengl/qglpixelbuffer_x11.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/qglpixmapfilter.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) … … 320 320 321 321 QGLBlurTextureInfo *takeBlurTextureInfo(const QPixmap &pixmap); 322 bool hasBlurTextureInfo( const QPixmap &pixmap) const;322 bool hasBlurTextureInfo(quint64 cacheKey) const; 323 323 void insertBlurTextureInfo(const QPixmap &pixmap, QGLBlurTextureInfo *info); 324 void clearBlurTextureInfo( const QPixmap &pixmap);324 void clearBlurTextureInfo(quint64 cacheKey); 325 325 326 326 void timerEvent(QTimerEvent *event); 327 327 328 328 private: 329 static void pixmapDestroyed(QPixmap *pixmap);329 static void pixmapDestroyed(QPixmapData *pixmap); 330 330 331 331 QCache<quint64, QGLBlurTextureInfo > cache; … … 380 380 } 381 381 382 void QGLBlurTextureCache::clearBlurTextureInfo( const QPixmap &pixmap)383 { 384 cache.remove( pixmap.cacheKey());385 } 386 387 bool QGLBlurTextureCache::hasBlurTextureInfo( const QPixmap &pixmap) const388 { 389 return cache.contains( pixmap.cacheKey());382 void QGLBlurTextureCache::clearBlurTextureInfo(quint64 cacheKey) 383 { 384 cache.remove(cacheKey); 385 } 386 387 bool QGLBlurTextureCache::hasBlurTextureInfo(quint64 cacheKey) const 388 { 389 return cache.contains(cacheKey); 390 390 } 391 391 … … 394 394 static bool hookAdded = false; 395 395 if (!hookAdded) { 396 QImagePixmapCleanupHooks::instance()->addPixmapD estructionHook(pixmapDestroyed);396 QImagePixmapCleanupHooks::instance()->addPixmapDataDestructionHook(pixmapDestroyed); 397 397 hookAdded = true; 398 398 } … … 407 407 } 408 408 409 void QGLBlurTextureCache::pixmapDestroyed(QPixmap *pixmap)409 void QGLBlurTextureCache::pixmapDestroyed(QPixmapData *pmd) 410 410 { 411 411 foreach (QGLBlurTextureCache *cache, blurTextureCaches) { 412 if (cache->hasBlurTextureInfo( *pixmap))413 cache->clearBlurTextureInfo( *pixmap);412 if (cache->hasBlurTextureInfo(pmd->cacheKey())) 413 cache->clearBlurTextureInfo(pmd->cacheKey()); 414 414 } 415 415 } -
trunk/src/opengl/qglpixmapfilter_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/qglscreen_qws.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/qglscreen_qws.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/qglshaderprogram.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) … … 106 106 107 107 \snippet doc/src/snippets/code/src_opengl_qglshaderprogram.cpp 2 108 109 \section1 Binary shaders and programs 110 111 Binary shaders may be specified using \c{glShaderBinary()} on 112 the return value from QGLShader::shaderId(). The QGLShader instance 113 containing the binary can then be added to the shader program with 114 addShader() and linked in the usual fashion with link(). 115 116 Binary programs may be specified using \c{glProgramBinaryOES()} 117 on the return value from programId(). Then the application should 118 call link(), which will notice that the program has already been 119 specified and linked, allowing other operations to be performed 120 on the shader program. 108 121 109 122 \sa QGLShader … … 633 646 return false; 634 647 } 635 if (!shader->d_func()->compiled)636 return false;637 648 if (!shader->d_func()->shaderGuard.id()) 638 649 return false; … … 821 832 if (!program) 822 833 return false; 834 GLint value; 835 if (d->shaders.isEmpty()) { 836 // If there are no explicit shaders, then it is possible that the 837 // application added a program binary with glProgramBinaryOES(), 838 // or otherwise populated the shaders itself. Check to see if the 839 // program is already linked and bail out if so. 840 value = 0; 841 glGetProgramiv(program, GL_LINK_STATUS, &value); 842 d->linked = (value != 0); 843 if (d->linked) 844 return true; 845 } 823 846 glLinkProgram(program); 824 GLintvalue = 0;847 value = 0; 825 848 glGetProgramiv(program, GL_LINK_STATUS, &value); 826 849 d->linked = (value != 0); … … 929 952 { 930 953 Q_D(const QGLShaderProgram); 954 GLuint id = d->programGuard.id(); 955 if (id) 956 return id; 957 958 // Create the identifier if we don't have one yet. This is for 959 // applications that want to create the attached shader configuration 960 // themselves, particularly those using program binaries. 961 if (!const_cast<QGLShaderProgram *>(this)->init()) 962 return 0; 931 963 return d->programGuard.id(); 932 964 } -
trunk/src/opengl/qglshaderprogram.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/qglwindowsurface_qws.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/qglwindowsurface_qws_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/qgraphicsshadereffect.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/qgraphicsshadereffect_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/qgraphicssystem_gl.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/qgraphicssystem_gl_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/qpaintengine_opengl.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) … … 109 109 #endif 110 110 111 #ifdef Q_WS_X11 112 static bool qt_nvidiaFboNeedsFinish = false; 113 #endif 114 111 115 static inline void qt_glColor4ubv(unsigned char *col) 112 116 { … … 424 428 #ifdef Q_WS_X11 425 429 // workaround for bug in nvidia driver versions 9x.xx 426 if ( QGLExtensions::nvidiaFboNeedsFinish)430 if (qt_nvidiaFboNeedsFinish) 427 431 glFinish(); 428 432 #endif … … 478 482 bool QGLOffscreen::isSupported() 479 483 { 480 return (QGLExtensions::glExtensions & QGLExtensions::FramebufferObject); // for fbo484 return (QGLExtensions::glExtensions() & QGLExtensions::FramebufferObject); // for fbo 481 485 } 482 486 … … 1267 1271 d->mv_matrix[i][j] = (i == j ? qreal(1) : qreal(0)); 1268 1272 1269 bool has_frag_program = (QGLExtensions::glExtensions & QGLExtensions::FragmentProgram)1273 bool has_frag_program = (QGLExtensions::glExtensions() & QGLExtensions::FragmentProgram) 1270 1274 && (pdev->devType() != QInternal::Pixmap); 1271 1275 … … 1280 1284 1281 1285 d->use_stencil_method = d->device->format().stencil() 1282 && (QGLExtensions::glExtensions & QGLExtensions::StencilWrap);1286 && (QGLExtensions::glExtensions() & QGLExtensions::StencilWrap); 1283 1287 if (d->device->format().directRendering() 1284 && (d->use_stencil_method && QGLExtensions::glExtensions & QGLExtensions::StencilTwoSide))1288 && (d->use_stencil_method && QGLExtensions::glExtensions() & QGLExtensions::StencilTwoSide)) 1285 1289 d->has_stencil_face_ext = qt_resolve_stencil_face_extension(ctx); 1290 1291 #ifdef Q_WS_X11 1292 static bool nvidia_workaround_needs_init = true; 1293 if (nvidia_workaround_needs_init) { 1294 // nvidia 9x.xx unix drivers contain a bug which requires us to 1295 // call glFinish before releasing an fbo to avoid painting 1296 // artifacts 1297 const QByteArray versionString(reinterpret_cast<const char*>(glGetString(GL_VERSION))); 1298 const int pos = versionString.indexOf("NVIDIA"); 1299 if (pos >= 0) { 1300 const float nvidiaDriverVersion = versionString.mid(pos + strlen("NVIDIA")).toFloat(); 1301 qt_nvidiaFboNeedsFinish = nvidiaDriverVersion >= 90.0 && nvidiaDriverVersion < 100.0; 1302 } 1303 nvidia_workaround_needs_init = false; 1304 } 1305 #endif 1286 1306 1287 1307 #ifndef QT_OPENGL_ES … … 1334 1354 glDisableClientState(GL_VERTEX_ARRAY); 1335 1355 1336 if (QGLExtensions::glExtensions & QGLExtensions::SampleBuffers)1356 if (QGLExtensions::glExtensions() & QGLExtensions::SampleBuffers) 1337 1357 glDisable(GL_MULTISAMPLE); 1338 1358 glDisable(GL_TEXTURE_2D); 1339 if (QGLExtensions::glExtensions & QGLExtensions::TextureRectangle)1359 if (QGLExtensions::glExtensions() & QGLExtensions::TextureRectangle) 1340 1360 glDisable(GL_TEXTURE_RECTANGLE_NV); 1341 1361 glDisable(GL_STENCIL_TEST); … … 1535 1555 Q_UNUSED(brush); 1536 1556 #else 1537 bool has_mirrored_repeat = QGLExtensions::glExtensions & QGLExtensions::MirroredRepeat;1557 bool has_mirrored_repeat = QGLExtensions::glExtensions() & QGLExtensions::MirroredRepeat; 1538 1558 Qt::BrushStyle style = brush.style(); 1539 1559 … … 2099 2119 return !(style == Qt::SolidPattern 2100 2120 || (style == Qt::LinearGradientPattern 2101 && (QGLExtensions::glExtensions & QGLExtensions::MirroredRepeat)));2121 && (QGLExtensions::glExtensions() & QGLExtensions::MirroredRepeat))); 2102 2122 } 2103 2123 … … 2421 2441 } else { 2422 2442 d->high_quality_antialiasing = false; 2423 if (QGLExtensions::glExtensions & QGLExtensions::SampleBuffers)2443 if (QGLExtensions::glExtensions() & QGLExtensions::SampleBuffers) 2424 2444 glEnable(GL_MULTISAMPLE); 2425 2445 } 2426 2446 } else { 2427 2447 d->high_quality_antialiasing = false; 2428 if (QGLExtensions::glExtensions & QGLExtensions::SampleBuffers)2448 if (QGLExtensions::glExtensions() & QGLExtensions::SampleBuffers) 2429 2449 glDisable(GL_MULTISAMPLE); 2430 2450 } … … 2436 2456 DEBUG_ONCE_STR("Unable to initialize offscreen, disabling high quality antialiasing"); 2437 2457 d->high_quality_antialiasing = false; 2438 if (QGLExtensions::glExtensions & QGLExtensions::SampleBuffers)2458 if (QGLExtensions::glExtensions() & QGLExtensions::SampleBuffers) 2439 2459 glEnable(GL_MULTISAMPLE); 2440 2460 } … … 2443 2463 d->has_antialiasing = d->high_quality_antialiasing 2444 2464 || ((hints & QPainter::Antialiasing) 2445 && (QGLExtensions::glExtensions & QGLExtensions::SampleBuffers));2465 && (QGLExtensions::glExtensions() & QGLExtensions::SampleBuffers)); 2446 2466 } 2447 2467 … … 4932 4952 glEnableClientState(GL_VERTEX_ARRAY); 4933 4953 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 4934 bool antialias = !(ti.fontEngine->fontDef.styleStrategy & QFont::NoAntialias); 4954 bool antialias = !(ti.fontEngine->fontDef.styleStrategy & QFont::NoAntialias) 4955 && (d->matrix.type() > QTransform::TxTranslate); 4935 4956 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, antialias ? GL_LINEAR : GL_NEAREST); 4936 4957 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, antialias ? GL_LINEAR : GL_NEAREST); -
trunk/src/opengl/qpaintengine_opengl_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/qpixmapdata_gl.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) … … 342 342 if (!m_source.isNull()) { 343 343 if (external_format == GL_RGB) { 344 const QImage tx = m_source.convertToFormat(QImage::Format_RGB888) ;344 const QImage tx = m_source.convertToFormat(QImage::Format_RGB888).mirrored(false, true); 345 345 346 346 glBindTexture(target, m_texture.id); -
trunk/src/opengl/qpixmapdata_gl_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/qpixmapdata_x11gl_egl.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) … … 40 40 ****************************************************************************/ 41 41 42 #include <QDebug> 43 42 44 #include <private/qgl_p.h> 43 45 #include <private/qegl_p.h> 44 46 #include <private/qeglproperties_p.h> 47 48 #if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) 45 49 #include <private/qpaintengineex_opengl2_p.h> 50 #endif 51 52 #ifndef QT_OPENGL_ES_2 53 #include <private/qpaintengine_opengl_p.h> 54 #endif 46 55 47 56 #include "qpixmapdata_x11gl_p.h" … … 188 197 } 189 198 190 static QGL2PaintEngineEx* qt_gl2_engine_for_pixmaps = 0; 199 #if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) 200 Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_pixmap_2_engine) 201 #endif 202 203 #ifndef QT_OPENGL_ES_2 204 Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_pixmap_engine) 205 #endif 206 191 207 192 208 QPaintEngine* QX11GLPixmapData::paintEngine() const … … 203 219 } 204 220 205 if (!qt_gl2_engine_for_pixmaps) 206 qt_gl2_engine_for_pixmaps = new QGL2PaintEngineEx(); 221 QPaintEngine* engine; 222 223 #if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL) 224 engine = qt_gl_pixmap_engine(); 225 #elif defined(QT_OPENGL_ES_2) 226 engine = qt_gl_pixmap_2_engine(); 227 #else 228 if (qt_gl_preferGL2Engine()) 229 engine = qt_gl_pixmap_2_engine(); 230 else 231 engine = qt_gl_pixmap_engine(); 232 #endif 233 234 207 235 208 236 // Support multiple painters on multiple pixmaps simultaniously 209 if ( qt_gl2_engine_for_pixmaps->isActive()) {237 if (engine->isActive()) { 210 238 qWarning("Pixmap paint engine already active"); 211 QPaintEngine* engine = new QGL2PaintEngineEx(); 239 240 #if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL) 241 engine = new QOpenGLPaintEngine; 242 #elif defined(QT_OPENGL_ES_2) 243 engine = new QGL2PaintEngineEx; 244 #else 245 if (qt_gl_preferGL2Engine()) 246 engine = new QGL2PaintEngineEx; 247 else 248 engine = new QOpenGLPaintEngine; 249 #endif 250 212 251 engine->setAutoDestruct(true); 213 252 return engine; 214 253 } 215 254 216 return qt_gl2_engine_for_pixmaps;255 return engine; 217 256 } 218 257 -
trunk/src/opengl/qpixmapdata_x11gl_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/qwindowsurface_gl.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) … … 296 296 { 297 297 Q_ASSERT(window->isTopLevel()); 298 QGLExtensions::init();299 298 d_ptr->pb = 0; 300 299 d_ptr->fbo = 0; … … 521 520 glDisable(GL_SCISSOR_TEST); 522 521 523 if (d_ptr->fbo && (QGLExtensions::glExtensions & QGLExtensions::FramebufferBlit)) {522 if (d_ptr->fbo && (QGLExtensions::glExtensions() & QGLExtensions::FramebufferBlit)) { 524 523 const int h = d_ptr->fbo->height(); 525 524 … … 699 698 700 699 if (d_ptr->destructive_swap_buffers 701 && (QGLExtensions::glExtensions & QGLExtensions::FramebufferObject)700 && (QGLExtensions::glExtensions() & QGLExtensions::FramebufferObject) 702 701 && (d_ptr->fbo || !d_ptr->tried_fbo) 703 702 && qt_gl_preferGL2Engine()) … … 713 712 format.setTextureTarget(target); 714 713 715 if (QGLExtensions::glExtensions & QGLExtensions::FramebufferBlit)714 if (QGLExtensions::glExtensions() & QGLExtensions::FramebufferBlit) 716 715 format.setSamples(8); 717 716 -
trunk/src/opengl/qwindowsurface_gl_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/qwindowsurface_x11gl.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/qwindowsurface_x11gl_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/util/fragmentprograms_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/util/generator.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) … … 288 288 out << "/****************************************************************************\n" 289 289 "**\n" 290 "** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).\n"290 "** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).\n" 291 291 "** All rights reserved.\n" 292 292 "** Contact: Nokia Corporation (qt-info@nokia.com)\n" -
trunk/src/opengl/util/glsl_to_include.sh
r561 r651 2 2 ############################################################################# 3 3 ## 4 ## Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).4 ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 5 5 ## All rights reserved. 6 6 ## Contact: Nokia Corporation (qt-info@nokia.com)
Note:
See TracChangeset
for help on using the changeset viewer.