[SDL_Tizen] Change env name of SDL_timer of vsync 07/86507/2
authorWonsik, Jung <sidein@samsung.com>
Thu, 1 Sep 2016 12:44:01 +0000 (21:44 +0900)
committerWonsik, Jung <sidein@samsung.com>
Fri, 2 Sep 2016 01:30:17 +0000 (10:30 +0900)
Change env name of SDL_timer of vsync and how to use

Change-Id: I68ac2a379c7b8ee66f3490eaa3acab42565994c0

configure.in
src/timer/SDL_timer.c

index 5ad20f9..f70b39b 100644 (file)
@@ -1269,9 +1269,9 @@ CheckTizen()
         if  test x$PKG_CONFIG != xno && \
             test x$video_opengl_egl = xyes && \
             test x$video_opengles_v2 = xyes; then
-            if $PKG_CONFIG --exists wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf; then
-                TIZEN_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf`
-                TIZEN_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf`
+            if $PKG_CONFIG --exists wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf libdrm; then
+                TIZEN_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf libdrm`
+                TIZEN_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf libdrm`
                 video_tizen=yes
             fi
         fi
index ce9c83a..e8dfedc 100755 (executable)
@@ -30,7 +30,6 @@
 
 /* #define DEBUG_TIMERS */
 
-char* timer_type = "NORMAL_TIMER";
 
 typedef struct _SDL_Timer
 {
@@ -120,18 +119,20 @@ SDL_TimerThread(void *_data)
      *  3. Wait until next dispatch time or new timer arrives
      */
     for ( ; ; ) {
-        if(SDL_strcmp(timer_type, "VSYNC_TIMER") == 0) {
+#if defined(__TIZEN__)
+        if(data->drm_fd > -1) {
             if(!data->active)
                 break;
-            if(0 == drmWaitVBlank(data->drm_fd, &(data->vblankInfo))) {
+            if(drmWaitVBlank(data->drm_fd, &(data->vblankInfo)) == 0) {
                 if(data->pending) {
                     current = data->pending;
                     current->callback(current->interval, current->param);
                 }
             }
-
         }
-        else {
+        else
+#endif
+        {
             /* Pending and freelist maintenance */
             SDL_AtomicLock(&data->lock);
             {
@@ -225,11 +226,17 @@ SDL_TimerThread(void *_data)
 int
 SDL_TimerInit(void)
 {
-    timer_type = getenv("SDL_TIMER_TYPE");
-    if(NULL == timer_type)
-    {
-        timer_type = "NORMAL_TIMER";
+#if defined(__TIZEN__)
+    int vsync_timer;
+    if (getenv("SDL_VSYNC_TIMER")) {
+        vsync_timer = 1;
     }
+    else {
+        vsync_timer = 0;
+    }
+
+
+#endif
     SDL_TimerData *data = &SDL_timer_data;
 
     if (!data->active) {
@@ -246,20 +253,26 @@ SDL_TimerInit(void)
         }
 
         data->active = SDL_TRUE;
-
-        if(SDL_strcmp(timer_type, "VSYNC_TIMER") == 0) {
+#if defined(__TIZEN__)
+        if (vsync_timer) {
             const char* DRM_DEVICE = "/dev/dri/card0";
             data->drm_fd = open( DRM_DEVICE, O_RDWR );
 
-            data->vblankInfo.request.type = DRM_VBLANK_NEXTONMISS;
-            data->vblankInfo.request.sequence = 0;
-            data->vblankInfo.request.signal = 0;
+            if (data->drm_fd > -1) {
+                data->vblankInfo.request.type = DRM_VBLANK_NEXTONMISS;
+                data->vblankInfo.request.sequence = 0;
+                data->vblankInfo.request.signal = 0;
 
-            data->vblankInfo.reply.type = DRM_VBLANK_NEXTONMISS;
-            data->vblankInfo.reply.sequence = 0;
-            data->vblankInfo.reply.tval_sec = 0;
-            data->vblankInfo.reply.tval_usec = 0;
+                data->vblankInfo.reply.type = DRM_VBLANK_NEXTONMISS;
+                data->vblankInfo.reply.sequence = 0;
+                data->vblankInfo.reply.tval_sec = 0;
+                data->vblankInfo.reply.tval_usec = 0;
+            }
         }
+        else {
+            data->drm_fd = -1;
+        }
+#endif
         /* !!! FIXME: this is nasty. */
 #if defined(__WIN32__) && !defined(HAVE_LIBC)
 #undef SDL_CreateThread