From 44ad7a7f2bbec33e358d1fcfc444d762e59ffe7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 9 Aug 2011 14:45:13 +0200 Subject: Removed QPaintDevice dependency in blitFramebuffer(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7294be5c4447d7e24dda95b822a9ce7b2abbccc4 Reviewed-on: http://codereview.qt.nokia.com/2783 Reviewed-by: Qt Sanity Bot Reviewed-by: Jørgen Lind --- src/gui/kernel/qguiglcontext_qpa.cpp | 15 +++++++++++++++ src/gui/kernel/qguiglcontext_qpa.h | 2 ++ src/opengl/qglframebufferobject.cpp | 6 ++++-- 3 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qguiglcontext_qpa.cpp b/src/gui/kernel/qguiglcontext_qpa.cpp index a11a1c77de..2c43befbc9 100644 --- a/src/gui/kernel/qguiglcontext_qpa.cpp +++ b/src/gui/kernel/qguiglcontext_qpa.cpp @@ -71,6 +71,7 @@ public: , platformGLContext(0) , shareContext(0) , screen(0) + , surface(0) { } @@ -86,6 +87,7 @@ public: QPlatformGLContext *platformGLContext; QGuiGLContext *shareContext; QScreen *screen; + QSurface *surface; static void setCurrentContext(QGuiGLContext *context); }; @@ -229,6 +231,7 @@ bool QGuiGLContext::makeCurrent(QSurface *surface) if (d->platformGLContext->makeCurrent(surface->surfaceHandle())) { QGuiGLContextPrivate::setCurrentContext(this); + d->surface = surface; return true; } @@ -246,8 +249,20 @@ void QGuiGLContext::doneCurrent() d->platformGLContext->doneCurrent(); QGuiGLContextPrivate::setCurrentContext(0); + + d->surface = 0; +} + +/*! + Returns the surface the context is current for. +*/ +QSurface *QGuiGLContext::surface() const +{ + Q_D(const QGuiGLContext); + return d->surface; } + void QGuiGLContext::swapBuffers(QSurface *surface) { Q_D(QGuiGLContext); diff --git a/src/gui/kernel/qguiglcontext_qpa.h b/src/gui/kernel/qguiglcontext_qpa.h index db3d6f29e6..11a7e16a82 100644 --- a/src/gui/kernel/qguiglcontext_qpa.h +++ b/src/gui/kernel/qguiglcontext_qpa.h @@ -81,6 +81,8 @@ public: void swapBuffers(QSurface *surface); void (*getProcAddress(const QByteArray &procName)) (); + QSurface *surface() const; + static QGuiGLContext *currentContext(); QPlatformGLContext *handle() const; diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 682c26255d..8068410dc1 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -1370,10 +1370,12 @@ void QGLFramebufferObject::blitFramebuffer(QGLFramebufferObject *target, const Q return; const QGLContext *ctx = QGLContext::currentContext(); - if (!ctx) + if (!ctx || !ctx->contextHandle()) return; - const int height = ctx->device()->height(); + QSurface *surface = ctx->contextHandle()->surface(); + + const int height = static_cast(surface)->height(); const int sh = source ? source->height() : height; const int th = target ? target->height() : height; -- cgit v1.2.3