Cocoa: Make the hellowindow opengl example work.

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>
This commit is contained in:
Morten Sorvig 2011-08-30 10:41:54 +02:00 committed by Samuel Rødal
parent 42f2da5e6b
commit d610fbc13e
4 changed files with 5 additions and 20 deletions

View 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

View 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];
}

View 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;

View 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)