[SDL_Tizen] Delete using ecore_timer
[platform/upstream/SDL.git] / src / video / tizen / SDL_tizenopengles.c
1 /*
2   Simple DirectMedia Layer
3   Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
4   Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
5
6   This software is provided 'as-is', without any express or implied
7   warranty.  In no event will the authors be held liable for any damages
8   arising from the use of this software.
9
10   Permission is granted to anyone to use this software for any purpose,
11   including commercial applications, and to alter it and redistribute it
12   freely, subject to the following restrictions:
13
14   1. The origin of this software must not be misrepresented; you must not
15      claim that you wrote the original software. If you use this software
16      in a product, an acknowledgment in the product documentation would be
17      appreciated but is not required.
18   2. Altered source versions must be plainly marked as such, and must not be
19      misrepresented as being the original software.
20   3. This notice may not be removed or altered from any source distribution.
21 */
22 #include "../../SDL_internal.h"
23
24 #if SDL_VIDEO_OPENGL_EGL
25
26 #include "SDL_log.h"
27 #include "SDL_tizenopengles.h"
28 #include "SDL_tizenindicator.h"
29 #include "SDL_tizenvideo.h"
30 #include "SDL_tizenwindow.h"
31
32 #if SDL_VIDEO_OPENGL
33 #include "SDL_opengl.h"
34 #endif /* SDL_VIDEO_OPENGL */
35
36 #if SDL_VIDEO_OPENGL_ES
37 #include "SDL_opengles.h"
38 #endif /* SDL_VIDEO_OPENGL_ES */
39
40 /* GL and GLES2 headers conflict on Linux 32 bits */
41 #if SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL
42 #include "SDL_opengles2.h"
43 #endif /* SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL */
44
45 int
46 Tizen_GLES_LoadLibrary(_THIS, const char *path)
47 {
48     int ret;
49
50     ret = SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)ecore_wl_display_get());
51     return ret;
52 }
53
54 SDL_GLContext
55 Tizen_GLES_CreateContext(_THIS, SDL_Window *window)
56 {
57     SDL_GLContext context;
58
59     context = SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
60
61     if(!(window->flags & SDL_WINDOW_FULLSCREEN) && !(window->flags & SDL_WINDOW_BORDERLESS))
62     {
63         SDL_VideoData *data = (SDL_VideoData *) (SDL_GetVideoDevice()->driverdata);
64         if(data->current_thread != SDL_GetThreadID(0))
65             return context;
66         if(!Tizen_Indicator_GLES_Init(window))
67         {
68             SDL_Log("Indicator GLES init error!");
69         }
70     }
71
72     return context;
73 }
74
75 void
76 Tizen_GLES_SwapWindow(_THIS, SDL_Window *window)
77 {
78     Tizen_DrawIndicator(window);
79     SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
80 }
81
82 int
83 Tizen_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
84 {
85     int ret;
86
87     if (window && context) {
88         ret = SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *) window->driverdata)->egl_surface, context);
89     } else {
90         ret = SDL_EGL_MakeCurrent(_this, NULL, NULL);
91     }
92
93     return ret;
94 }
95
96 void
97 Tizen_GLES_DeleteContext(_THIS, SDL_GLContext context)
98 {
99     SDL_EGL_DeleteContext(_this, context);
100 }
101
102 #endif /* SDL_VIDEO_DRIVER_TIZEN && SDL_VIDEO_OPENGL_EGL */
103
104 /* vi: set ts=4 sw=4 expandtab: */