From: Stanislav Vorobiov Date: Fri, 15 Aug 2014 07:35:43 +0000 (+0400) Subject: VIGS/qt5: now working on mac os x X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=59dda6278d9768c734cc91ffb3bd104dc60d6aa9;p=sdk%2Femulator%2Fqemu.git VIGS/qt5: now working on mac os x Change-Id: I64a4453ed29fcfdbde855d981ca4f9fbba00a4b8 Signed-off-by: Stanislav Vorobiov --- diff --git a/configure b/configure index b03fa35a9f..746df53e92 100755 --- 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 diff --git a/hw/vigs/vigs_gl_backend_cgl.c b/hw/vigs/vigs_gl_backend_cgl.c index e31adeac72..e2e9830b53 100644 --- a/hw/vigs/vigs_gl_backend_cgl.c +++ b/hw/vigs/vigs_gl_backend_cgl.c @@ -29,6 +29,7 @@ #include "vigs_gl_backend.h" #include "vigs_log.h" +#include "vigs_qt5.h" #include #include @@ -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; } diff --git a/hw/vigs/vigs_qt5.cpp b/hw/vigs/vigs_qt5.cpp index 78c788a097..2df737510f 100644 --- a/hw/vigs/vigs_qt5.cpp +++ b/hw/vigs/vigs_qt5.cpp @@ -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()); diff --git a/hw/yagl/yagl_drivers/egl_cgl/yagl_egl_cgl.c b/hw/yagl/yagl_drivers/egl_cgl/yagl_egl_cgl.c index 31bf8d63c2..8e242556a6 100644 --- a/hw/yagl/yagl_drivers/egl_cgl/yagl_egl_cgl.c +++ b/hw/yagl/yagl_drivers/egl_cgl/yagl_egl_cgl.c @@ -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 }; diff --git a/tizen/src/display/qt5.c b/tizen/src/display/qt5.c index aacfb842f8..e1ef860f47 100644 --- a/tizen/src/display/qt5.c +++ b/tizen/src/display/qt5.c @@ -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); diff --git a/tizen/src/display/qt5_supplement.cpp b/tizen/src/display/qt5_supplement.cpp index 5942efb54b..447dfb80c9 100644 --- a/tizen/src/display/qt5_supplement.cpp +++ b/tizen/src/display/qt5_supplement.cpp @@ -113,6 +113,8 @@ void qt5_skin_init(void) mainwindow->show(); mainwindow->openController(0); + + mainwindow->startSwapper(); } void qt5_early_prepare(void) diff --git a/tizen/src/ns_event.h b/tizen/src/ns_event.h index 54655c9006..fcc80daedf 100644 --- a/tizen/src/ns_event.h +++ b/tizen/src/ns_event.h @@ -3,4 +3,6 @@ void ns_event_loop(int* keepRunning); +void ns_run_in_event_loop(void (*func)()); + #endif /* _NS_EVENT_H_ */ diff --git a/tizen/src/ns_event.m b/tizen/src/ns_event.m index 69928df519..ec6adefd65 100644 --- a/tizen/src/ns_event.m +++ b/tizen/src/ns_event.m @@ -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]; +} diff --git a/tizen/src/ui/mainwindow.cpp b/tizen/src/ui/mainwindow.cpp index a7ce433122..7c0aab8777 100644 --- a/tizen/src/ui/mainwindow.cpp +++ b/tizen/src/ui/mainwindow.cpp @@ -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); } diff --git a/tizen/src/ui/mainwindow.h b/tizen/src/ui/mainwindow.h index 3966964b26..db4620daec 100644 --- a/tizen/src/ui/mainwindow.h +++ b/tizen/src/ui/mainwindow.h @@ -47,6 +47,7 @@ public: ControllerWidget *getController(); void openController(int index); void closeController(); + void startSwapper(); UIInformation *uiInfo; QLabel *getLabel(); diff --git a/tizen/src/util/check_gl_cgl.c b/tizen/src/util/check_gl_cgl.c index 379bab38a9..13c7573d29 100644 --- a/tizen/src/util/check_gl_cgl.c +++ b/tizen/src/util/check_gl_cgl.c @@ -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 };