From: Rajeev Ranjan <rajeev.r@samsung.com>
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 13 May 2012 04:24:28 +0000 (04:24 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 13 May 2012 04:24:28 +0000 (04:24 +0000)
Subject: [E-devel] [PATCH][EDJE] Patch to remove the alpha from image
header while saving if the alpha is set to 1 but the image is fully
opaque

Attached to the mail is a patch to set the alpha information for an
image header to 0 with alpha present but all the texels being opaque.
Continuing to our discussion, as suggested by many people in the
community it has been implemented at edje_cc level.

Change description:
    While compiling the edc file, image data for image files is
scanned to find out whether the alpha value in header is set to 1 and
is not being used in the image.
  If this is the case, while writing to eet the alpha is set to 0 to
avoid blending for such images in the graphics pipeline when used by
evas.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@70954 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

AUTHORS
ChangeLog
src/bin/edje_cc_out.c

diff --git a/AUTHORS b/AUTHORS
index 3377d78..34ce0fa 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -23,3 +23,4 @@ Prince Kumar Dubey <prince.dubey@samsung.com> <prince.dubey@gmail.com>
 David Seikel <onefang at gmail.com>
 Mikael Sans <sans.mikael@gmail.com>
 Jérôme Pinot <ngc891@gmail.com>
+Rajeev Ranjan (Rajeev) <rajeev.r@samsung.com> <rajeev.jnnce@gmail.com>
index 59e6842..5fc6a4d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 2012-05-10  Cedric Bail
 
        * Preserve user box and table items during call of edje_object_file_set.
+
+2012-04-30  Rajeev Ranjan (Rajeev)
+
+       * Add edje_cc optimization to remove alpha channel flag from images
+        with absolutely no alpha in them if marked as havin alpha in the
+        originals
+
index f3b4358..fe72c5e 100644 (file)
@@ -566,6 +566,8 @@ data_write_images(Eet_File *ef, int *image_num, int *input_bytes, int *input_raw
                       int  im_w, im_h;
                       int  im_alpha;
                       char buf[256];
+                      unsigned int  *start, *end;
+                      Eina_Bool opaque = EINA_TRUE;
 
                       evas_object_image_size_get(im, &im_w, &im_h);
                       im_alpha = evas_object_image_alpha_get(im);
@@ -605,6 +607,21 @@ data_write_images(Eet_File *ef, int *image_num, int *input_bytes, int *input_raw
                                 if (qual < min_quality) qual = min_quality;
                                 if (qual > max_quality) qual = max_quality;
                              }
+                           if (im_alpha)
+                             {
+                                start = (unsigned int *) im_data;
+                                end = start + (im_w * im_h);
+                                while (start < end)
+                                  {
+                                     if ((*start & 0xff000000) != 0xff000000)
+                                       {
+                                          opaque = EINA_FALSE;
+                                          break;
+                                       }
+                                     start++;
+                                  }
+                                if (opaque) im_alpha = 0;
+                             }
                            if (mode == 0)
                              bytes = eet_data_image_write(ef, buf,
                                                           im_data, im_w, im_h,