summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoawindow.mm
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-06-07 17:25:22 +0200
committerSamuel Rødal <samuel.rodal@nokia.com>2011-06-10 09:24:56 +0200
commit4a189c188ccd2fb5f8d1d5ddadf06cbd6bc0916f (patch)
tree99bff9f015e869b5521836ea5667590939b22a53 /src/plugins/platforms/cocoa/qcocoawindow.mm
parent4d10e64f2a78e32418a98e1c80c6579ae0779dfc (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/plugins/platforms/cocoa/qcocoawindow.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index a5ad8c87ae..874790a128 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -84,6 +84,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
QCocoaWindow::~QCocoaWindow()
{
+
}
void QCocoaWindow::setGeometry(const QRect &rect)
@@ -92,6 +93,9 @@ void QCocoaWindow::setGeometry(const QRect &rect)
NSRect bounds = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
[[m_nsWindow contentView]setFrameSize:bounds.size];
+
+ if (m_glContext)
+ m_glContext->update();
}
void QCocoaWindow::setVisible(bool visible)
@@ -131,18 +135,41 @@ NSView *QCocoaWindow::contentView() const
return [m_nsWindow contentView];
}
+NSView *QCocoaWindow::windowSurfaceView() const
+{
+ return m_windowSurfaceView;
+}
+
+void QCocoaWindow::windowDidMove()
+{
+ if (m_glContext)
+ m_glContext->update();
+}
+
void QCocoaWindow::windowDidResize()
{
//jlind: XXX This isn't ideal. Eventdispatcher does not run when resizing...
NSRect rect = [[m_nsWindow contentView]frame];
QRect geo(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height);
QWindowSystemInterface::handleGeometryChange(window(),geo);
+
+ if (m_glContext)
+ m_glContext->update();
}
-QPlatformGLContext *QCocoaWindow::glContext() const
+QPlatformGLSurface *QCocoaWindow::createGLSurface() const
+{
+ Q_ASSERT(window()->surfaceType() == QWindow::OpenGLSurface);
+ return new QCocoaGLSurface(window()->glFormat(), window());
+}
+
+void QCocoaWindow::setCurrentContext(QCocoaGLContext *context)
+{
+ m_glContext = context;
+}
+
+QCocoaGLContext *QCocoaWindow::currentContext() const
{
- if (!m_glContext) {
- m_glContext = new QCocoaGLContext(m_windowSurfaceView);
- }
return m_glContext;
}
+