upgrade SDL to version 2.0.8
[platform/upstream/SDL.git] / src / video / SDL_egl.c
index 0daf98a..e5e45bc 100755 (executable)
@@ -221,7 +221,23 @@ SDL_EGL_GetProcAddress(_THIS, const char *proc)
         }
     }
 #endif
-    
+
+#ifdef __TIZEN__
+    char *Tizen_Not_Support_API[4] = {
+        "eglSetDamageRegionKHR",
+        "eglSwapBuffersWithDamageEXT",
+        "eglSwapBuffersWithDamageINTEL",
+        "eglSwapBuffersWithDamage"
+    };
+
+    int i;
+    for(i=0; i<4; i++)
+    {
+        if(!SDL_strcmp(proc, Tizen_Not_Support_API[i]))
+            return NULL;
+    }
+#endif
+
     retval = SDL_LoadFunction(_this->egl_data->egl_dll_handle, proc);
     if (!retval && SDL_strlen(proc) <= 1022) {
         procname[0] = '_';
@@ -578,7 +594,7 @@ SDL_GLContext
 SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
 {
     /* max 14 values plus terminator. */
-    EGLint attribs[15];
+    EGLint attribs[40];
     int attr = 0;
 
     EGLContext egl_context, share_context = EGL_NO_CONTEXT;
@@ -640,6 +656,34 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
         }
     }
 
+#ifdef __TIZEN__
+    if ((SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_IMG_context_priority"))
+         && (_this->gl_config.context_priority_level > SDL_GL_CONTEXT_PRIORITY_NONE)) {
+        if (_this->gl_config.flags == SDL_GL_CONTEXT_PRIORITY_HIGH) {
+           attribs[attr++] = EGL_CONTEXT_PRIORITY_HIGH_IMG;
+        }
+        else if (_this->gl_config.flags == SDL_GL_CONTEXT_PRIORITY_MEDIUM) {
+           attribs[attr++] = EGL_CONTEXT_PRIORITY_MEDIUM_IMG;
+        }
+        else if (_this->gl_config.flags == SDL_GL_CONTEXT_PRIORITY_LOW) {
+           attribs[attr++] = EGL_CONTEXT_PRIORITY_LOW_IMG;
+        }
+    }
+#endif
+
+    if (_this->gl_config.no_error) {
+#ifdef EGL_KHR_create_context_no_error
+        if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_create_context_no_error")) {
+            attribs[attr++] = EGL_CONTEXT_OPENGL_NO_ERROR_KHR;
+            attribs[attr++] = _this->gl_config.no_error;
+        } else
+#endif
+        {
+            SDL_SetError("EGL implementation does not support no_error contexts");
+            return NULL;
+        }
+    }
+
     if (_this->gl_config.no_error) {
 #ifdef EGL_KHR_create_context_no_error
         if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_create_context_no_error")) {
@@ -698,19 +742,28 @@ SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context)
     if (!_this->egl_data) {
         return SDL_SetError("OpenGL not initialized");
     }
-    
-    /* The android emulator crashes badly if you try to eglMakeCurrent 
-     * with a valid context and invalid surface, so we have to check for both here.
-     */
-    if (!egl_context || !egl_surface) {
-         _this->egl_data->eglMakeCurrent(_this->egl_data->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
-    } else {
+#ifdef __TIZEN__
+    if ((SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_surfaceless_context")) && (!egl_surface)) {
         if (!_this->egl_data->eglMakeCurrent(_this->egl_data->egl_display,
-            egl_surface, egl_surface, egl_context)) {
-            return SDL_EGL_SetError("Unable to make EGL context current", "eglMakeCurrent");
+                EGL_NO_SURFACE , EGL_NO_SURFACE , egl_context)) {
+                return SDL_SetError("Unable to make EGL context current");
+            }
+    }
+    else
+#endif
+    {
+        /* The android emulator crashes badly if you try to eglMakeCurrent
+        * with a valid context and invalid surface, so we have to check for both here.
+        */
+        if (!egl_context || !egl_surface) {
+            _this->egl_data->eglMakeCurrent(_this->egl_data->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+        } else {
+            if (!_this->egl_data->eglMakeCurrent(_this->egl_data->egl_display,
+                egl_surface, egl_surface, egl_context)) {
+                return SDL_EGL_SetError("Unable to make EGL context current", "eglMakeCurrent");
+            }
         }
     }
-      
     return 0;
 }