[SDL] Add sdl_tizen core for tizen app core 44/73044/1
authorWonsik, Jung <sidein@samsung.com>
Sun, 5 Jun 2016 06:02:45 +0000 (15:02 +0900)
committerWonsik, Jung <sidein@samsung.com>
Sun, 5 Jun 2016 06:06:27 +0000 (15:06 +0900)
Creating core/tizen and sdl_tizen.c/h
This files has the function for Tizen app core init/exit
This patch does not have full code for that.

Change-Id: I4dd0224288e2406b6f5d419a60806f2b2d76cc77

17 files changed:
configure
configure.in
src/core/tizen/SDL_tizen.c [new file with mode: 0644]
src/core/tizen/SDL_tizen.h [new file with mode: 0644]
src/main/tizen/SDL_tizen_main.c
src/video/tizen/SDL_tizenevents.c
src/video/tizen/SDL_tizenevents_c.h
src/video/tizen/SDL_tizenmouse.c
src/video/tizen/SDL_tizenmouse.h
src/video/tizen/SDL_tizenopengles.c
src/video/tizen/SDL_tizenopengles.h
src/video/tizen/SDL_tizentouch.c
src/video/tizen/SDL_tizentouch.h
src/video/tizen/SDL_tizenvideo.c
src/video/tizen/SDL_tizenvideo.h
src/video/tizen/SDL_tizenwindow.c
src/video/tizen/SDL_tizenwindow.h

index a3b382c..4cd5eea 100755 (executable)
--- a/configure
+++ b/configure
@@ -18955,6 +18955,7 @@ $as_echo "$video_tizen" >&6; }
 $as_echo "#define SDL_VIDEO_DRIVER_TIZEN 1" >>confdefs.h
 
             SOURCES="$SOURCES $srcdir/src/video/tizen/*.c"
+            SOURCES="$SOURCES $srcdir/src/core/tizen/*.c"
 
             SDLMAIN_SOURCES="$srcdir/src/main/tizen/*.c"
             EXTRA_CFLAGS="$EXTRA_CFLAGS $TIZEN_CFLAGS -DTIZEN"
index e4b9a1e..a031c95 100644 (file)
@@ -1280,6 +1280,7 @@ CheckTizen()
         if test x$video_tizen = xyes; then
             AC_DEFINE(SDL_VIDEO_DRIVER_TIZEN, 1, [ ])
             SOURCES="$SOURCES $srcdir/src/video/tizen/*.c"
+            SOURCES="$SOURCES $srcdir/src/core/tizen/*.c"
 
             SDLMAIN_SOURCES="$srcdir/src/main/tizen/*.c"
             EXTRA_CFLAGS="$EXTRA_CFLAGS $TIZEN_CFLAGS -DTIZEN"
diff --git a/src/core/tizen/SDL_tizen.c b/src/core/tizen/SDL_tizen.c
new file mode 100644 (file)
index 0000000..abb7269
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+  Simple DirectMedia Layer
+  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+  Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+*/
+#include <stdio.h>
+#include "../../SDL_internal.h"
+
+#if __TIZEN__
+#include "SDL_tizen.h"
+#include <appcore-efl.h>
+
+typedef enum {
+    APP_STATE_NOT_RUNNING,
+    APP_STATE_CREATING,
+    APP_STATE_RUNNING,
+} app_state_e;
+
+struct ui_app_context {
+    char *package;
+    char *app_name;
+    app_state_e state;
+    void *callback;
+    void *data;
+};
+
+/* TODO  ::
+ * Impplementation of serveral app core callback function for SDL Application and App Core
+ * */
+
+static int
+_tizen_app_create(void *data)
+{
+    fprintf(stderr,"%s:%d\n",__FUNCTION__, __LINE__);
+    return 0;
+}
+
+static int
+_tizen_app_terminate(void *data)
+{
+    fprintf(stderr,"%s:%d\n",__FUNCTION__, __LINE__);
+    return 0;
+}
+
+static int
+_tizen_app_pause (void *data)
+{
+    fprintf(stderr,"%s:%d\n",__FUNCTION__, __LINE__);
+    return 0;
+}
+
+static int
+_tizen_app_resume(void *data)
+{
+    fprintf(stderr,"%s:%d\n",__FUNCTION__, __LINE__);
+    return 0;
+}
+
+static int
+_tizen_app_reset(bundle *bun, void *data)
+{
+    fprintf(stderr,"%s:%d\n",__FUNCTION__, __LINE__);
+    return 0;
+}
+
+int
+SDL_tizen_app_init(int argc, char *argv[])
+{
+    struct ui_app_context app_context = {
+        .package = NULL,
+        .app_name = NULL,
+        .state = APP_STATE_NOT_RUNNING,
+        .callback = NULL,
+        .data = NULL,
+    };
+
+    struct appcore_ops appcore_context = {
+        .data = &app_context,
+        .create = _tizen_app_create,
+        .terminate = _tizen_app_terminate,
+        .pause = _tizen_app_pause,
+        .resume = _tizen_app_resume,
+        .reset = _tizen_app_reset,
+    };
+
+    if (argc < 1 || argv == NULL)
+    {
+        fprintf(stderr,"%s: APP_ERROR_INVALID_PARAMETER",__FUNCTION__);
+        return 0;
+    }
+
+    if (app_context.state != APP_STATE_NOT_RUNNING)
+    {
+        fprintf(stderr,"%s: APP_STATE_NOT_RUNNING\n",__FUNCTION__);
+        return 0;
+    }
+
+    /* TODO  ::
+     * At first, check the necessary calling app_get_id()/app_get_package_app_name() while app_init.
+     * If necessary, help these functions can be export.
+     * After that, determine the implementation of them.
+     * */
+#if 0
+    if (app_get_id(&(app_context.package)) != 0)
+    {
+        fprintf(stderr,"%s: APP_ERROR_INVALID_CONTEXT",__FUNCTION__);
+        return 0;
+    }
+
+    if (app_get_package_app_name(app_context.package, &(app_context.app_name)) != 0)
+    {
+        free(app_context.package);
+        fprintf(stderr,"%s: APP_ERROR_INVALID_CONTEXT",__FUNCTION__);
+        return 0;
+    }
+#endif
+    return appcore_efl_init(app_context.app_name, &argc, &argv, &appcore_context);
+}
+
+void
+SDL_tizen_app_exit(void)
+{
+    appcore_efl_fini();
+}
+#endif
diff --git a/src/core/tizen/SDL_tizen.h b/src/core/tizen/SDL_tizen.h
new file mode 100644 (file)
index 0000000..674749a
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+  Simple DirectMedia Layer
+  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+  Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "../../SDL_internal.h"
+
+#ifndef _SDL_tizen_h
+#define _SDL_tizen_h
+
+#if __TIZEN__
+int  SDL_tizen_app_init(int argc, char *argv[]);
+void SDL_tizen_app_exit(void);
+#endif
+
+#endif /* _SDL_tizen_h */
index 9d4e004..32b514d 100644 (file)
@@ -8,6 +8,7 @@
 #include "SDL_main.h"
 #include <stdlib.h>
 #include <stdio.h>
+#include "../../core/tizen/SDL_tizen.h"
 
 #ifdef main
 #undef main
@@ -15,6 +16,7 @@
 int main(int argc, char *argv[])
 {
     printf("Start MAIN!!!!!!\n");
+    SDL_tizen_app_init(argc, argv);
     SDL_SetMainReady();
     (void)SDL_main(argc, argv);
     return 0;
index fdcbea6..c77877e 100644 (file)
@@ -3,8 +3,6 @@
   Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
   Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
 
-  Contact: Sangjin Lee <lsj119@samsung.com>
-
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   arising from the use of this software.
index e509693..c79cbe2 100644 (file)
@@ -3,8 +3,6 @@
   Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
   Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
 
-  Contact: Sangjin Lee <lsj119@samsung.com>
-
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   arising from the use of this software.
index d66ed0d..c64a48e 100644 (file)
@@ -3,8 +3,6 @@
   Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
   Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
 
-  Contact: Sangjin Lee <lsj119@samsung.com>
-
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   arising from the use of this software.
index 5502f10..ded9243 100644 (file)
@@ -3,8 +3,6 @@
   Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
   Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
 
-  Contact: Sangjin Lee <lsj119@samsung.com>
-
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   arising from the use of this software.
index 6fe7c3c..86cf548 100644 (file)
@@ -3,8 +3,6 @@
   Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
   Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
 
-  Contact: Sangjin Lee <lsj119@samsung.com>
-
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   arising from the use of this software.
index e8f969d..97efd16 100644 (file)
@@ -3,8 +3,6 @@
   Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
   Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
 
-  Contact: Sangjin Lee <lsj119@samsung.com>
-
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   arising from the use of this software.
index 03031f9..7ba8b98 100644 (file)
@@ -3,8 +3,6 @@
   Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
   Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
 
-  Contact: Sangjin Lee <lsj119@samsung.com>
-
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   arising from the use of this software.
index d66ed0d..c64a48e 100644 (file)
@@ -3,8 +3,6 @@
   Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
   Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
 
-  Contact: Sangjin Lee <lsj119@samsung.com>
-
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   arising from the use of this software.
index 1fd1459..c731828 100644 (file)
@@ -3,8 +3,6 @@
   Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
   Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
 
-  Contact: Sangjin Lee <lsj119@samsung.com>
-
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   arising from the use of this software.
@@ -30,6 +28,7 @@
 #include "SDL_mouse.h"
 #include "SDL_stdinc.h"
 #include "../../events/SDL_events_c.h"
+#include "../../core/tizen/SDL_tizen.h"
 
 #include "SDL_tizenvideo.h"
 #include "SDL_tizenevents_c.h"
@@ -52,41 +51,6 @@ Tizen_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
 static void
 Tizen_VideoQuit(_THIS);
 
-static int
-__tizen_app_create(void *data)
-{
-    printf("%s:%d\n",__FUNCTION__, __LINE__);
-    return 0;
-}
-
-static int
-__tizen_app_terminate(void *data)
-{
-    printf("%s:%d\n",__FUNCTION__, __LINE__);
-    return 0;
-}
-
-static int
-__tizen_app_pause (void *data)
-{
-    printf("%s:%d\n",__FUNCTION__, __LINE__);
-    return 0;
-}
-
-static int
-__tizen_app_resume(void *data)
-{
-    printf("%s:%d\n",__FUNCTION__, __LINE__);
-    return 0;
-}
-
-static int
-__tizen_app_reset(bundle *bun, void *data)
-{
-    printf("%s:%d\n",__FUNCTION__, __LINE__);
-    return 0;
-}
-
 static void
 __tizen_add_display(SDL_VideoData *d, uint32_t id)
 {
@@ -172,26 +136,9 @@ VideoBootStrap TIZEN_bootstrap = {
     Tizen_Available, Tizen_CreateDevice
 };
 
-static int _argc = 1;
-static char *_argv[] = {
-    "tizen_sdl_app",
-    NULL,
-};
-
-static struct appcore_ops _ops = {
-    .create         = __tizen_app_create,
-    .terminate      = __tizen_app_terminate,
-    .pause          = __tizen_app_pause,
-    .resume         = __tizen_app_resume,
-    .reset          = __tizen_app_reset,
-};
-
 int
 Tizen_VideoInit(_THIS)
 {
-    int *argc;
-    char **argv;
-
     TRACE_ENTER();
     SDL_VideoData *data = SDL_malloc(sizeof * data);
 
@@ -205,11 +152,6 @@ Tizen_VideoInit(_THIS)
     __tizen_add_display(data, 0);
 
     Tizen_InitWindow(_this);
-
-    _ops.data = _this;
-    argc = &_argc;
-    argv = _argv;
-    appcore_efl_init(_argv[0], argc, &argv, &_ops);
     return 0;
 }
 
@@ -233,7 +175,7 @@ Tizen_VideoQuit(_THIS)
     SDL_VideoData *data = _this->driverdata;
 
     Tizen_DeinitWindow(_this);
-    appcore_efl_fini();
+    SDL_tizen_app_exit();
     ecore_wl_shutdown();
     free(data);
 
index 7101ece..3df07c8 100644 (file)
@@ -3,8 +3,6 @@
   Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
   Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
 
-  Contact: Sangjin Lee <lsj119@samsung.com>
-
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   arising from the use of this software.
@@ -29,7 +27,6 @@
 
 #include <EGL/egl.h>
 #include <Ecore_Wayland.h>
-#include <appcore-efl.h>
 
 typedef struct {
     EGLDisplay edpy;
index e9d3afe..e87fd4f 100644 (file)
@@ -3,8 +3,6 @@
   Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
   Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
 
-  Contact: Sangjin Lee <lsj119@samsung.com>
-
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   arising from the use of this software.
index 3b035a3..91519d4 100644 (file)
@@ -3,8 +3,6 @@
   Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
   Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
 
-  Contact: Sangjin Lee <lsj119@samsung.com>
-
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   arising from the use of this software.