diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-06-07 17:25:22 +0200 |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-06-10 09:24:56 +0200 |
commit | 4a189c188ccd2fb5f8d1d5ddadf06cbd6bc0916f (patch) | |
tree | 99bff9f015e869b5521836ea5667590939b22a53 /src/gui/kernel/qwindow.cpp | |
parent | 4d10e64f2a78e32418a98e1c80c6579ae0779dfc (diff) |
QWindowContext / QWindowFormat refactor.
To enable having a single GL context used for multiple drawables we need
to de-couple the context class a bit more from the window class in the
plugin API. Now contexts are created stand-alone based on a GL format
and a share context, and when calling makeCurrent() a desired surface
is specified. This maps well to GLX, EGL, Cocoa, AGL, and WGL, which all
support this use case.
QWindowContext is renamed to QGuiGLContext, and QWindowFormat is renamed
to QGuiGLFormat. We have the ability to introduce a pbuffer or similar
other offscreen GL drawable abstraction in the future.
Diffstat (limited to 'src/gui/kernel/qwindow.cpp')
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 3d227f49ca..97e74c5652 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -42,9 +42,9 @@ #include "qwindow.h" #include "qplatformwindow_qpa.h" -#include "qwindowformat_qpa.h" +#include "qguiglformat_qpa.h" #include "qplatformglcontext_qpa.h" -#include "qwindowcontext_qpa.h" +#include "qguiglcontext_qpa.h" #include "qwindow_p.h" #include "qguiapplication_p.h" @@ -177,21 +177,26 @@ void QWindow::setWindowModality(Qt::WindowModality windowModality) d->modality = windowModality; } -void QWindow::setWindowFormat(const QWindowFormat &format) +void QWindow::setGLFormat(const QGuiGLFormat &format) { Q_D(QWindow); d->requestedFormat = format; } -QWindowFormat QWindow::requestedWindowFormat() const +QGuiGLFormat QWindow::glFormat() const { Q_D(const QWindow); + if (d->glSurface) + return d->glSurface->format(); return d->requestedFormat; } -QWindowFormat QWindow::actualWindowFormat() const +QPlatformGLSurface *QWindow::glSurface() const { - return glContext()->handle()->windowFormat(); + Q_D(const QWindow); + if (d->platformWindow && !d->glSurface) + const_cast<QPlatformGLSurface *&>(d->glSurface) = d->platformWindow->createGLSurface(); + return d->glSurface; } void QWindow::setSurfaceType(SurfaceType type) @@ -397,23 +402,12 @@ void QWindow::setWindowIcon(const QImage &icon) const qDebug() << "unimplemented:" << __FILE__ << __LINE__; } -QWindowContext * QWindow::glContext() const -{ - Q_D(const QWindow); - if (d->platformWindow && !d->glContext) - const_cast<QWindowPrivate *>(d)->glContext = new QWindowContext(const_cast<QWindow *>(this)); - return d->glContext; -} - void QWindow::destroy() { Q_D(QWindow); - if (d->glContext) { - d->glContext->deleteQGLContext(); - } - delete d->glContext; - d->glContext = 0; + delete d->glSurface; delete d->platformWindow; + d->glSurface = 0; d->platformWindow = 0; } |