OS X: Fix build with QT_NO_OPENGL

Task-number: QTBUG-31151
Change-Id: I7ed8117ae05ba0eebaf85731c7fdd2bb51d6ed04
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
Sergio Martins 2014-02-10 15:11:38 +00:00 committed by Morten Johan Sørvig
parent 90a68926f3
commit a12ba31616
11 changed files with 58 additions and 6 deletions

View File

@ -14,7 +14,6 @@ OBJECTIVE_SOURCES += main.mm \
qnsviewaccessibility.mm \
qcocoaautoreleasepool.mm \
qnswindowdelegate.mm \
qcocoaglcontext.mm \
qcocoanativeinterface.mm \
qcocoaeventdispatcher.mm \
qcocoaapplicationdelegate.mm \
@ -51,7 +50,6 @@ HEADERS += qcocoaintegration.h \
qnsview.h \
qcocoaautoreleasepool.h \
qnswindowdelegate.h \
qcocoaglcontext.h \
qcocoanativeinterface.h \
qcocoaeventdispatcher.h \
qcocoaapplicationdelegate.h \
@ -80,6 +78,12 @@ HEADERS += qcocoaintegration.h \
messages.h \
qcocoamimetypes.h
contains(QT_CONFIG, opengl.*) {
OBJECTIVE_SOURCES += qcocoaglcontext.mm
HEADERS += qcocoaglcontext.h
}
RESOURCES += qcocoaresources.qrc
LIBS += -framework Cocoa -framework Carbon -framework IOKit -lcups

View File

@ -59,7 +59,9 @@ public:
QPaintDevice *paintDevice();
void flush(QWindow *widget, const QRegion &region, const QPoint &offset);
#ifndef QT_NO_OPENGL
QImage toImage() const Q_DECL_OVERRIDE;
#endif
void resize (const QSize &size, const QRegion &);
bool scroll(const QRegion &area, int dx, int dy);
CGImageRef getBackingStoreCGImage();

View File

@ -96,10 +96,12 @@ void QCocoaBackingStore::flush(QWindow *win, const QRegion &region, const QPoint
}
}
#ifndef QT_NO_OPENGL
QImage QCocoaBackingStore::toImage() const
{
return m_qImage;
}
#endif
void QCocoaBackingStore::resize(const QSize &size, const QRegion &)
{

View File

@ -113,7 +113,9 @@ public:
bool hasCapability(QPlatformIntegration::Capability cap) const;
QPlatformWindow *createPlatformWindow(QWindow *window) const;
#ifndef QT_NO_OPENGL
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const;
#endif
QPlatformBackingStore *createPlatformBackingStore(QWindow *widget) const;
QAbstractEventDispatcher *createEventDispatcher() const;

View File

@ -401,9 +401,11 @@ bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) cons
{
switch (cap) {
case ThreadedPixmaps:
#ifndef QT_NO_OPENGL
case OpenGL:
case ThreadedOpenGL:
case BufferQueueingOpenGL:
#endif
case WindowMasks:
case MultipleWindows:
case ForeignWindows:
@ -420,6 +422,7 @@ QPlatformWindow *QCocoaIntegration::createPlatformWindow(QWindow *window) const
return new QCocoaWindow(window);
}
#ifndef QT_NO_OPENGL
QPlatformOpenGLContext *QCocoaIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
QCocoaGLContext *glContext = new QCocoaGLContext(context->format(),
@ -428,6 +431,7 @@ QPlatformOpenGLContext *QCocoaIntegration::createPlatformOpenGLContext(QOpenGLCo
context->setNativeHandle(glContext->nativeHandle());
return glContext;
}
#endif
QPlatformBackingStore *QCocoaIntegration::createPlatformBackingStore(QWindow *window) const
{

View File

@ -61,15 +61,19 @@ class QCocoaNativeInterface : public QPlatformNativeInterface
public:
QCocoaNativeInterface();
#ifndef QT_NO_OPENGL
void *nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context);
#endif
void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window);
NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE;
Q_INVOKABLE void beep();
#ifndef QT_NO_OPENGL
static void *cglContextForContext(QOpenGLContext *context);
static void *nsOpenGLContextForContext(QOpenGLContext* context);
#endif
public Q_SLOTS:
void onAppFocusWindowChanged(QWindow *window);

View File

@ -40,7 +40,6 @@
****************************************************************************/
#include "qcocoanativeinterface.h"
#include "qcocoaglcontext.h"
#include "qcocoawindow.h"
#include "qcocoamenu.h"
#include "qcocoamenubar.h"
@ -53,8 +52,11 @@
#include <qpixmap.h>
#include <qpa/qplatformwindow.h>
#include "qsurfaceformat.h"
#ifndef QT_NO_OPENGL
#include <qpa/qplatformopenglcontext.h>
#include "qopenglcontext.h"
#include "qcocoaglcontext.h"
#endif
#include "qguiapplication.h"
#include <qdebug.h>
@ -72,6 +74,7 @@ QCocoaNativeInterface::QCocoaNativeInterface()
{
}
#ifndef QT_NO_OPENGL
void *QCocoaNativeInterface::nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context)
{
if (!context)
@ -83,16 +86,19 @@ void *QCocoaNativeInterface::nativeResourceForContext(const QByteArray &resource
return 0;
}
#endif
void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window)
{
if (!window->handle())
return 0;
if (resourceString == "nsopenglcontext") {
return static_cast<QCocoaWindow *>(window->handle())->currentContext()->nsOpenGLContext();
} else if (resourceString == "nsview") {
if (resourceString == "nsview") {
return static_cast<QCocoaWindow *>(window->handle())->m_contentView;
#ifndef QT_NO_OPENGL
} else if (resourceString == "nsopenglcontext") {
return static_cast<QCocoaWindow *>(window->handle())->currentContext()->nsOpenGLContext();
#endif
} else if (resourceString == "nswindow") {
return static_cast<QCocoaWindow *>(window->handle())->m_nsWindow;
}
@ -198,6 +204,7 @@ void QCocoaNativeInterface::onAppFocusWindowChanged(QWindow *window)
QCocoaMenuBar::updateMenuBarImmediately();
}
#ifndef QT_NO_OPENGL
void *QCocoaNativeInterface::cglContextForContext(QOpenGLContext* context)
{
NSOpenGLContext *nsOpenGLContext = static_cast<NSOpenGLContext*>(nsOpenGLContextForContext(context));
@ -216,6 +223,7 @@ void *QCocoaNativeInterface::nsOpenGLContextForContext(QOpenGLContext* context)
}
return 0;
}
#endif
void QCocoaNativeInterface::addToMimeList(void *macPasteboardMime)
{

View File

@ -47,7 +47,9 @@
#include <qpa/qplatformwindow.h>
#include <QRect>
#ifndef QT_NO_OPENGL
#include "qcocoaglcontext.h"
#endif
#include "qnsview.h"
QT_FORWARD_DECLARE_CLASS(QCocoaWindow)
@ -194,8 +196,10 @@ public:
void setWindowShadow(Qt::WindowFlags flags);
void setWindowZoomButton(Qt::WindowFlags flags);
#ifndef QT_NO_OPENGL
void setCurrentContext(QCocoaGLContext *context);
QCocoaGLContext *currentContext() const;
#endif
bool setWindowModified(bool modified) Q_DECL_OVERRIDE;
@ -263,7 +267,9 @@ public: // for QNSView
bool m_windowUnderMouse;
bool m_inConstructor;
#ifndef QT_NO_OPENGL
QCocoaGLContext *m_glContext;
#endif
QCocoaMenuBar *m_menubar;
NSCursor *m_windowCursor;

View File

@ -43,7 +43,9 @@
#include "qnswindowdelegate.h"
#include "qcocoaautoreleasepool.h"
#include "qcocoaeventdispatcher.h"
#ifndef QT_NO_OPENGL
#include "qcocoaglcontext.h"
#endif
#include "qcocoahelpers.h"
#include "qcocoanativeinterface.h"
#include "qnsview.h"
@ -366,7 +368,9 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
, m_windowModality(Qt::NonModal)
, m_windowUnderMouse(false)
, m_inConstructor(true)
#ifndef QT_NO_OPENGL
, m_glContext(0)
#endif
, m_menubar(0)
, m_windowCursor(0)
, m_hasModalSession(false)
@ -703,8 +707,10 @@ void QCocoaWindow::setVisible(bool visible)
[m_contentView setHidden:NO];
} else {
// qDebug() << "close" << this;
#ifndef QT_NO_OPENGL
if (m_glContext)
m_glContext->windowWasHidden();
#endif
QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher());
QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = 0;
if (cocoaEventDispatcher)
@ -1213,6 +1219,7 @@ bool QCocoaWindow::windowIsPopupType(Qt::WindowType type) const
return ((type & Qt::Popup) == Qt::Popup);
}
#ifndef QT_NO_OPENGL
void QCocoaWindow::setCurrentContext(QCocoaGLContext *context)
{
m_glContext = context;
@ -1222,6 +1229,7 @@ QCocoaGLContext *QCocoaWindow::currentContext() const
{
return m_glContext;
}
#endif
void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
{

View File

@ -69,14 +69,18 @@ QT_END_NAMESPACE
bool m_sendUpAsRightButton;
Qt::KeyboardModifiers currentWheelModifiers;
bool m_subscribesForGlobalFrameNotifications;
#ifndef QT_NO_OPENGL
QCocoaGLContext *m_glContext;
bool m_shouldSetGLContextinDrawRect;
#endif
NSString *m_inputSource;
}
- (id)init;
- (id)initWithQWindow:(QWindow *)window platformWindow:(QCocoaWindow *) platformWindow;
#ifndef QT_NO_OPENGL
- (void)setQCocoaGLContext:(QCocoaGLContext *)context;
#endif
- (void)flushBackingStore:(QCocoaBackingStore *)backingStore region:(const QRegion &)region offset:(QPoint)offset;
- (void)setMaskRegion:(const QRegion *)region;
- (void)invalidateWindowShadowIfNeeded;

View File

@ -57,7 +57,9 @@
#include <QtCore/QDebug>
#include <private/qguiapplication_p.h>
#include "qcocoabackingstore.h"
#ifndef QT_NO_OPENGL
#include "qcocoaglcontext.h"
#endif
#include "qcocoaintegration.h"
#ifdef QT_COCOA_ENABLE_ACCESSIBILITY_INSPECTOR
@ -95,8 +97,10 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
m_buttons = Qt::NoButton;
m_sendKeyEvent = false;
m_subscribesForGlobalFrameNotifications = false;
#ifndef QT_NO_OPENGL
m_glContext = 0;
m_shouldSetGLContextinDrawRect = false;
#endif
currentCustomDragTypes = 0;
m_sendUpAsRightButton = false;
m_inputSource = 0;
@ -160,6 +164,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
return self;
}
#ifndef QT_NO_OPENGL
- (void) setQCocoaGLContext:(QCocoaGLContext *)context
{
m_glContext = context;
@ -181,6 +186,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
object:self];
}
}
#endif
- (void) globalFrameChanged:(NSNotification*)notification
{
@ -466,10 +472,12 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
- (void) drawRect:(NSRect)dirtyRect
{
#ifndef QT_NO_OPENGL
if (m_glContext && m_shouldSetGLContextinDrawRect) {
[m_glContext->nsOpenGLContext() setView:self];
m_shouldSetGLContextinDrawRect = false;
}
#endif
if (m_platformWindow->m_drawContentBorderGradient)
NSDrawWindowBackground(dirtyRect);