Evas gl_x11: Fix abort() in evas_object_image_data_get()
authorJean-Philippe Andre <jp.andre@samsung.com>
Tue, 22 Apr 2014 08:12:02 +0000 (17:12 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Tue, 22 Apr 2014 08:46:30 +0000 (17:46 +0900)
Since the introduction of new colorspaces for GL_X11
(GRY8, AGRY88 and ETC1), stride_get() would return
an invalid value and data_get() would just abort().

Add proper support for these functions.
ETC1 data will NOT be returned from data_get() and
stride_get() will return 0. This is to avoid people from
messing up badly with encoded color spaces.

src/modules/evas/engines/gl_x11/evas_engine.c

index 490fad7..bac2557 100644 (file)
@@ -2832,6 +2832,8 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, i
    switch (im->cs.space)
      {
       case EVAS_COLORSPACE_ARGB8888:
+      case EVAS_COLORSPACE_AGRY88:
+      case EVAS_COLORSPACE_GRY8:
          if (to_write)
            {
               if (im->references > 1)
@@ -2864,6 +2866,11 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, i
       case EVAS_COLORSPACE_YCBCR420TM12601_PL:
          *image_data = im->cs.data;
          break;
+      case EVAS_COLORSPACE_ETC1:
+         ERR("This image is encoded in ETC1, not returning any data");
+         *err = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
+         *image_data = NULL;
+         break;
       default:
          abort();
          break;
@@ -3213,7 +3220,24 @@ eng_image_stride_get(void *data EINA_UNUSED, void *image, int *stride)
    if ((im->tex) && (im->tex->pt->dyn.img))
      *stride = im->tex->pt->dyn.stride;
    else
-     *stride = im->w * 4;
+     {
+        switch (im->cs.space)
+          {
+           case EVAS_COLORSPACE_ARGB8888:
+             *stride = im->w * 4;
+             return;
+           case EVAS_COLORSPACE_AGRY88:
+             *stride = im->w * 2;
+             return;
+           case EVAS_COLORSPACE_GRY8:
+             *stride = im->w * 1;
+             return;
+           default:
+             ERR("Requested stride on an invalid format %d", im->cs.space);
+             *stride = 0;
+             return;
+          }
+     }
 }
 
 static Eina_Bool