Removed QPaintDevice dependency in blitFramebuffer().
authorSamuel Rødal <samuel.rodal@nokia.com>
Tue, 9 Aug 2011 12:45:13 +0000 (14:45 +0200)
committerJørgen Lind <jorgen.lind@nokia.com>
Tue, 9 Aug 2011 14:10:28 +0000 (16:10 +0200)
Change-Id: I7294be5c4447d7e24dda95b822a9ce7b2abbccc4
Reviewed-on: http://codereview.qt.nokia.com/2783
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
src/gui/kernel/qguiglcontext_qpa.cpp
src/gui/kernel/qguiglcontext_qpa.h
src/opengl/qglframebufferobject.cpp

index a11a1c7..2c43bef 100644 (file)
@@ -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);
index db3d6f2..11a7e16 100644 (file)
@@ -81,6 +81,8 @@ public:
     void swapBuffers(QSurface *surface);
     void (*getProcAddress(const QByteArray &procName)) ();
 
+    QSurface *surface() const;
+
     static QGuiGLContext *currentContext();
 
     QPlatformGLContext *handle() const;
index 682c262..8068410 100644 (file)
@@ -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<QWindow *>(surface)->height();
 
     const int sh = source ? source->height() : height;
     const int th = target ? target->height() : height;