[Rollback]
[framework/uifw/evas.git] / src / modules / engines / software_generic / evas_engine.c
index d9db3a0..f2bd395 100644 (file)
@@ -97,6 +97,24 @@ eng_context_multiplier_get(void *data __UNUSED__, void *context, int *r, int *g,
 }
 
 static void
+eng_context_mask_set(void *data __UNUSED__, void *context, void *mask, int x, int y, int w, int h)
+{
+   evas_common_draw_context_set_mask(context, mask, x, y, w, h);
+}
+
+static void
+eng_context_mask_unset(void *data __UNUSED__, void *context)
+{
+   evas_common_draw_context_unset_mask(context);
+}
+
+static void *
+eng_context_mask_get(void *data __UNUSED__, void *context)
+{
+   return ((RGBA_Draw_Context *)context)->mask.mask;
+}
+
+static void
 eng_context_cutout_add(void *data __UNUSED__, void *context, int x, int y, int w, int h)
 {
    evas_common_draw_context_add_cutout(context, x, y, w, h);
@@ -239,6 +257,31 @@ eng_image_colorspace_get(void *data __UNUSED__, void *image)
    return im->space;
 }
 
+static void
+eng_image_mask_create(void *data __UNUSED__, void *image)
+{
+   RGBA_Image *im;
+   int sz;
+   uint8_t *dst,*end;
+   uint32_t *src;
+
+   if (!image) return;
+   im = image;
+   if (im->mask.mask && !im->mask.dirty) return;
+
+   if (im->mask.mask) free(im->mask.mask);
+   sz = im->cache_entry.w * im->cache_entry.h;
+   im->mask.mask = malloc(sz);
+   dst = im->mask.mask;
+   if (!im->image.data)
+      evas_cache_image_load_data(&im->cache_entry);
+   src = im->image.data;
+   for (end = dst + sz ; dst < end ; dst ++, src ++)
+      *dst = *src >> 24;
+   im->mask.dirty = 0;
+}
+
+
 static void *
 eng_image_alpha_set(void *data __UNUSED__, void *image, int has_alpha)
 {
@@ -428,7 +471,6 @@ eng_image_data_put(void *data, void *image, DATA32 *image_data)
                  if (!im->cs.no_free) free(im->cs.data);
               }
             im->cs.data = image_data;
-            evas_common_image_colorspace_dirty(im);
          }
         break;
       default:
@@ -470,11 +512,11 @@ eng_image_draw(void *data __UNUSED__, void *context, void *surface, void *image,
 #endif
         )
      {
-        evas_common_rgba_image_scalecache_prepare((Image_Entry *)(im), 
+        evas_common_rgba_image_scalecache_prepare((Image_Entry *)(im),
                                                   surface, context, smooth,
                                                   src_x, src_y, src_w, src_h,
                                                   dst_x, dst_y, dst_w, dst_h);
-        
+
         evas_common_pipe_image_draw(im, surface, context, smooth,
                                     src_x, src_y, src_w, src_h,
                                     dst_x, dst_y, dst_w, dst_h);
@@ -491,7 +533,7 @@ eng_image_draw(void *data __UNUSED__, void *context, void *surface, void *image,
         evas_common_rgba_image_scalecache_do(&im->cache_entry, surface, context, smooth,
                                              src_x, src_y, src_w, src_h,
                                              dst_x, dst_y, dst_w, dst_h);
-/*        
+/*
        if (smooth)
          evas_common_scale_rgba_in_to_out_clip_smooth(im, surface, context,
                                                       src_x, src_y, src_w, src_h,
@@ -506,14 +548,14 @@ eng_image_draw(void *data __UNUSED__, void *context, void *surface, void *image,
 }
 
 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)
 {
-   RGBA_Image *im, *srf;
-//   RGBA_Map_Point *pt = p;
+   RGBA_Image *im;
 
    if (!image) return;
+   if (npoints < 3) return;
    im = image;
-   srf = surface;
+
    if ((p[0].x == p[3].x) &&
        (p[1].x == p[2].x) &&
        (p[0].y == p[1].y) &&
@@ -522,12 +564,12 @@ eng_image_map4_draw(void *data __UNUSED__, void *context, void *surface, void *i
        (p[0].y <= p[2].y) &&
        (p[0].u == 0) &&
        (p[0].v == 0) &&
-       (p[1].u == (im->cache_entry.w << FP)) &&
+       (p[1].u == (int)(im->cache_entry.w << FP)) &&
        (p[1].v == 0) &&
-       (p[2].u == (im->cache_entry.w << FP)) &&
-       (p[2].v == (im->cache_entry.h << FP)) &&
+       (p[2].u == (int)(im->cache_entry.w << FP)) &&
+       (p[2].v == (int)(im->cache_entry.h << FP)) &&
        (p[3].u == 0) &&
-       (p[3].v == (im->cache_entry.h << FP)) &&
+       (p[3].v == (int)(im->cache_entry.h << FP)) &&
        (p[0].col == 0xffffffff) &&
        (p[1].col == 0xffffffff) &&
        (p[2].col == 0xffffffff) &&
@@ -552,12 +594,18 @@ eng_image_map4_draw(void *data __UNUSED__, void *context, void *surface, void *i
        && evas_common_frameq_enabled()
 # endif
         )
-          evas_common_pipe_map4_draw(im, surface, context, p, smooth, level);
+          evas_common_pipe_map_draw(im, surface, context, npoints, p, smooth, level);
         else
 #endif
-          evas_common_map4_rgba(im, surface, context, p, smooth, level);
+          evas_common_map_rgba(im, surface, context, npoints, p, smooth, level);
      }
    evas_common_cpu_end_opt();
+
+   if (npoints > 4)
+     {
+        eng_image_map_draw(data, context, surface, image, npoints - 2, p + 2,
+                       smooth, level);
+     }
 }
 
 static void *
@@ -810,6 +858,8 @@ static Evas_Func func =
      eng_context_clip_clip,
      eng_context_clip_unset,
      eng_context_clip_get,
+     eng_context_mask_set,
+     eng_context_mask_unset,
      eng_context_color_set,
      eng_context_color_get,
      eng_context_multiplier_set,
@@ -853,6 +903,7 @@ static Evas_Func func =
      eng_image_format_get,
      eng_image_colorspace_set,
      eng_image_colorspace_get,
+     eng_image_mask_create,
      eng_image_native_set,
      eng_image_native_get,
      /* image cache funcs */
@@ -888,11 +939,11 @@ static Evas_Func func =
      /* more font draw functions */
      eng_font_last_up_to_pos,
      /* FUTURE software generic calls go here (done) */
-     eng_image_map4_draw,
+     eng_image_map_draw,
      eng_image_map_surface_new,
      eng_image_map_surface_free,
-     NULL, // eng_image_content_hint_set - software doesnt use it
-     NULL // eng_image_content_hint_get - software doesnt use it
+     NULL, // eng_image_content_hint_set - software doesn't use it
+     NULL // eng_image_content_hint_get - software doesn't use it
      /* FUTURE software generic calls go here */
 };
 
@@ -908,11 +959,12 @@ static int
 module_open(Evas_Module *em)
 {
    if (!em) return 0;
-   _evas_soft_gen_log_dom = eina_log_domain_register("EvasSoftGeneric", EVAS_DEFAULT_LOG_COLOR);
+   _evas_soft_gen_log_dom = eina_log_domain_register
+     ("evas-software_generic", EVAS_DEFAULT_LOG_COLOR);
    if(_evas_soft_gen_log_dom<0)
      {
-       EINA_LOG_ERR("Evas SoftGen : Impossible to create a log domain for the software generic engine.\n");
-       return 0;
+        EINA_LOG_ERR("Can not create a module log domain.");
+        return 0;
      }
    em->functions = (void *)(&func);
    cpunum = eina_cpu_count();
@@ -920,7 +972,7 @@ module_open(Evas_Module *em)
 }
 
 static void
-module_close(Evas_Module *em)
+module_close(Evas_Module *em __UNUSED__)
 {
   eina_log_domain_unregister(_evas_soft_gen_log_dom);
 }