diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-09-01 01:18:09 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-09-02 01:08:52 +0200 |
commit | e65acd2ebbb85d557068692674f317ff3a038e9b (patch) | |
tree | 5bececa0eb86c78ed1f3efdfc06e9d8d3a605973 | |
parent | ff3321cf775871f34985cd3e1d2c9fa25738037a (diff) |
use SystemWindowData to request a NSOpenGLWindow
Change-Id: Ief50a2fc533846cd61be66b1ea166a992942083b
-rw-r--r-- | include/vcl/sysdata.hxx | 5 | ||||
-rw-r--r-- | vcl/inc/osx/salobj.h | 2 | ||||
-rw-r--r-- | vcl/osx/salinst.cxx | 5 | ||||
-rw-r--r-- | vcl/osx/salobj.cxx | 25 | ||||
-rw-r--r-- | vcl/source/opengl/OpenGLContext.cxx | 3 |
5 files changed, 32 insertions, 8 deletions
diff --git a/include/vcl/sysdata.hxx b/include/vcl/sysdata.hxx index 59aaaa06a9d8..8ac816a1a261 100644 --- a/include/vcl/sysdata.hxx +++ b/include/vcl/sysdata.hxx @@ -51,6 +51,7 @@ struct SystemEnvData HWND hWnd; // the window hwnd #elif defined( MACOSX ) NSView* mpNSView; // the cocoa (NSView *) implementing this object + bool mbOpenGL; // use a OpenGL providing NSView #elif defined( ANDROID ) // Nothing #elif defined( IOS ) @@ -75,6 +76,7 @@ struct SystemEnvData , hWnd(0) #elif defined( MACOSX ) , mpNSView(NULL) + , mbOpenGL(false) #elif defined( ANDROID ) #elif defined( IOS ) #elif defined( UNX ) @@ -174,7 +176,8 @@ struct SystemWindowData { unsigned long nSize; // size in bytes of this structure #if defined( WNT ) // meaningless on Windows -#elif defined( MACOSX ) // meaningless on Mac OS X +#elif defined( MACOSX ) + bool bOpenGL; // create a OpenGL providing NSView // Nothing #elif defined( ANDROID ) // Nothing diff --git a/vcl/inc/osx/salobj.h b/vcl/inc/osx/salobj.h index 8e18a7d6f9f7..5db9d3e2ad1f 100644 --- a/vcl/inc/osx/salobj.h +++ b/vcl/inc/osx/salobj.h @@ -52,7 +52,7 @@ public: void setClippedPosSize(); - AquaSalObject( AquaSalFrame* pFrame ); + AquaSalObject( AquaSalFrame* pFrame, SystemWindowData* pWinData ); virtual ~AquaSalObject(); virtual void ResetClipRegion() SAL_OVERRIDE; diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx index 532fc3876606..93d1e1a53e19 100644 --- a/vcl/osx/salinst.cxx +++ b/vcl/osx/salinst.cxx @@ -757,13 +757,12 @@ void AquaSalInstance::DestroyFrame( SalFrame* pFrame ) delete pFrame; } -SalObject* AquaSalInstance::CreateObject( SalFrame* pParent, SystemWindowData* /* pWindowData */, bool /* bShow */ ) +SalObject* AquaSalInstance::CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool /* bShow */ ) { - // SystemWindowData is meaningless on Mac OS X AquaSalObject *pObject = NULL; if ( pParent ) - pObject = new AquaSalObject( static_cast<AquaSalFrame*>(pParent) ); + pObject = new AquaSalObject( static_cast<AquaSalFrame*>(pParent), pWindowData ); return pObject; } diff --git a/vcl/osx/salobj.cxx b/vcl/osx/salobj.cxx index 7f9df92c739d..7c7ad5d41129 100644 --- a/vcl/osx/salobj.cxx +++ b/vcl/osx/salobj.cxx @@ -22,8 +22,9 @@ #include "osx/saldata.hxx" #include "osx/salobj.h" #include "osx/salframe.h" +#include <AppKit/NSOpenGLView.h> -AquaSalObject::AquaSalObject( AquaSalFrame* pFrame ) : +AquaSalObject::AquaSalObject( AquaSalFrame* pFrame, SystemWindowData* pWindowData ) : mpFrame( pFrame ), mnClipX( -1 ), mnClipY( -1 ), @@ -37,6 +38,7 @@ AquaSalObject::AquaSalObject( AquaSalFrame* pFrame ) : { maSysData.nSize = sizeof( maSysData ); maSysData.mpNSView = NULL; + maSysData.mbOpenGL = pWindowData->bOpenGL; NSRect aInitFrame = { NSZeroPoint, { 20, 20 } }; mpClipView = [[NSClipView alloc] initWithFrame: aInitFrame ]; @@ -45,8 +47,25 @@ AquaSalObject::AquaSalObject( AquaSalFrame* pFrame ) : [mpFrame->getNSView() addSubview: mpClipView]; [mpClipView setHidden: YES]; } - maSysData.mpNSView = [[NSView alloc] initWithFrame: aInitFrame]; - if( maSysData.mpNSView ) + if (pWindowData->bOpenGL) + { + NSOpenGLPixelFormatAttribute aAttributes[] = + { + NSOpenGLPFADoubleBuffer, + NSOpenGLPFAAlphaSize, 8, + NSOpenGLPFAColorSize, 24, + 0 + }; + + NSOpenGLPixelFormat* pixFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:aAttributes]; + maSysData.mpNSView = [[NSOpenGLView alloc] initWithFrame: aInitFrame pixelFormat:pixFormat]; + + } + else + { + maSysData.mpNSView = [[NSView alloc] initWithFrame: aInitFrame]; + } + if( maSysData.mpNSView ) { if( mpClipView ) [mpClipView setDocumentView: maSysData.mpNSView]; diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index b4e7e0d70d4e..75185ada30e0 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -724,6 +724,9 @@ bool OpenGLContext::initWindow() SystemWindowData OpenGLContext::generateWinData(Window* /*pParent*/) { SystemWindowData aWinData; +#if defined(MACOSX) + aWinData.bOpenGL = true; +#endif aWinData.nSize = sizeof(aWinData); return aWinData; } |