Cocoa: Make the hellowindow opengl example work.
authorMorten Sorvig <morten.sorvig@nokia.com>
Tue, 30 Aug 2011 08:41:54 +0000 (10:41 +0200)
committerSamuel Rødal <samuel.rodal@nokia.com>
Tue, 30 Aug 2011 10:12:45 +0000 (12:12 +0200)
You're not supposed to use NSOpenGLView and
NSOpenGLContext at the same time - it's one or
the other. Qmlscene worked because it was hitting
the raster path that doesn't have a NSOpenGLView.

Remove the NSOpenGLView path and m_windowSurfaceView.

Change-Id: I10358851a94cd1780a312af09bbb7cf5db8f984f
Reviewed-on: http://codereview.qt.nokia.com/3862
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/plugins/platforms/cocoa/qcocoabackingstore.mm
src/plugins/platforms/cocoa/qcocoaglcontext.mm
src/plugins/platforms/cocoa/qcocoawindow.h
src/plugins/platforms/cocoa/qcocoawindow.mm

index 1a25608..5a59fb5 100644 (file)
@@ -84,7 +84,7 @@ void QCocoaBackingStore::flush(QWindow *widget, const QRegion &region, const QPo
     QRect geo = region.boundingRect();
 
     NSRect rect = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height());
-    [m_cocoaWindow->m_windowSurfaceView displayRect:rect];
+    [m_cocoaWindow->m_contentView displayRect:rect];
 }
 
 void QCocoaBackingStore::resize(const QSize &size, const QRegion &)
@@ -92,7 +92,7 @@ void QCocoaBackingStore::resize(const QSize &size, const QRegion &)
     delete m_image;
     m_image = new QImage(size,QImage::Format_ARGB32_Premultiplied);
     NSSize newSize = NSMakeSize(size.width(),size.height());
-    [static_cast<QNSView *>(m_cocoaWindow->m_windowSurfaceView) setImage:m_image];
+    [static_cast<QNSView *>(m_cocoaWindow->m_contentView) setImage:m_image];
 }
 
 QT_END_NAMESPACE
index fabed4e..8b07315 100644 (file)
@@ -39,6 +39,8 @@ void QCocoaGLContext::swapBuffers(QPlatformSurface *surface)
 
 bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface)
 {
+    QCocoaAutoReleasePool pool;
+
     QWindow *window = static_cast<QCocoaWindow *>(surface)->window();
     setActiveWindow(window);
 
@@ -61,7 +63,7 @@ void QCocoaGLContext::setActiveWindow(QWindow *window)
     QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
     cocoaWindow->setCurrentContext(this);
 
-    NSView *view = cocoaWindow->windowSurfaceView();
+    NSView *view = cocoaWindow->contentView();
     [m_context setView:view];
 }
 
index 035a09b..ce79d39 100644 (file)
@@ -72,7 +72,6 @@ public:
 
     WId winId() const;
     NSView *contentView() const;
-    NSView *windowSurfaceView() const;
 
     void windowDidMove();
     void windowDidResize();
@@ -92,7 +91,6 @@ private:
     friend class QCocoaBackingStore;
     QNSWindow *m_nsWindow;
     QNSView *m_contentView;
-    NSView *m_windowSurfaceView;
     quint32 m_windowAttributes;
     quint32 m_windowClass;
     QCocoaGLContext *m_glContext;
index b7d7bd8..78785a8 100644 (file)
@@ -90,16 +90,6 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
 
     m_contentView = [[QNSView alloc] initWithQWindow:tlw];
 
-    if (tlw->surfaceType() == QWindow::OpenGLSurface) {
-        NSRect glFrame = globalGeometry(window()->geometry());
-        m_windowSurfaceView = [[NSOpenGLView alloc] initWithFrame : glFrame pixelFormat : QCocoaGLContext::createNSOpenGLPixelFormat() ];
-        [m_contentView setAutoresizesSubviews : YES];
-        [m_windowSurfaceView setAutoresizingMask : (NSViewWidthSizable | NSViewHeightSizable)];
-        [m_contentView addSubview : m_windowSurfaceView];
-    } else {
-        m_windowSurfaceView = m_contentView;
-    }
-
     setGeometry(tlw->geometry());
 
     [m_nsWindow setContentView:m_contentView];
@@ -166,11 +156,6 @@ NSView *QCocoaWindow::contentView() const
     return [m_nsWindow contentView];
 }
 
-NSView *QCocoaWindow::windowSurfaceView() const
-{
-    return m_windowSurfaceView;
-}
-
 void QCocoaWindow::windowDidMove()
 {
     if (m_glContext)