diff options
author | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-09-10 13:56:11 (GMT) |
---|---|---|
committer | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-09-10 14:06:58 (GMT) |
commit | a21b661384c31e6c9154a99690b2d134a12b9187 (patch) | |
tree | 6bf37bcdda9f15f16cec716c8fdaca4e85e3f3a7 /src | |
parent | 56ac253d0668c5ea9227a07699c31beb2b8034a1 (diff) | |
download | Qt-a21b661384c31e6c9154a99690b2d134a12b9187.zip Qt-a21b661384c31e6c9154a99690b2d134a12b9187.tar.gz Qt-a21b661384c31e6c9154a99690b2d134a12b9187.tar.bz2 |
Re-order begin() so everything needing a current context has one
It should be up to QGLPaintDevice::beginPaint() to make the correct
context current, so everything needing a current context needs to be
moved after that call.
This patch also modifies QGLPixmapData to use QGLContext::drawTexture
rather than the GL2 PE's drawTexture, which shouldn't be called inside
beginPaint as the paint engine hasn't been fully initialised yet.
Reviewed-by: Eskil
Diffstat (limited to 'src')
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 24 | ||||
-rw-r--r-- | src/opengl/qpixmapdata_gl.cpp | 8 |
2 files changed, 14 insertions, 18 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 2eacef0..4427ee9 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1318,23 +1318,13 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) return false; d->ctx = d->device->context(); - d->ctx->d_ptr->active_engine = this; - d->last_created_state = 0; - QSize sz = d->device->size(); + const QSize sz = d->device->size(); d->width = sz.width(); d->height = sz.height(); + d->last_created_state = 0; d->mode = BrushDrawingMode; - -#if !defined(QT_OPENGL_ES_2) - d->ctx->makeCurrent(); - bool success = qt_resolve_version_2_0_functions(d->ctx); - Q_ASSERT(success); -#endif - - d->shaderManager = new QGLEngineShaderManager(d->ctx); - d->brushTextureDirty = true; d->brushUniformsDirty = true; d->matrixDirty = true; @@ -1346,8 +1336,18 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->needsSync = true; d->use_system_clip = !systemClip().isEmpty(); + // Calling begin paint should make the correct context current. So, any + // code which calls into GL or otherwise needs a current context *must* + // go after beginPaint: d->device->beginPaint(); +#if !defined(QT_OPENGL_ES_2) + bool success = qt_resolve_version_2_0_functions(d->ctx); + Q_ASSERT(success); +#endif + + d->shaderManager = new QGLEngineShaderManager(d->ctx); + if (!d->inRenderText) { glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index fa1b815..0bc46e1 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -157,12 +157,8 @@ void QGLPixmapGLPaintDevice::beginPaint() // uploaded from an image or rendered into before), we need to // copy it from the texture to the render FBO. - // Pass false to tell bind to _not_ copy the FBO into the texture! - GLuint texId = data->bind(false); - - QGL2PaintEngineEx* pe = static_cast<QGL2PaintEngineEx*>(data->paintEngine()); - QRect rect(0, 0, data->width(), data->height()); - pe->drawTexture(QRectF(rect), texId, rect.size(), QRectF(rect)); + // Pass false to bind so it doesn't copy the FBO into the texture! + context()->drawTexture(QPointF(0.0, 0.0), data->bind(false)); } } |