lean down memory usage per process - now it doesnt use up 64kb it doesnt need
authorCarsten Haitzler <raster@rasterman.com>
Mon, 10 May 2004 06:40:51 +0000 (06:40 +0000)
committerCarsten Haitzler <raster@rasterman.com>
Mon, 10 May 2004 06:40:51 +0000 (06:40 +0000)
to... :)

SVN revision: 10153

legacy/evas/src/lib/engines/common/evas_blend_alpha_color_pixel.c
legacy/evas/src/lib/engines/common/evas_blend_color_pixel.c
legacy/evas/src/lib/engines/common/evas_blend_main.c
legacy/evas/src/lib/engines/common/evas_blend_ops.h
legacy/evas/src/lib/engines/common/evas_blend_pixel_cmod_pixel.c
legacy/evas/src/lib/engines/common/evas_blend_pixel_mul_pixel.c
legacy/evas/src/lib/engines/common/evas_blend_pixel_pixel.c
legacy/evas/src/lib/engines/common/evas_draw_main.c
legacy/evas/src/lib/engines/common/evas_line_main.c
legacy/evas/src/lib/engines/common/evas_scale_smooth.c
legacy/evas/src/lib/include/evas_common.h

index 0347481..fb741dc 100644 (file)
@@ -4,7 +4,7 @@
 #include "evas_mmx.h"
 #endif
 
-extern DATA8        _evas_pow_lut[256][256];
+extern DATA8        *_evas_pow_lut;
 extern const DATA16 _evas_const_c1[4];
 
 #ifdef BUILD_C
@@ -158,7 +158,7 @@ evas_common_blend_alpha_color_rgba_to_rgba_c (DATA8 *src, DATA32 *dst, int len,
             *dst_ptr = col;
             break;
           default:
-            a = _evas_pow_lut[aa][A_VAL(dst_ptr)];
+            a = _evas_pow_lut[(aa << 8) | A_VAL(dst_ptr)];
             BLEND_COLOR(aa, A_VAL(dst_ptr), 
                       255, A_VAL(dst_ptr), 
                       tmp);
index d4c81e9..9259696 100644 (file)
@@ -4,7 +4,7 @@
 #include "evas_mmx.h"
 #endif
 
-extern DATA8        _evas_pow_lut[256][256];
+extern DATA8       *_evas_pow_lut;
 extern const DATA16 _evas_const_c1[4];
 
 #ifdef BUILD_C
@@ -94,7 +94,7 @@ evas_common_blend_color_rgba_to_rgba_c(DATA32 src, DATA32 *dst, int len)
        DATA32 tmp;
        DATA8  a;
        
-       a = _evas_pow_lut[A_VAL(&src)][A_VAL(dst_ptr)];
+       a = _evas_pow_lut[(A_VAL(&src) << 8) | A_VAL(dst_ptr)];
        
        BLEND_COLOR(A_VAL(&src), A_VAL(dst_ptr), 
                    255, A_VAL(dst_ptr), 
index a9d9f8f..3877180 100644 (file)
@@ -4,9 +4,7 @@
 #include "evas_mmx.h"
 #endif
 
-static void evas_blend_init_evas_pow_lut(void);
-
-DATA8        _evas_pow_lut[256][256];
+DATA8       *_evas_pow_lut = NULL;
 const DATA16 _evas_const_c1[4]       = {1, 1, 1, 1};
 
 void
@@ -22,14 +20,16 @@ evas_common_blend_init(void)
    
    evas_common_cpu_can_do(&mmx, &sse, &sse2);
    
-   evas_blend_init_evas_pow_lut();
+/*   evas_common_blend_init_evas_pow_lut(); */
 }
 
 void
-evas_blend_init_evas_pow_lut(void)
+evas_common_blend_init_evas_pow_lut(void)
 {
    int i, j;
-   
+
+   _evas_pow_lut = malloc(256 * 256);
+   if (!_evas_pow_lut) return;
    for (i = 0; i < 256; i++)
      {
        for (j = 0; j < 256; j++)
@@ -37,8 +37,8 @@ evas_blend_init_evas_pow_lut(void)
             int divisor;
             
             divisor = (i + (j * (255 - i)) / 255);
-            if (divisor > 0) _evas_pow_lut[i][j] = (i * 255) / divisor;
-            else             _evas_pow_lut[i][j] = 0;
+            if (divisor > 0) _evas_pow_lut[(i << 8) | j] = (i * 255) / divisor;
+            else             _evas_pow_lut[(i << 8) | j] = 0;
          }
      }
 }
index fb41836..cfc0ed1 100644 (file)
@@ -8,7 +8,7 @@
 \
    if (A_VAL(src)) /* hmmm - do we need this? */ \
      { \
-       __a = _evas_pow_lut[A_VAL(src)][A_VAL(dst)]; \
+       __a = _evas_pow_lut[(A_VAL(src) << 8) | A_VAL(dst)]; \
        BLEND_COLOR(A_VAL(src), A_VAL(dst), \
                    255, A_VAL(dst), \
                    __tmp); \
index 9b5cc02..aee9dfd 100644 (file)
@@ -4,7 +4,7 @@
 #include "evas_mmx.h"
 #endif
 
-extern DATA8        _evas_pow_lut[256][256];
+extern DATA8       *_evas_pow_lut;
 extern const DATA16 _evas_const_c1[4];
 
 void
@@ -77,7 +77,7 @@ evas_common_blend_pixels_cmod_rgba_to_rgba_c(DATA32 *src, DATA32 *dst, int len,
             B_VAL(dst_ptr) = bmod[B_VAL(src_ptr)];
             break;
           default:
-            a = _evas_pow_lut[aa][A_VAL(dst_ptr)];
+            a = _evas_pow_lut[(aa << 8) | A_VAL(dst_ptr)];
             BLEND_COLOR(aa,A_VAL(dst_ptr),
                       255,A_VAL(dst_ptr),tmp);
             BLEND_COLOR(a, R_VAL(dst_ptr), 
index 6c31b30..d152b95 100644 (file)
@@ -4,7 +4,7 @@
 #include "evas_mmx.h"
 #endif
 
-extern DATA8        _evas_pow_lut[256][256];
+extern DATA8       *_evas_pow_lut;
 extern const DATA16 _evas_const_c1[4];
 
 #ifdef BUILD_C
@@ -200,7 +200,7 @@ evas_common_blend_pixels_mul_color_rgba_to_rgba_c(DATA32 *src, DATA32 *dst, int
                  *dst_ptr = *src_ptr;
                  break;
                default:
-                 a = _evas_pow_lut[aa][A_VAL(dst_ptr)];
+                 a = _evas_pow_lut[(aa << 8) | A_VAL(dst_ptr)];
                  
                  BLEND_COLOR(aa, A_VAL(dst_ptr),
                                255, A_VAL(dst_ptr),
@@ -239,7 +239,7 @@ evas_common_blend_pixels_mul_color_rgba_to_rgba_c(DATA32 *src, DATA32 *dst, int
                  B_VAL(dst_ptr) = ((B_VAL(src_ptr) * (B_VAL(&mul_color) + 1)) >> 8);
                  break;
                default:
-                 a = _evas_pow_lut[aa][A_VAL(dst_ptr)];
+                 a = _evas_pow_lut[(aa << 8) | A_VAL(dst_ptr)];
                  
                  BLEND_COLOR(aa, A_VAL(dst_ptr),
                                255, A_VAL(dst_ptr),
index 4d7163c..2b6f31a 100644 (file)
@@ -4,7 +4,7 @@
 #include "evas_mmx.h"
 #endif
 
-extern DATA8        _evas_pow_lut[256][256];
+extern DATA8       *_evas_pow_lut;
 extern const DATA16 _evas_const_c1[4];
 
 #ifdef BUILD_C
@@ -125,7 +125,7 @@ evas_common_blend_pixels_rgba_to_rgba_c(DATA32 *src, DATA32 *dst, int len)
             *dst_ptr = *src_ptr;
             break;
           default:
-            a = _evas_pow_lut[aa][A_VAL(dst_ptr)];
+            a = _evas_pow_lut[(aa << 8) | A_VAL(dst_ptr)];
             
             BLEND_COLOR(aa, A_VAL(dst_ptr), 
                         255, A_VAL(dst_ptr), 
index d71da09..c27f44e 100644 (file)
@@ -1,5 +1,7 @@
 #include "evas_common.h"
 
+extern DATA8        *_evas_pow_lut;
+
 void
 evas_common_draw_init(void)
 {
@@ -565,6 +567,7 @@ evas_common_draw_func_blend_color_get(DATA32 src, RGBA_Image *dst, int pixels)
      {
        if (dst->flags & RGBA_IMAGE_HAS_ALPHA)
          {
+            if (!_evas_pow_lut) evas_common_blend_init_evas_pow_lut();
             return evas_common_blend_color_rgba_to_rgba_c;
          }
        else
@@ -585,6 +588,7 @@ evas_common_draw_func_blend_color_get(DATA32 src, RGBA_Image *dst, int pixels)
      {
        if (dst->flags & RGBA_IMAGE_HAS_ALPHA)
          {
+            if (!_evas_pow_lut) evas_common_blend_init_evas_pow_lut();
             return evas_common_copy_color_rgb_to_rgba_c;
          }
        else
@@ -619,6 +623,7 @@ evas_common_draw_func_blend_cmod_get(RGBA_Image *src, RGBA_Image *dst, int pixel
      {
        if (dst->flags & RGBA_IMAGE_HAS_ALPHA)
          {
+            if (!_evas_pow_lut) evas_common_blend_init_evas_pow_lut();
             return evas_common_blend_pixels_cmod_rgba_to_rgba_c;
          }
        else
@@ -630,6 +635,7 @@ evas_common_draw_func_blend_cmod_get(RGBA_Image *src, RGBA_Image *dst, int pixel
      {
        if (dst->flags & RGBA_IMAGE_HAS_ALPHA)
          {
+            if (!_evas_pow_lut) evas_common_blend_init_evas_pow_lut();
             return evas_common_copy_pixels_cmod_rgb_to_rgba_c;
          }
        else
@@ -648,6 +654,7 @@ evas_common_draw_func_blend_mul_get(RGBA_Image *src, DATA32 col, RGBA_Image *dst
      {
        if (dst->flags & RGBA_IMAGE_HAS_ALPHA)
          {
+            if (!_evas_pow_lut) evas_common_blend_init_evas_pow_lut();
             return evas_common_blend_pixels_mul_color_rgba_to_rgba_c;
          }
        else
@@ -668,6 +675,7 @@ evas_common_draw_func_blend_mul_get(RGBA_Image *src, DATA32 col, RGBA_Image *dst
      {
        if (dst->flags & RGBA_IMAGE_HAS_ALPHA)
          {
+            if (!_evas_pow_lut) evas_common_blend_init_evas_pow_lut();
             return evas_common_blend_pixels_mul_color_rgba_to_rgba_c;
          }
        else
@@ -694,6 +702,7 @@ evas_common_draw_func_blend_alpha_get(RGBA_Image *dst)
 {
    if (dst->flags & RGBA_IMAGE_HAS_ALPHA)
      {
+       if (!_evas_pow_lut) evas_common_blend_init_evas_pow_lut();
        return evas_common_blend_alpha_color_rgba_to_rgba_c;
      }
    else
index 92ab415..3e61e40 100644 (file)
@@ -1,6 +1,6 @@
 #include "evas_common.h"
 
-extern DATA8        _evas_pow_lut[256][256];
+extern DATA8       *_evas_pow_lut;
 
 void
 evas_common_line_init(void)
@@ -54,7 +54,7 @@ evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x1, int y1, in
             DATA8  __blend_a;                                  
             
             ptr = dst->image->data + (y1 * dst->image->w) + x1;
-            __blend_a = _evas_pow_lut[A_VAL(&(col))][A_VAL(ptr)]; 
+            __blend_a = _evas_pow_lut[(A_VAL(&(col)) << 8) | A_VAL(ptr)]; 
             
             BLEND_COLOR(A_VAL(&(col)), A_VAL(ptr), 
                         255, A_VAL(ptr), 
@@ -133,6 +133,7 @@ evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x1, int y1, in
    y = y1;
    if (dst->flags & RGBA_IMAGE_HAS_ALPHA)
      {
+       if (!_evas_pow_lut) evas_common_blend_init_evas_pow_lut();
        if (ax > ay)
          {
             d = ay - (ax >> 1);
@@ -146,7 +147,7 @@ evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x1, int y1, in
                            DATA32 __blend_tmp;                       
                            DATA8  __blend_a;                                  
                            
-                           __blend_a = _evas_pow_lut[A_VAL(&(col))][A_VAL(ptr)]; 
+                           __blend_a = _evas_pow_lut[(A_VAL(&(col)) << 8) | A_VAL(ptr)]; 
                            
                            BLEND_COLOR(A_VAL(&(col)), A_VAL(ptr), 
                                        255, A_VAL(ptr), 
@@ -185,7 +186,7 @@ evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x1, int y1, in
                            DATA32 __blend_tmp;                       
                            DATA8  __blend_a;                                  
                            
-                           __blend_a = _evas_pow_lut[A_VAL(&(col))][A_VAL(ptr)]; 
+                           __blend_a = _evas_pow_lut[(A_VAL(&(col)) << 8) | A_VAL(ptr)]; 
                            
                            BLEND_COLOR(A_VAL(&(col)), A_VAL(ptr), 
                                        255, A_VAL(ptr), 
index 7766ce1..4a1e644 100644 (file)
@@ -5,7 +5,6 @@
 
 #include "evas_blend_ops.h"
 
-extern DATA8        _evas_pow_lut[256][256];
 extern const DATA16 _evas_const_c1[4];
 
 static DATA32 **scale_calc_y_points(DATA32 *src, int sw, int sh, int dh);
index 9449424..e5e9ff8 100644 (file)
@@ -627,7 +627,8 @@ void evas_common_cpu_end_opt                            (void);
     
 /****/
 void evas_common_blend_init                             (void);
-
+void evas_common_blend_init_evas_pow_lut                (void);
+   
 void evas_common_blend_pixels_rgba_to_rgb_c             (DATA32 *src, DATA32 *dst, int len);
 void evas_common_blend_pixels_rgba_to_rgb_mmx           (DATA32 *src, DATA32 *dst, int len);
 void evas_common_blend_pixels_rgba_to_rgba_c            (DATA32 *src, DATA32 *dst, int len);