From 367adc10de1d6c1f02546a543ddfd50471a1b03d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 5 Sep 2018 11:45:46 +0200 Subject: macOS: Rename QCocoaGLContext::setActiveWindow to setDrawable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0be5125b434418c005f45f05c54b22f0418b46e4 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaglcontext.h | 2 +- src/plugins/platforms/cocoa/qcocoaglcontext.mm | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h index 0e5934bc23..9d827289f7 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.h +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h @@ -74,7 +74,7 @@ public: private: static NSOpenGLPixelFormat *pixelFormatForSurfaceFormat(const QSurfaceFormat &format); - bool setActiveWindow(QWindow *window); + bool setDrawable(QPlatformSurface *surface); void updateSurfaceFormat(); NSOpenGLContext *m_context = nil; diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index c23636a1a0..2c8885e419 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -336,11 +336,8 @@ bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface) return true; } - QWindow *window = static_cast(surface)->window(); - if (!setActiveWindow(window)) { - qCDebug(lcQpaOpenGLContext) << "Failed to activate window, skipping makeCurrent"; + if (!setDrawable(surface)) return false; - } [m_context makeCurrentContext]; @@ -365,8 +362,15 @@ bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface) return true; } -bool QCocoaGLContext::setActiveWindow(QWindow *window) +/*! + Sets the drawable object of the NSOpenGLContext, which is the + frame buffer that is the target of OpenGL drawing operations. +*/ +bool QCocoaGLContext::setDrawable(QPlatformSurface *surface) { + Q_ASSERT(surface && surface->surface()->surfaceClass() == QSurface::Window); + QWindow *window = static_cast(surface)->window(); + if (window == m_currentWindow.data()) return true; @@ -375,11 +379,11 @@ bool QCocoaGLContext::setActiveWindow(QWindow *window) NSView *view = cocoaWindow->view(); if ((m_context.view = view) != view) { - qCDebug(lcQpaOpenGLContext) << "Associating" << view << "with" << m_context << "failed"; + qCInfo(lcQpaOpenGLContext) << "Failed to set" << view << "as drawable for" << m_context; return false; } - qCDebug(lcQpaOpenGLContext) << m_context << "now associated with" << m_context.view; + qCInfo(lcQpaOpenGLContext) << "Set drawable for" << m_context << "to" << m_context.view; if (m_currentWindow && m_currentWindow.data()->handle()) static_cast(m_currentWindow.data()->handle())->setCurrentContext(0); @@ -408,9 +412,9 @@ void QCocoaGLContext::swapBuffers(QPlatformSurface *surface) if (surface->surface()->surfaceClass() == QSurface::Offscreen) return; // Nothing to do - QWindow *window = static_cast(surface)->window(); - if (!setActiveWindow(window)) { - qCWarning(lcQpaOpenGLContext) << "Failed to activate window, skipping swapBuffers"; + if (!setDrawable(surface)) { + qCWarning(lcQpaOpenGLContext) << "Can't flush" << m_context + << "without" << surface << "as drawable"; return; } @@ -435,7 +439,7 @@ void QCocoaGLContext::windowWasHidden() { // If the window is hidden, we need to unset the m_currentWindow // variable so that succeeding makeCurrent's will not abort prematurely - // because of the optimization in setActiveWindow. + // because of the optimization in setDrawable. // Doing a full doneCurrent here is not preferable, because the GL context // might be rendering in a different thread at this time. m_currentWindow.clear(); -- cgit v1.2.3