diff options
author | Morten Sorvig <morten.sorvig@nokia.com> | 2011-05-20 10:47:59 +0200 |
---|---|---|
committer | Morten Sorvig <morten.sorvig@nokia.com> | 2011-05-20 10:58:37 +0200 |
commit | e285501267bc28c226e8f3a455f28b5090e934aa (patch) | |
tree | 3342b1a1b0eb8111f67cb7ec773683ca0225fb68 /src | |
parent | ea7277690d9f4a7c4e10f3d3b7a2bef46d6878c2 (diff) |
Add QCocoaNativeInterface.
Supports getting the NSOpenGLContext for now.
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/cocoa/cocoa.pro | 10 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaglcontext.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaglcontext.mm | 5 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaintegration.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaintegration.mm | 7 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoanativeinterface.h | 55 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoanativeinterface.mm | 59 |
7 files changed, 135 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 87846a9092..5d751631a9 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -10,7 +10,9 @@ OBJECTIVE_SOURCES = main.mm \ qcocoaeventloopintegration.mm \ qcocoaautoreleasepool.mm \ qnswindowdelegate.mm \ - qcocoaglcontext.mm + qcocoaglcontext.mm \ + qcocoanativeinterface.mm + OBJECTIVE_HEADERS = qcocoaintegration.h \ qcocoawindowsurface.h \ @@ -19,7 +21,10 @@ OBJECTIVE_HEADERS = qcocoaintegration.h \ qcocoaeventloopintegration.h \ qcocoaautoreleasepool.h \ qnswindowdelegate.h \ - qcocoaglcontext.h + qcocoaglcontext.h \ + qcocoanativeinterface.h + +DEFINES += QT_BUILD_COCOA_LIB #add libz for freetype. LIBS += -lz @@ -30,4 +35,3 @@ QT += core-private gui-private include(../fontdatabases/basicunix/basicunix.pri) target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target - diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h index b9a84a1606..4d330a4294 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.h +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h @@ -18,6 +18,7 @@ public: void* getProcAddress(const QString& procName); QWindowFormat windowFormat() const; static NSOpenGLPixelFormat *createNSOpenGLPixelFormat(); + NSOpenGLContext *nsOpenGLContext() const; private: NSOpenGLView *m_glView; }; diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index 505be4a9de..3a87537e64 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -76,3 +76,8 @@ NSOpenGLPixelFormat *QCocoaGLContext::createNSOpenGLPixelFormat() return pixelFormat; } +NSOpenGLContext *QCocoaGLContext::nsOpenGLContext() const +{ + return [m_glView openGLContext]; +} + diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index 21bdf6c045..1d961ed1b0 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -85,7 +85,7 @@ public: QPlatformFontDatabase *fontDatabase() const; QPlatformEventLoopIntegration *createEventLoopIntegration() const; - + QPlatformNativeInterface *nativeInterface() const; private: QList<QPlatformScreen *> mScreens; QPlatformFontDatabase *mFontDb; diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index ab8763ad4a..31815d8a65 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -44,6 +44,7 @@ #include "qcocoawindow.h" #include "qcocoawindowsurface.h" #include "qcocoaeventloopintegration.h" +#include "qcocoanativeinterface.h" #include "qbasicunixfontdatabase.h" @@ -127,4 +128,10 @@ QPlatformEventLoopIntegration *QCocoaIntegration::createEventLoopIntegration() c { return new QCocoaEventLoopIntegration(); } + +QPlatformNativeInterface *QCocoaIntegration::nativeInterface() const +{ + return new QCocoaNativeInterface(); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h new file mode 100644 index 0000000000..78f5ce0f94 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOCOANATIVEINTERFACE_H +#define QCOCOANATIVEINTERFACE_H + +#include <QtGui/QPlatformNativeInterface> + +class QWidget; + +class QCocoaNativeInterface : public QPlatformNativeInterface +{ +public: + void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window); +}; + +#endif // QCOCOANATIVEINTERFACE_H diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm new file mode 100644 index 0000000000..859e04ccc7 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcocoanativeinterface.h" +#include "qcocoaglcontext.h" +#include <qbytearray.h> +#include <qwindow.h> +#include "qplatformwindow_qpa.h" +#include "qwindowformat_qpa.h" +#include "qplatformglcontext_qpa.h" +#include "qwindowcontext_qpa.h" +#include <qdebug.h> + +void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) +{ + if (resourceString == "nsopenglcontext") { + QPlatformGLContext *platformContext = window->glContext()->handle(); + return static_cast<QCocoaGLContext *>(platformContext)->nsOpenGLContext(); + } + return 0; +} |