Revert "Upstream merge"
[framework/uifw/evas.git] / src / modules / engines / gl_sdl / evas_engine.c
index 6942e89..46588d9 100644 (file)
@@ -1,8 +1,6 @@
 #include "evas_common.h" /* Also includes international specific stuff */
 #include "evas_engine.h"
 
-#include <dlfcn.h>      /* dlopen,dlclose,etc */
-
 static void*                     _sdl_output_setup     (int w, int h, int fullscreen, int noframe);
                 
 int _evas_engine_GL_SDL_log_dom = -1;
@@ -97,7 +95,7 @@ eng_output_resize(void *data, int w, int h)
          }
      }
 
-   evas_gl_common_context_resize(re->gl_context, w, h);
+   evas_gl_common_context_resize(re->gl_context, w, h, re->gl_context->rot);
 }
 
 static void
@@ -114,7 +112,7 @@ eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
    Render_Engine *re;
 
    re = (Render_Engine *)data;
-   evas_gl_common_context_resize(re->gl_context, re->w, re->h);
+   evas_gl_common_context_resize(re->gl_context, re->w, re->h, re->gl_context->rot);
    /* smple bounding box */
    if (!re->draw.redraw)
      {
@@ -175,6 +173,7 @@ eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, i
 
    re = (Render_Engine *)data;
    evas_gl_common_context_flush(re->gl_context);
+   evas_gl_common_context_newframe(re->gl_context);
    /* get the upate rect surface - return engine data as dummy */
    if (!re->draw.redraw)
      {
@@ -466,6 +465,9 @@ eng_image_colorspace_set(void *data, void *image, int cspace)
        break;
       case EVAS_COLORSPACE_YCBCR422P601_PL:
       case EVAS_COLORSPACE_YCBCR422P709_PL:
+      case EVAS_COLORSPACE_YCBCR422601_PL:
+      case EVAS_COLORSPACE_YCBCR420NV12601_PL:
+      case EVAS_COLORSPACE_YCBCR420TM12601_PL:
         if (im->tex) evas_gl_common_texture_free(im->tex);
         im->tex = NULL;
        if (im->cs.data)
@@ -511,9 +513,10 @@ _native_free_cb(void *data, void *image)
 {
 }
 
-static void
+static void *
 eng_image_native_set(void *data, void *image, void *native)
 {
+   return NULL;
 }
 
 static void *
@@ -596,9 +599,18 @@ eng_image_size_set(void *data, void *image, int w, int h)
         return image;
      }
    im_old = image;
-   if ((eng_image_colorspace_get(data, image) == EVAS_COLORSPACE_YCBCR422P601_PL) ||
-       (eng_image_colorspace_get(data, image) == EVAS_COLORSPACE_YCBCR422P709_PL))
-     w &= ~0x1;
+
+   switch (eng_image_colorspace_get(data, image))
+     {
+      case EVAS_COLORSPACE_YCBCR422P601_PL:
+      case EVAS_COLORSPACE_YCBCR422P709_PL:
+      case EVAS_COLORSPACE_YCBCR422601_PL:
+      case EVAS_COLORSPACE_YCBCR420NV12601_PL:
+      case EVAS_COLORSPACE_YCBCR420TM12601_PL:
+         w &= ~0x1;
+         break;
+     }
+
    if ((im_old) && (im_old->im->cache_entry.w == w) && (im_old->im->cache_entry.h == h))
      return image;
    if (im_old)
@@ -635,24 +647,27 @@ eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h)
 }
 
 static void *
-eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
+eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, int *err)
 {
    Render_Engine *re;
    Evas_GL_Image *im;
-
+   int error;
+   
    re = (Render_Engine *)data;
    if (!image)
      {
        *image_data = NULL;
+        if (err) *err = EVAS_LOAD_ERROR_GENERIC;
        return NULL;
      }
    im = image;
    if (im->native.data)
      {
         *image_data = NULL;
+        if (err) *err = EVAS_LOAD_ERROR_NONE;
         return im;
      }
-   evas_cache_image_load_data(&im->im->cache_entry);
+   error = evas_cache_image_load_data(&im->im->cache_entry);
    switch (im->cs.space)
      {
       case EVAS_COLORSPACE_ARGB8888:
@@ -668,7 +683,8 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
                  if (!im_new)
                    {
                       *image_data = NULL;
-                      return im;
+                       if (err) *err = error;
+                       return im;
                    }
                  evas_gl_common_image_free(im);
                  im = im_new;
@@ -680,12 +696,16 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
        break;
       case EVAS_COLORSPACE_YCBCR422P601_PL:
       case EVAS_COLORSPACE_YCBCR422P709_PL:
+      case EVAS_COLORSPACE_YCBCR422601_PL:
+      case EVAS_COLORSPACE_YCBCR420NV12601_PL:
+      case EVAS_COLORSPACE_YCBCR420TM12601_PL:
        *image_data = im->cs.data;
        break;
       default:
        abort();
        break;
      }
+   if (err) *err = error;
    return im;
 }
 
@@ -718,6 +738,9 @@ eng_image_data_put(void *data, void *image, DATA32 *image_data)
         break;
       case EVAS_COLORSPACE_YCBCR422P601_PL:
       case EVAS_COLORSPACE_YCBCR422P709_PL:
+      case EVAS_COLORSPACE_YCBCR422601_PL:
+      case EVAS_COLORSPACE_YCBCR420NV12601_PL:
+      case EVAS_COLORSPACE_YCBCR420TM12601_PL:
         if (image_data != im->cs.data)
          {
             if (im->cs.data)
@@ -783,14 +806,14 @@ eng_image_scale_hint_set(void *data __UNUSED__, void *image, int hint)
 }
 
 static void
-eng_image_map4_draw(void *data __UNUSED__, void *context, void *surface, void *image, RGBA_Map_Point *p, int smooth, int level)
+eng_image_map_draw(void *data __UNUSED__, void *context, void *surface, void *image, int npoints, RGBA_Map_Point *p, int smooth, int level)
 {
    Render_Engine *re;
    
    re = (Render_Engine *)data;
    evas_gl_common_context_target_surface_set(re->gl_context, surface);
    re->gl_context->dc = context;
-   evas_gl_common_image_map4_draw(re->gl_context, image, p, smooth, level);
+   evas_gl_common_image_map_draw(re->gl_context, image, npoints, p, smooth, level);
 }
 
 static void *
@@ -815,7 +838,7 @@ eng_image_scale_hint_get(void *data __UNUSED__, void *image)
 }
 
 static void
-eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w __UNUSED__, int h __UNUSED__, int ow __UNUSED__, int oh __UNUSED__, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props)
+eng_font_draw(void *data, void *context, void *surface, Evas_Font_Set *font, int x, int y, int w __UNUSED__, int h __UNUSED__, int ow __UNUSED__, int oh __UNUSED__, const Evas_Text_Props *intl_props)
 {
    Render_Engine *re;
 
@@ -835,7 +858,8 @@ eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y
                                              evas_gl_font_texture_new,
                                              evas_gl_font_texture_free,
                                              evas_gl_font_texture_draw);
-       evas_common_font_draw(im, context, font, x, y, text, intl_props);
+       evas_common_font_draw(im, context, (RGBA_Font *) font, x, y,
+              intl_props);
        evas_common_draw_context_font_ext_set(context,
                                              NULL,
                                              NULL,
@@ -852,16 +876,29 @@ eng_canvas_alpha_get(void *data __UNUSED__, void *info __UNUSED__)
 }
 
 static int
+eng_image_load_error_get(void *data __UNUSED__, void *image)
+{
+   Evas_GL_Image *im;
+   
+   if (!image) return EVAS_LOAD_ERROR_NONE;
+   im = image;
+   return im->im->cache_entry.load_error;
+}
+
+
+static int
 module_open(Evas_Module *em)
 {
    if (!em) return 0;
+   if (!evas_gl_common_module_open()) return 0;
    /* get whatever engine module we inherit from */
    if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
    if (_evas_engine_GL_SDL_log_dom < 0)
-     _evas_engine_GL_SDL_log_dom = eina_log_domain_register("EvasEngineGLSDL", EVAS_DEFAULT_LOG_COLOR);
+     _evas_engine_GL_SDL_log_dom = eina_log_domain_register
+       ("evas-gl_sdl", EVAS_DEFAULT_LOG_COLOR);
    if (_evas_engine_GL_SDL_log_dom < 0)
      {
-        EINA_LOG_ERR("Impossible to create a log domain for GL SDL engine.\n");
+        EINA_LOG_ERR("Can not create a module log domain.");
         return 0;
      }
    /* store it for later use */
@@ -913,14 +950,39 @@ module_open(Evas_Module *em)
    ORD(image_colorspace_get);
    ORD(image_native_set);
    ORD(image_native_get);
+#if 0 // filtering disabled
+//   ORD(image_draw_filtered);
+//   ORD(image_filtered_get);
+//   ORD(image_filtered_save);
+//   ORD(image_filtered_free);
+#endif
    ORD(font_draw);
    
    ORD(image_scale_hint_set);
    ORD(image_scale_hint_get);
    
-   ORD(image_map4_draw);
+   ORD(image_map_draw);
    ORD(image_map_surface_new);
    ORD(image_map_surface_free);
+
+//   ORD(image_content_hint_set);
+//   ORD(image_content_hint_get);
+   
+//   ORD(image_cache_flush);
+//   ORD(image_cache_set);
+//   ORD(image_cache_get);
+   
+//   ORD(gl_surface_create);
+//   ORD(gl_surface_destroy);
+//   ORD(gl_context_create);
+//   ORD(gl_context_destroy);
+//   ORD(gl_make_current);
+//   ORD(gl_proc_address_get);
+//   ORD(gl_native_surface_get);
+   
+//   ORD(gl_api_get);
+   
+   ORD(image_load_error_get);
    
    /* now advertise out own api */
    em->functions = (void *)(&func);
@@ -931,6 +993,7 @@ static void
 module_close(Evas_Module *em)
 {
     eina_log_domain_unregister(_evas_engine_GL_SDL_log_dom);
+    evas_gl_common_module_close();
 }
 
 static Evas_Module_Api evas_modapi =
@@ -994,16 +1057,12 @@ _sdl_output_setup                (int w, int h, int fullscreen, int noframe)
 
    if (!surface)
      {
-        CRIT("SDL_SetVideoMode [ %i x %i x 32 ] failed.", w, h);
-       CRIT("SDL: %s\n", SDL_GetError());
+        CRIT("SDL_SetVideoMode [ %i x %i x 32 ] failed. %s", w, h, SDL_GetError());
        SDL_Quit();
         exit(-1);
      }
 
-   fprintf(stderr, "Screen Depth : %d\n", SDL_GetVideoSurface()->format->BitsPerPixel);
-   fprintf(stderr, "Vendor       : %s\n", glGetString(GL_VENDOR));
-   fprintf(stderr, "Renderer     : %s\n", glGetString(GL_RENDERER));
-   fprintf(stderr, "Version      : %s\n", glGetString(GL_VERSION));
+   INF("Screen Depth: %d, Vendor: '%s', Renderer: '%s', Version: '%s'", SDL_GetVideoSurface()->format->BitsPerPixel, glGetString(GL_VENDOR), glGetString(GL_RENDERER), glGetString(GL_VERSION));
 
    re->gl_context = evas_gl_common_context_new();
    if (!re->gl_context)
@@ -1012,7 +1071,7 @@ _sdl_output_setup         (int w, int h, int fullscreen, int noframe)
        return NULL;
      }
    evas_gl_common_context_use(re->gl_context);
-   evas_gl_common_context_resize(re->gl_context, w, h);
+   evas_gl_common_context_resize(re->gl_context, w, h, re->gl_context->rot);
 
    /* End GL Initialization */
    re->w = w;