Enlightenment CVS committal

Author  : barbieri
Project : e17
Module  : proto/python-efl

Dir     : e17/proto/python-efl/python-evas/evas


Modified Files:
        evas_object_image_rotate.c evas_object_image_mask.c 


Log Message:
Cleanup pointer types.

Avoid doing casts all over the places.

===================================================================
RCS file: 
/cvs/e/e17/proto/python-efl/python-evas/evas/evas_object_image_rotate.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- evas_object_image_rotate.c  12 Mar 2008 18:53:55 -0000      1.4
+++ evas_object_image_rotate.c  12 Mar 2008 19:55:57 -0000      1.5
@@ -34,10 +34,12 @@
    switch (colorspace)
      {
       case EVAS_COLORSPACE_ARGB8888:
-        image_byte_size = IMG_BYTE_SIZE_ARGB8888(dst_stride, dst_height, 
has_alpha);
+        image_byte_size = IMG_BYTE_SIZE_ARGB8888(dst_stride, dst_height,
+                                                 has_alpha);
         break;
       case EVAS_COLORSPACE_RGB565_A5P:
-        image_byte_size = IMG_BYTE_SIZE_RGB565(dst_stride, dst_height, 
has_alpha);
+        image_byte_size = IMG_BYTE_SIZE_RGB565(dst_stride, dst_height,
+                                               has_alpha);
         break;
       default:
         image_byte_size = -1;
@@ -48,18 +50,20 @@
 }
 
 static void
-_data8_image_rotate_90(char *dst, const char *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
+_data8_image_rotate_90(DATA8 *dst, const DATA8 *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
 {
-   DATA8 *dp, *sp;
-   int x, y;
+   const DATA8 *sp;
+   DATA8 *dp;
+   int y;
 
-   sp = (DATA8 *) src;
-   dp = ((DATA8 *) dst) + ((out_x +
-                           (w + out_y - 1) * dst_stride));
+   sp = src;
+   dp = dst + ((out_x + (w + out_y - 1) * dst_stride));
 
    for (y = 0; y < h; y++)
      {
-        DATA8 *dp_itr, *sp_itr;
+       const DATA8 *sp_itr;
+        DATA8 *dp_itr;
+       int x;
 
         sp_itr = sp;
         dp_itr = dp;
@@ -77,18 +81,20 @@
 }
 
 static void
-_data16_image_rotate_90(char *dst, const char *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
+_data16_image_rotate_90(DATA16 *dst, const DATA16 *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
 {
-   DATA16 *dp, *sp;
-   int x, y;
+   const DATA16 *sp;
+   DATA16 *dp;
+   int y;
 
-   sp = (DATA16 *) src;
-   dp = ((DATA16 *) dst) + ((out_x +
-                            (w + out_y - 1) * dst_stride));
+   sp = src;
+   dp = dst + ((out_x + (w + out_y - 1) * dst_stride));
 
    for (y = 0; y < h; y++)
      {
-        DATA16 *dp_itr, *sp_itr;
+       const DATA16 *sp_itr;
+        DATA16 *dp_itr;
+       int x;
 
         sp_itr = sp;
         dp_itr = dp;
@@ -106,18 +112,20 @@
 }
 
 static void
-_data32_image_rotate_90(char *dst, const char *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
+_data32_image_rotate_90(DATA32 *dst, const DATA32 *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
 {
-   DATA32 *dp, *sp;
-   int x, y;
+   const DATA32 *sp;
+   DATA32 *dp;
+   int y;
 
-   sp = (DATA32 *) src;
-   dp = ((DATA32 *) dst) + ((out_x +
-                            (w + out_y - 1) * dst_stride));
+   sp = src;
+   dp = dst + ((out_x + (w + out_y - 1) * dst_stride));
 
    for (y = 0; y < h; y++)
      {
-        DATA32 *dp_itr, *sp_itr;
+       const DATA32 *sp_itr;
+        DATA32 *dp_itr;
+       int x;
 
         sp_itr = sp;
         dp_itr = dp;
@@ -135,18 +143,21 @@
 }
 
 static void
-_data8_image_rotate_180(char *dst, const char *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
+_data8_image_rotate_180(DATA8 *dst, const DATA8 *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
 {
-   DATA8 *dp, *sp;
-   int x, y;
+   const DATA8 *sp;
+   DATA8 *dp;
+   int y;
 
-   sp = (DATA8 *) src;
-   dp = ((DATA8 *) dst) + ((w + out_x - 1) +
-                          (h + out_y - 1) * dst_stride);
+   sp = src;
+   dp = dst + ((w + out_x - 1) + (h + out_y - 1) * dst_stride);
 
    for (y = 0; y < h; y++)
      {
-        DATA8 *dp_itr, *sp_itr;
+       const DATA8 *sp_itr;
+        DATA8 *dp_itr;
+       int x;
+
         sp_itr = sp;
         dp_itr = dp;
 
@@ -163,18 +174,21 @@
 }
 
 static void
-_data16_image_rotate_180(char *dst, const char *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
+_data16_image_rotate_180(DATA16 *dst, const DATA16 *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
 {
-   DATA16 *dp, *sp;
-   int x, y;
+   const DATA16 *sp;
+   DATA16 *dp;
+   int y;
 
-   sp = (DATA16 *) src;
-   dp = ((DATA16 *) dst) + ((w + out_x - 1) +
-                           (h + out_y - 1) * dst_stride);
+   sp = src;
+   dp = dst + ((w + out_x - 1) + (h + out_y - 1) * dst_stride);
 
    for (y = 0; y < h; y++)
      {
-        DATA16 *dp_itr, *sp_itr;
+       const DATA16 *sp_itr;
+        DATA16 *dp_itr;
+       int x;
+
         sp_itr = sp;
         dp_itr = dp;
 
@@ -189,19 +203,23 @@
         dp -= dst_stride;
      }
 }
+
 static void
-_data32_image_rotate_180(char *dst, const char *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
+_data32_image_rotate_180(DATA32 *dst, const DATA32 *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
 {
-   DATA32 *dp, *sp;
-   int x, y;
+   const DATA32 *sp;
+   DATA32 *dp;
+   int y;
 
-   sp = (DATA32 *) src;
-   dp = ((DATA32 *) dst) + ((w + out_x - 1) +
-                           (h + out_y - 1) * dst_stride);
+   sp = src;
+   dp = dst + ((w + out_x - 1) + (h + out_y - 1) * dst_stride);
 
    for (y = 0; y < h; y++)
      {
-        DATA32 *dp_itr, *sp_itr;
+       const DATA32 *sp_itr;
+        DATA32 *dp_itr;
+       int x;
+
         sp_itr = sp;
         dp_itr = dp;
 
@@ -218,18 +236,21 @@
 }
 
 static void
-_data8_image_rotate_270(char *dst, const char *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
+_data8_image_rotate_270(DATA8 *dst, const DATA8 *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
 {
-   DATA8 *dp, *sp;
-   int x, y;
+   const DATA8 *sp;
+   DATA8 *dp;
+   int y;
 
-   sp = (DATA8 *) src;
-   dp = ((DATA8 *) dst) + ((h + out_x - 1) +
-                          out_y * dst_stride);
+   sp = src;
+   dp = dst + ((h + out_x - 1) + out_y * dst_stride);
 
    for (y = 0; y < h; y++)
      {
-        DATA8 *dp_itr, *sp_itr;
+       const DATA8 *sp_itr;
+        DATA8 *dp_itr;
+       int x;
+
         sp_itr = sp;
         dp_itr = dp;
 
@@ -246,18 +267,21 @@
 }
 
 static void
-_data16_image_rotate_270(char *dst, const char *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
+_data16_image_rotate_270(DATA16 *dst, const DATA16 *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
 {
-   DATA16 *dp, *sp;
-   int x, y;
+   const DATA16 *sp;
+   DATA16 *dp;
+   int y;
 
-   sp = (DATA16 *) src;
-   dp = ((DATA16 *) dst) + ((h + out_x - 1) +
-                           out_y * dst_stride);
+   sp = src;
+   dp = dst + ((h + out_x - 1) + out_y * dst_stride);
 
    for (y = 0; y < h; y++)
      {
-        DATA16 *dp_itr, *sp_itr;
+       const DATA16 *sp_itr;
+        DATA16 *dp_itr;
+       int x;
+
         sp_itr = sp;
         dp_itr = dp;
 
@@ -274,18 +298,21 @@
 }
 
 static void
-_data32_image_rotate_270(char *dst, const char *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
+_data32_image_rotate_270(DATA32 *dst, const DATA32 *src, int dst_stride, int 
src_stride, int out_x, int out_y, int w, int h)
 {
-   DATA32 *dp, *sp;
-   int x, y;
+   const DATA32 *sp;
+   DATA32 *dp;
+   int y;
 
-   sp = (DATA32 *) src;
-   dp = ((DATA32 *) dst) + ((h + out_x - 1) +
-                           out_y * dst_stride);
+   sp = src;
+   dp = dst + ((h + out_x - 1) + out_y * dst_stride);
 
    for (y = 0; y < h; y++)
      {
-        DATA32 *dp_itr, *sp_itr;
+       const DATA32 *sp_itr;
+        DATA32 *dp_itr;
+       int x;
+
         sp_itr = sp;
         dp_itr = dp;
 
@@ -302,14 +329,14 @@
 }
 
 static void
-_rgb565_image_rotate(Evas_Object_Image_Rotation rotation, char *dst, const 
char *src, int src_stride, unsigned char has_alpha, int out_x, int out_y, int 
w, int h)
+_rgb565_image_rotate(Evas_Object_Image_Rotation rotation, DATA16 *dst, const 
DATA16 *src, int src_stride, unsigned char has_alpha, int out_x, int out_y, int 
w, int h)
 {
    int dst_stride;
-   char *dst_alpha;
-   const char *src_alpha;
+   DATA8 *dst_alpha;
+   const DATA8 *src_alpha;
 
    if (has_alpha)
-     src_alpha = src + src_stride * h * 2;
+     src_alpha = (const DATA8*)(src + src_stride * h);
 
    switch (rotation)
      {
@@ -320,7 +347,7 @@
                                 out_x, out_y, w, h);
         if (has_alpha)
           {
-             dst_alpha = dst + dst_stride * w * 2;
+             dst_alpha = (DATA8 *)(dst + dst_stride * w);
              _data8_image_rotate_90(dst_alpha, src_alpha,
                                     dst_stride, src_stride,
                                     out_x, out_y, w, h);
@@ -333,7 +360,7 @@
                                  out_x, out_y, w, h);
         if (has_alpha)
           {
-             dst_alpha = dst + dst_stride * h * 2;
+             dst_alpha = (DATA8 *)(dst + dst_stride * h);
              _data8_image_rotate_180(dst_alpha, src_alpha,
                                      dst_stride, src_stride,
                                      out_x, out_y, w, h);
@@ -346,7 +373,7 @@
                                  out_x, out_y, w, h);
         if (has_alpha)
           {
-             dst_alpha = dst + dst_stride * w * 2;
+             dst_alpha = (DATA8 *)(dst + dst_stride * w);
              _data8_image_rotate_270(dst_alpha, src_alpha,
                                      dst_stride, src_stride,
                                      out_x, out_y, w, h);
@@ -358,7 +385,7 @@
 }
 
 static void
-_argb8888_image_rotate(Evas_Object_Image_Rotation rotation, char *dst, const 
char *src, int src_stride, int out_x, int out_y, int w, int h)
+_argb8888_image_rotate(Evas_Object_Image_Rotation rotation, DATA32 *dst, const 
DATA32 *src, int src_stride, int out_x, int out_y, int w, int h)
 {
    int dst_stride;
 
@@ -394,8 +421,7 @@
    int image_byte_size;
    int stride, width, height;
    unsigned char has_alpha;
-   char *new_buffer;
-   char *src_data;
+   void *new_buffer, *src_data;
 
    evas_object_image_size_get(image, &width, &height);
    stride = evas_object_image_stride_get(image);
@@ -408,6 +434,9 @@
      return;
 
    new_buffer = malloc(image_byte_size);
+   if (!new_buffer)
+     return;
+
    src_data = evas_object_image_data_get(image, 0);
 
    switch (colorspace)
===================================================================
RCS file: 
/cvs/e/e17/proto/python-efl/python-evas/evas/evas_object_image_mask.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- evas_object_image_mask.c    12 Mar 2008 18:53:55 -0000      1.2
+++ evas_object_image_mask.c    12 Mar 2008 19:55:57 -0000      1.3
@@ -9,60 +9,61 @@
 
 
 static void
-_argb8888_image_mask_fill(char *dst, const char *src, const char *msk, const 
char *srf, int x_msk, int y_msk, int x_srf, int y_srf, int src_stride, int 
src_width, int src_height, int msk_stride, int msk_width, int msk_height, int 
srf_stride, int srf_width, int srf_height)
+_argb8888_image_mask_fill(DATA32 *dst, const DATA32 *src, const DATA32 *msk, 
const DATA32 *srf, int x_msk, int y_msk, int x_srf, int y_srf, int src_stride, 
int src_width, int src_height, int msk_stride, int msk_width, int msk_height, 
int srf_stride, int srf_width, int srf_height)
 {
-   int x, y, xp, yp, xs, ys;
-   int r, g, b, a;
-   DATA32 pixel, pxa, pxb;
-   DATA32 *sp = (DATA32 *) src;
-   DATA32 *mp = (DATA32 *) msk;
-   DATA32 *fp = (DATA32 *) srf;
-   DATA32 *dp = (DATA32 *) dst;
+   int y;
 
    for (y = 0; y < src_height; y++)
-     for (x = 0; x < src_width; x++)
-       {
-         xp = x - x_msk;
-         yp = y - y_msk;
-         xs = x - x_srf;
-         ys = y - y_srf;
-
-         pixel = *(BPIXEL(sp, x, y, src_stride));
-
-         if ((xp >= 0) && (xp < msk_width) &&
-             (yp >= 0) && (yp < msk_height) &&
-             (xs >= 0) && (xs < srf_width) &&
-             (ys >= 0) && (ys < srf_height))
-           {
-              pxa = *(BPIXEL(mp, xp, yp, msk_stride));
-              pxb = *(BPIXEL(fp, xs, ys, srf_stride));
-              if (pxa != 0)
-                {
-                    a = MEDPIXEL((pixel >> 24) & 0xFF,
-                                 (pxa >> 24) & 0xFF, (pxb >> 24) & 0xFF);
-                    r = MEDPIXEL((pixel >> 16) & 0xFF,
-                                 (pxa >> 16) & 0xFF, (pxb >> 16) & 0xFF);
-                    g = MEDPIXEL((pixel >> 8) & 0xFF,
-                                 (pxa >> 8) & 0xFF, (pxb >> 8) & 0xFF);
-                    b = MEDPIXEL(pixel & 0xFF, pxa & 0xFF, pxb & 0xFF);
-                    pixel = (a << 24) | (r << 16) | (g << 8) | b;
-                }
-            }
+     {
+       int x;
 
-         *(BPIXEL(dp, x, y, src_stride)) = pixel;
-       }
+       for (x = 0; x < src_width; x++)
+         {
+            int xp, yp, xs, ys;
+            DATA32 pixel;
+
+            xp = x - x_msk;
+            yp = y - y_msk;
+            xs = x - x_srf;
+            ys = y - y_srf;
+
+            pixel = *(BPIXEL(src, x, y, src_stride));
+
+            if ((xp >= 0) && (xp < msk_width) &&
+                (yp >= 0) && (yp < msk_height) &&
+                (xs >= 0) && (xs < srf_width) &&
+                (ys >= 0) && (ys < srf_height))
+              {
+                 DATA32 pxa, pxb;
+
+                 pxa = *(BPIXEL(msk, xp, yp, msk_stride));
+                 pxb = *(BPIXEL(srf, xs, ys, srf_stride));
+                 if (pxa != 0)
+                   {
+                      int r, g, b, a;
+
+                      a = MEDPIXEL((pixel >> 24) & 0xFF,
+                                   (pxa >> 24) & 0xFF, (pxb >> 24) & 0xFF);
+                      r = MEDPIXEL((pixel >> 16) & 0xFF,
+                                   (pxa >> 16) & 0xFF, (pxb >> 16) & 0xFF);
+                      g = MEDPIXEL((pixel >> 8) & 0xFF,
+                                   (pxa >> 8) & 0xFF, (pxb >> 8) & 0xFF);
+                      b = MEDPIXEL(pixel & 0xFF, pxa & 0xFF, pxb & 0xFF);
+                      pixel = (a << 24) | (r << 16) | (g << 8) | b;
+                   }
+              }
+
+            *(BPIXEL(dst, x, y, src_stride)) = pixel;
+         }
+     }
 }
 
-
 int
 evas_object_image_mask_fill(Evas_Object *src, Evas_Object *mask, Evas_Object 
*surface, int x_mask, int y_mask, int x_surface, int y_surface)
 {
    int alloc_size;
    unsigned char has_alpha;
-   char *src_data;
-   char *msk_data;
-   char *srf_data;
-   char *new_buffer;
+   void *src_data, *msk_data, *srf_data, *new_buffer;
    int src_stride, src_width, src_height;
    int msk_stride, msk_width, msk_height;
    int srf_stride, srf_width, srf_height;
@@ -77,10 +78,15 @@
 
    evas_object_image_size_get(src, &src_width, &src_height);
    src_stride = evas_object_image_stride_get(src);
+   src_data = evas_object_image_data_get(src, 0);
+
    evas_object_image_size_get(mask, &msk_width, &msk_height);
    msk_stride = evas_object_image_stride_get(mask);
+   msk_data = evas_object_image_data_get(mask, 0);
+
    evas_object_image_size_get(surface, &srf_width, &srf_height);
    srf_stride = evas_object_image_stride_get(surface);
+   srf_data = evas_object_image_data_get(surface, 0);
 
    has_alpha = evas_object_image_alpha_get(src);
 
@@ -91,10 +97,6 @@
         new_buffer = malloc(alloc_size);
         if (!new_buffer)
           return 3;
-
-        src_data = evas_object_image_data_get(src, 0);
-        msk_data = evas_object_image_data_get(mask, 0);
-        srf_data = evas_object_image_data_get(surface, 0);
 
         _argb8888_image_mask_fill(new_buffer, src_data, msk_data,
                                   srf_data, x_mask, y_mask,



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to