Enlightenment CVS committal

Author  : barbieri
Project : e17
Module  : libs/evas

Dir     : e17/libs/evas/src/modules/engines/software_16


Modified Files:
        evas_engine.c evas_soft16.h evas_soft16_main.c 


Log Message:
Implement extra operations for image.

I tried to get those right, but I'd like someone else to review these.

===================================================================
RCS file: /cvs/e/e17/libs/evas/src/modules/engines/software_16/evas_engine.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- evas_engine.c       23 Jul 2007 14:22:57 -0000      1.7
+++ evas_engine.c       3 Aug 2007 23:11:56 -0000       1.8
@@ -10,6 +10,11 @@
  *****
  */
 
+#define NOT_IMPLEMENTED()                                               \
+   fprintf(stderr, "NOT_IMPLEMENTED: %s() at %s:%d\n",                  \
+           __FUNCTION__, __FILE__, __LINE__)
+
+
 static int cpunum = 0;
 
 static void *
@@ -149,6 +154,7 @@
 static void
 eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int 
x2, int y2)
 {
+   NOT_IMPLEMENTED();
 //   evas_common_line_draw(surface, context, x1, y1, x2, y2);
 //   evas_common_cpu_end_opt();
 }
@@ -156,6 +162,7 @@
 static void *
 eng_polygon_point_add(void *data, void *context, void *polygon, int x, int y)
 {
+   NOT_IMPLEMENTED();
    return NULL;
 //   return evas_common_polygon_point_add(polygon, x, y);
 }
@@ -163,6 +170,7 @@
 static void *
 eng_polygon_points_clear(void *data, void *context, void *polygon)
 {
+   NOT_IMPLEMENTED();
    return NULL;
 //   return evas_common_polygon_points_clear(polygon);
 }
@@ -170,6 +178,7 @@
 static void
 eng_polygon_draw(void *data, void *context, void *surface, void *polygon)
 {
+   NOT_IMPLEMENTED();
 //   evas_common_polygon_draw(surface, context, polygon);
 //   evas_common_cpu_end_opt();
 }
@@ -177,6 +186,7 @@
 static void *
 eng_gradient_new(void *data)
 {
+   NOT_IMPLEMENTED();
    return NULL;
 //   return evas_common_gradient_new();
 }
@@ -184,84 +194,98 @@
 static void
 eng_gradient_free(void *data, void *gradient)
 {
+   NOT_IMPLEMENTED();
 //   evas_common_gradient_free(gradient);
 }
 
 static void
 eng_gradient_color_stop_add(void *data, void *gradient, int r, int g, int b, 
int a, int delta)
 {
+   NOT_IMPLEMENTED();
 //   evas_common_gradient_color_stop_add(gradient, r, g, b, a, delta);
 }
 
 static void
 eng_gradient_alpha_stop_add(void *data, void *gradient, int a, int delta)
 {
+   NOT_IMPLEMENTED();
 //   evas_common_gradient_alpha_stop_add(gradient, a, delta);
 }
 
 static void
 eng_gradient_color_data_set(void *data, void *gradient, void *map, int len, 
int has_alpha)
 {
+   NOT_IMPLEMENTED();
 //   evas_common_gradient_color_data_set(gradient, map, len, has_alpha);
 }
 
 static void
 eng_gradient_alpha_data_set(void *data, void *gradient, void *alpha_map, int 
len)
 {
+   NOT_IMPLEMENTED();
 //   evas_common_gradient_alpha_data_set(gradient, alpha_map, len);
 }
 
 static void
 eng_gradient_clear(void *data, void *gradient)
 {
+   NOT_IMPLEMENTED();
 //   evas_common_gradient_clear(gradient);
 }
 
 static void
 eng_gradient_fill_set(void *data, void *gradient, int x, int y, int w, int h)
 {
+   NOT_IMPLEMENTED();
 //   evas_common_gradient_fill_set(gradient, x, y, w, h);
 }
 
 static void
 eng_gradient_fill_angle_set(void *data, void *gradient, double angle)
 {
+   NOT_IMPLEMENTED();
 //   evas_common_gradient_fill_angle_set(gradient, angle);
 }
 
 static void
 eng_gradient_fill_spread_set(void *data, void *gradient, int spread)
 {
+   NOT_IMPLEMENTED();
 //   evas_common_gradient_fill_spread_set(gradient, spread);
 }
 
 static void
 eng_gradient_angle_set(void *data, void *gradient, double angle)
 {
+   NOT_IMPLEMENTED();
 //   evas_common_gradient_map_angle_set(gradient, angle);
 }
 
 static void
 eng_gradient_offset_set(void *data, void *gradient, float offset)
 {
+   NOT_IMPLEMENTED();
 //   evas_common_gradient_map_offset_set(gradient, offset);
 }
 
 static void
 eng_gradient_direction_set(void *data, void *gradient, int direction)
 {
+   NOT_IMPLEMENTED();
 //   evas_common_gradient_map_direction_set(gradient, direction);
 }
 
 static void
 eng_gradient_type_set(void *data, void *gradient, char *name, char *params)
 {
+   NOT_IMPLEMENTED();
 //   evas_common_gradient_type_set(gradient, name, params);
 }
 
 static int
 eng_gradient_is_opaque(void *data, void *context, void *gradient, int x, int 
y, int w, int h)
 {
+   NOT_IMPLEMENTED();
    return 0;
 //   RGBA_Draw_Context *dc = (RGBA_Draw_Context *)context;
 //   RGBA_Gradient *gr = (RGBA_Gradient *)gradient;
@@ -274,6 +298,7 @@
 static int
 eng_gradient_is_visible(void *data, void *context, void *gradient, int x, int 
y, int w, int h)
 {
+   NOT_IMPLEMENTED();
    return 0;
 //   RGBA_Draw_Context *dc = (RGBA_Draw_Context *)context;
 //
@@ -292,11 +317,13 @@
 //   gr->type.geometer->geom_set(gr);
 //   len = gr->type.geometer->get_map_len(gr);
 //   evas_common_gradient_map(dc, gr, len);
+   NOT_IMPLEMENTED();
 }
 
 static void
 eng_gradient_render_post(void *data, void *gradient)
 {
+   NOT_IMPLEMENTED();
 }
 
 static void
@@ -304,13 +331,14 @@
 {
 //   evas_common_gradient_draw(surface, context, x, y, w, h, gradient);
 //   evas_common_cpu_end_opt();
+   NOT_IMPLEMENTED();
 }
 
 static int
 eng_image_alpha_get(void *data, void *image)
 {
    Soft16_Image *im;
-   
+
    if (!image) return 0;
    im = image;
    if (im->have_alpha) return 1;
@@ -324,9 +352,11 @@
 }
 
 static void *
-eng_image_alpha_set(void *data, void *image, int has_alpha)
+eng_image_alpha_set(void *data, void *image, int have_alpha)
 {
-   // FIXME: implement
+   if (!image) return NULL;
+   have_alpha = !!have_alpha;
+   soft16_image_alpha_set(image, have_alpha);
    return image;
 }
 
@@ -356,7 +386,7 @@
 static void
 eng_image_colorspace_set(void *data, void *image, int cspace)
 {
-// FIXME: implement
+   NOT_IMPLEMENTED();
 }
 
 static void
@@ -379,15 +409,25 @@
 static void *
 eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data, int 
alpha, int cspace)
 {
-   // FIXME: implement
-   return NULL;
+   if ((image_data) && (cspace != EVAS_COLORSPACE_RGB565_A5P))
+     {
+       fprintf(stderr, "Unsupported colorspace %d in %s() (%s:%d)\n",
+               cspace, __FUNCTION__, __FILE__, __LINE__);
+       return NULL;
+     }
+   return soft16_image_new(w, h, -1, alpha, (DATA16 *)image_data, 0);
 }
 
 static void *
 eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, 
int alpha, int cspace)
 {
-   // FIXME: implement
-   return NULL;
+   if ((image_data) && (cspace != EVAS_COLORSPACE_RGB565_A5P))
+     {
+       fprintf(stderr, "Unsupported colorspace %d in %s() (%s:%d)\n",
+               cspace, __FUNCTION__, __FILE__, __LINE__);
+       return NULL;
+     }
+   return soft16_image_new(w, h, -1, alpha, (DATA16 *)image_data, 1);
 }
 
 static void
@@ -412,8 +452,13 @@
 static void *
 eng_image_size_set(void *data, void *image, int w, int h)
 {
-   // FIXME: implement
-   return image;
+   if (!image) return NULL;
+   if ((w <= 0) || (h <= 0))
+     {
+       soft16_image_free(image);
+       return NULL;
+     }
+   return soft16_image_size_set(image, w, h);
 }
 
 static void
@@ -430,7 +475,8 @@
 static void *
 eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h)
 {
-   // FIXME: implement
+   /* FIXME: is this required? */
+   //NOT_IMPLEMENTED();
    return image;
 }
 
@@ -469,8 +515,17 @@
 static void *
 eng_image_data_put(void *data, void *image, DATA32 *image_data)
 {
-   // FIXME: implement
-   return image;
+   Soft16_Image *old_im, *new_im;
+
+   if (!image) return NULL;
+
+   old_im = image;
+   if ((DATA16 *)image_data == old_im->pixels) return old_im;
+
+   new_im = soft16_image_new(old_im->w, old_im->h, old_im->stride,
+                            old_im->have_alpha, (DATA16 *)image_data, 0);
+   soft16_image_free(old_im);
+   return new_im;
 }
 
 static void
@@ -805,10 +860,10 @@
 {
 }
 
-EAPI Evas_Module_Api evas_modapi = 
+EAPI Evas_Module_Api evas_modapi =
 {
-   EVAS_MODULE_API_VERSION, 
-     EVAS_MODULE_TYPE_ENGINE,
-     "software_16",
-     "none"
+  EVAS_MODULE_API_VERSION,
+  EVAS_MODULE_TYPE_ENGINE,
+  "software_16",
+  "none"
 };
===================================================================
RCS file: /cvs/e/e17/libs/evas/src/modules/engines/software_16/evas_soft16.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- evas_soft16.h       20 Jul 2007 00:18:07 -0000      1.7
+++ evas_soft16.h       3 Aug 2007 23:11:56 -0000       1.8
@@ -86,6 +86,9 @@
 Soft16_Image *soft16_image_load(const char *file, const char *key, int *error, 
Evas_Image_Load_Opts *lo);
 void soft16_image_load_data(Soft16_Image *im);
 void soft16_image_draw(Soft16_Image *src, Soft16_Image *dst, RGBA_Draw_Context 
*dc, int src_region_x, int src_region_y, int src_region_w, int src_region_h, 
int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h, int 
smooth);
+void soft16_image_alpha_set(Soft16_Image *im, int have_alpha);
+Soft16_Image *soft16_image_size_set(Soft16_Image *im, int w, int h);
+
 
 void soft16_image_draw_unscaled(Soft16_Image *src, Soft16_Image *dst, 
RGBA_Draw_Context *dc, const Evas_Rectangle sr, const Evas_Rectangle dr, const 
Evas_Rectangle cr);
 void soft16_image_draw_scaled_sampled(Soft16_Image *src, Soft16_Image *dst, 
RGBA_Draw_Context *dc, const Evas_Rectangle sr, const Evas_Rectangle dr, const 
Evas_Rectangle cr);
===================================================================
RCS file: 
/cvs/e/e17/libs/evas/src/modules/engines/software_16/evas_soft16_main.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- evas_soft16_main.c  20 Jul 2007 00:18:07 -0000      1.13
+++ evas_soft16_main.c  3 Aug 2007 23:11:56 -0000       1.14
@@ -57,14 +57,20 @@
 {
    Soft16_Image *im;
 
+   if (stride < 0) stride = _calc_stride(w);
+
    im = soft16_image_alloc(w, h, stride, have_alpha, copy);
    if (!im) return NULL;
 
-   if (copy) memcpy(im->pixels, pixels, IMG_BYTE_SIZE(stride, h, have_alpha));
-   else
+   if (pixels)
      {
-       im->pixels = pixels;
-       if (have_alpha) im->alpha = (DATA8 *)(im->pixels + (stride * h));
+       if (copy)
+         memcpy(im->pixels, pixels, IMG_BYTE_SIZE(stride, h, have_alpha));
+       else
+         {
+            im->pixels = pixels;
+            if (have_alpha) im->alpha = (DATA8 *)(im->pixels + (stride * h));
+         }
      }
    return im;
 }
@@ -442,3 +448,81 @@
    dc->clip = clip_bkp;
 }
 
+void
+soft16_image_alpha_set(Soft16_Image *im, int have_alpha)
+{
+   if (im->have_alpha == have_alpha) return;
+   im->have_alpha = have_alpha;
+
+   if ((im->pixels) && (im->free_pixels))
+     {
+       int size;
+
+       size = im->stride * im->h;
+       if (!im->have_alpha)
+         {
+            im->pixels = realloc(im->pixels, size * 2);
+            im->alpha = NULL;
+         }
+       else
+         {
+            im->pixels = realloc(im->pixels, size * 3);
+            im->alpha = (DATA8*)(im->pixels + size);
+            memset(im->alpha, 0x1f, size);
+         }
+     }
+}
+
+Soft16_Image *
+soft16_image_size_set(Soft16_Image *old_im, int w, int h)
+{
+   Soft16_Image *new_im;
+   DATA16 *dp, *sp;
+   int i, cw, ch, ew;
+
+   if ((old_im->w == w) && (old_im->h == h)) return old_im;
+
+   new_im = soft16_image_new(w, h, -1, old_im->have_alpha, NULL, 1);
+
+   if (old_im->w < new_im->w)
+     cw = old_im->w;
+   else
+     cw = new_im->w;
+
+   ew = new_im->w - cw;
+
+   if (old_im->h < new_im->h)
+     ch = old_im->h;
+   else
+     ch = new_im->h;
+
+   dp = new_im->pixels;
+   sp = old_im->pixels;
+   for (i = 0; i < ch; i++)
+     {
+       memcpy(dp, sp, cw * sizeof(DATA16));
+       if (ew > 0) memset(dp, 0, ew * sizeof(DATA16));
+
+       dp += new_im->stride;
+       sp += old_im->stride;
+     }
+
+   if (old_im->have_alpha)
+     {
+       DATA8 *dp, *sp;
+
+       dp = new_im->alpha;
+       sp = old_im->alpha;
+       for (i = 0; i < ch; i++)
+         {
+            memcpy(dp, sp, cw * sizeof(DATA8));
+            if (ew > 0) memset(dp, 0, ew * sizeof(DATA8));
+
+            dp += new_im->stride;
+            sp += old_im->stride;
+         }
+     }
+
+   soft16_image_free(old_im);
+   return new_im;
+}



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to