VIGS/qt5: now working on mac os x 70/26070/1
authorStanislav Vorobiov <s.vorobiov@samsung.com>
Fri, 15 Aug 2014 07:35:43 +0000 (11:35 +0400)
committerStanislav Vorobiov <s.vorobiov@samsung.com>
Fri, 15 Aug 2014 07:36:19 +0000 (11:36 +0400)
Change-Id: I64a4453ed29fcfdbde855d981ca4f9fbba00a4b8
Signed-off-by: Stanislav Vorobiov <s.vorobiov@samsung.com>
configure
hw/vigs/vigs_gl_backend_cgl.c
hw/vigs/vigs_qt5.cpp
hw/yagl/yagl_drivers/egl_cgl/yagl_egl_cgl.c
tizen/src/display/qt5.c
tizen/src/display/qt5_supplement.cpp
tizen/src/ns_event.h
tizen/src/ns_event.m
tizen/src/ui/mainwindow.cpp
tizen/src/ui/mainwindow.h
tizen/src/util/check_gl_cgl.c

index b03fa35a9f70042837b4a386334b5b60afea9b39..746df53e92477fcde605efcf570535c634ddec6b 100755 (executable)
--- a/configure
+++ b/configure
@@ -600,6 +600,8 @@ Darwin)
   cocoa="yes"
   audio_drv_list="coreaudio"
   audio_possible_drivers="coreaudio sdl fmod"
+  QT_PATH="/opt/local/Library/Frameworks"
+  CFLAGS="-F$QT_PATH -I$QT_PATH/QtCore.framework/Headers -I$QT_PATH/QtWidgets.framework/Headers -I$QT_PATH/QtGui.framework/Headers -I$QT_PATH/QtGui.framework/Headers/5.3.1/QtGui -I$QT_PATH/QtQML.framework/Headers -I$QT_PATH/QtOpenGL.framework/Headers $CFLAGS"
   LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
   libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
   # Disable attempts to use ObjectiveC features in os/object.h since they
index e31adeac72378145de514e083248b180dc38527e..e2e9830b536210eb4321eb11e0460c39542c1435 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "vigs_gl_backend.h"
 #include "vigs_log.h"
+#include "vigs_qt5.h"
 #include <OpenGL/OpenGL.h>
 #include <dlfcn.h>
 
@@ -61,7 +62,6 @@ static const CGLPixelFormatAttribute pixel_format_legacy_attrs[] =
     kCGLPFAAlphaSize, 8,
     kCGLPFADepthSize, 24,
     kCGLPFAStencilSize, 8,
-    kCGLPFANoRecovery,
     kCGLPFAPBuffer,
     0
 };
@@ -74,7 +74,6 @@ static const CGLPixelFormatAttribute pixel_format_3_2_core_attrs[] =
     kCGLPFAAlphaSize, 8,
     kCGLPFADepthSize, 24,
     kCGLPFAStencilSize, 8,
-    kCGLPFANoRecovery,
     kCGLPFAOpenGLProfile, kCGLOGLPVersion_3_2_Core,
     0
 };
@@ -257,6 +256,7 @@ struct vigs_backend *vigs_gl_backend_create(void *display)
     CGLError error;
     CGLPixelFormatObj pixel_format;
     int n;
+    CGLContextObj qt5_ctx = NULL;
 
     gl_backend_cgl = g_malloc0(sizeof(*gl_backend_cgl));
 
@@ -373,9 +373,16 @@ struct vigs_backend *vigs_gl_backend_create(void *display)
         goto fail2;
     }
 
+    if (vigs_qt5_enabled()) {
+        qt5_ctx = (CGLContextObj)vigs_qt5_gl_context_create(gl_backend_cgl->base.is_gl_2);
+        if (!qt5_ctx) {
+            goto fail2;
+        }
+    }
+
     if (!vigs_gl_backend_cgl_create_context(gl_backend_cgl,
                                             pixel_format,
-                                            NULL,
+                                            qt5_ctx,
                                             &gl_backend_cgl->context)) {
         goto fail3;
     }
index 78c788a097abba8156a3fc7b0c4df6c06048b57f..2df737510f0ef2e56883e17584224f2a85c980cf 100644 (file)
@@ -81,7 +81,12 @@ void *vigs_qt5_gl_context_create(bool is_gl2)
 
     if (!is_gl2) {
         format.setMajorVersion(3);
+#ifdef CONFIG_DARWIN
+        format.setMinorVersion(2);
+        format.setProfile(QSurfaceFormat::CoreProfile);
+#else
         format.setMinorVersion(1);
+#endif
     }
 
     qt5GLContext->setScreen(QGuiApplication::primaryScreen());
index 31bf8d63c2d915211fb5f130a083ac8bfccedcef..8e242556a6897d175a9b5dc02cf2fbb14eab56dc 100644 (file)
@@ -55,7 +55,6 @@ static const CGLPixelFormatAttribute pixel_format_legacy_attrs[] =
     kCGLPFAAlphaSize, 8,
     kCGLPFADepthSize, 24,
     kCGLPFAStencilSize, 8,
-    kCGLPFANoRecovery,
     kCGLPFAPBuffer,
     0
 };
@@ -68,7 +67,6 @@ static const CGLPixelFormatAttribute pixel_format_3_2_core_attrs[] =
     kCGLPFAAlphaSize, 8,
     kCGLPFADepthSize, 24,
     kCGLPFAStencilSize, 8,
-    kCGLPFANoRecovery,
     kCGLPFAOpenGLProfile, kCGLOGLPVersion_3_2_Core,
     0
 };
index aacfb842f88889b61a058e6479aa0d8355baf189..e1ef860f473a13be995f70c5a310cc49255111a2 100644 (file)
@@ -97,9 +97,17 @@ static const DisplayChangeListenerOps dcl_ops = {
     .dpy_cursor_define = qt5_mouse_define,
 };
 
+#ifdef CONFIG_DARWIN
+void ns_run_in_event_loop(void (*func)());
+#endif
+
 void maru_qt5_display_early_init(void)
 {
+#ifdef CONFIG_DARWIN
+    ns_run_in_event_loop(&qt5_early_prepare);
+#else
     qt5_early_prepare();
+#endif
 }
 
 void maru_qt5_display_init(MaruDisplayChangeListener *mdcl, int full_screen)
@@ -112,7 +120,11 @@ void maru_qt5_display_init(MaruDisplayChangeListener *mdcl, int full_screen)
 #endif
 
     // prepare gui
+#ifdef CONFIG_DARWIN
+    ns_run_in_event_loop(&qt5_prepare);
+#else
     qt5_prepare();
+#endif
 
     for (i = 0;; i++) {
         QemuConsole *con = qemu_console_lookup_by_index(i);
index 5942efb54b6d5348c28e5669e69d645f3cc1b837..447dfb80c963c7f9f818b148caf7ebfc7488c15f 100644 (file)
@@ -113,6 +113,8 @@ void qt5_skin_init(void)
     mainwindow->show();
 
     mainwindow->openController(0);
+
+    mainwindow->startSwapper();
 }
 
 void qt5_early_prepare(void)
index 54655c9006d0d4894b084d9ffb00e907cc4644a9..fcc80daedf26b38ba258f6f8c46c288201a5d1d1 100644 (file)
@@ -3,4 +3,6 @@
 
 void ns_event_loop(int* keepRunning);
 
+void ns_run_in_event_loop(void (*func)());
+
 #endif /* _NS_EVENT_H_ */
index 69928df519485edeca3e5952ac9d4d71beb3ccdb..ec6adefd65d3a057a1c497922d8908469d51a714 100644 (file)
@@ -13,3 +13,25 @@ void ns_event_loop(int* keepRunning)
     while (*keepRunning && [theRunLoop runMode:NSDefaultRunLoopMode beforeDate:distantFuture]);
     // return [[NSRunLoop currentRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1]];
 }
+
+@interface Runner : NSObject
+{
+    @public void (*func)();
+}
+- (void)run;
+@end
+
+@implementation Runner
+- (void)run;
+{
+    self->func();
+}
+@end
+
+void ns_run_in_event_loop(void (*func)())
+{
+    Runner *runner = [[Runner alloc] init];
+    runner->func = func;
+    [runner performSelectorOnMainThread:@selector(run) withObject:nil waitUntilDone:YES];
+    [runner release];
+}
index a7ce433122b34c948c63fe4da4850bfa60263e1c..7c0aab877761cc19fabaa441b8d998d7cf017ccf 100644 (file)
@@ -132,7 +132,10 @@ MainWindow::MainWindow(UIInformation *uiInfo, QWidget *parent) :
     connect(swapperThread, &QThread::finished, swapper, &QObject::deleteLater);
 
     swapperThread->start();
+}
 
+void MainWindow::startSwapper()
+{
     QMetaObject::invokeMethod(swapper, "display", Qt::QueuedConnection);
 }
 
index 3966964b261a90ffdb8aeca5f8b62461017f7035..db4620daec9bdad80b6d166d308b7d588fd58396 100644 (file)
@@ -47,6 +47,7 @@ public:
     ControllerWidget *getController();
     void openController(int index);
     void closeController();
+    void startSwapper();
 
     UIInformation *uiInfo;
     QLabel *getLabel();
index 379bab38a94c29467c8ed38a98791ff0f82067f0..13c7573d29e392016b3d639447cdac6906386ff6 100644 (file)
@@ -75,7 +75,6 @@ struct gl_context *check_gl_context_create(struct gl_context *share_ctx,
         kCGLPFAAlphaSize, 8,
         kCGLPFADepthSize, 24,
         kCGLPFAStencilSize, 8,
-        kCGLPFANoRecovery,
         kCGLPFAPBuffer,
         0
     };
@@ -88,7 +87,6 @@ struct gl_context *check_gl_context_create(struct gl_context *share_ctx,
         kCGLPFAAlphaSize, 8,
         kCGLPFADepthSize, 24,
         kCGLPFAStencilSize, 8,
-        kCGLPFANoRecovery,
         kCGLPFAOpenGLProfile, kCGLOGLPVersion_3_2_Core,
         0
     };