Thanks! And again, sorry for the DOS newlines. I'll blame Gnus for that.

On Mon, Feb 18, 2013 at 1:18 PM, Enlightenment SVN
<no-re...@enlightenment.org> wrote:
> Log:
> evas/engines: Introduce pixel_alpha_get()
>
>   The _pixel_alpha_get() function used in evas_object_image_is_inside won't
>   work with engines other than software - since it relies on engine data
>   being *always* RGBA_Image * - which is wrong for OpenGL backend that uses
>   Evas_GL_Image * for "engine_data" pointer.
>
>   NOTE: Backported from upstream.
>
>   Signed-off-by: Paulo C. A. Cavalcanti Jr <paulo.cavalca...@intel.com>
>
>   Patch by: "Paulo C. A. Cavalcanti Jr" <paulo.cavalca...@intel.com>
>
>
>
> Author:       sachiel
> Date:         2013-02-18 08:18:17 -0800 (Mon, 18 Feb 2013)
> New Revision: 84067
> Trac:         http://trac.enlightenment.org/e/changeset/84067
>
> Modified:
>   branches/evas-1.7/src/lib/canvas/evas_object_image.c 
> branches/evas-1.7/src/lib/include/evas_private.h 
> branches/evas-1.7/src/modules/engines/gl_x11/evas_engine.c 
> branches/evas-1.7/src/modules/engines/software_generic/evas_engine.c
>
> Modified: branches/evas-1.7/src/lib/canvas/evas_object_image.c
> ===================================================================
> --- branches/evas-1.7/src/lib/canvas/evas_object_image.c        2013-02-18 
> 16:07:30 UTC (rev 84066)
> +++ branches/evas-1.7/src/lib/canvas/evas_object_image.c        2013-02-18 
> 16:18:17 UTC (rev 84067)
> @@ -3631,83 +3631,13 @@
>     return 1;
>  }
>
> -static inline Eina_Bool
> -_pixel_alpha_get(RGBA_Image *im, int x, int y, DATA8 *alpha,
> -                 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 px, py, dx, dy, sx, sy, src_w, src_h;
> -   double scale_w, scale_h;
> -
> -   if ((dst_region_x > x) || (x >= (dst_region_x + dst_region_w)) ||
> -       (dst_region_y > y) || (y >= (dst_region_y + dst_region_h)))
> -     {
> -        *alpha = 0;
> -        return EINA_FALSE;
> -     }
> -
> -   src_w = im->cache_entry.w;
> -   src_h = im->cache_entry.h;
> -   if ((src_w == 0) || (src_h == 0))
> -     {
> -        *alpha = 0;
> -        return EINA_TRUE;
> -     }
> -
> -   EINA_SAFETY_ON_TRUE_GOTO(src_region_x < 0, error_oob);
> -   EINA_SAFETY_ON_TRUE_GOTO(src_region_y < 0, error_oob);
> -   EINA_SAFETY_ON_TRUE_GOTO(src_region_x + src_region_w > src_w, error_oob);
> -   EINA_SAFETY_ON_TRUE_GOTO(src_region_y + src_region_h > src_h, error_oob);
> -
> -   scale_w = (double)dst_region_w / (double)src_region_w;
> -   scale_h = (double)dst_region_h / (double)src_region_h;
> -
> -   /* point at destination */
> -   dx = x - dst_region_x;
> -   dy = y - dst_region_y;
> -
> -   /* point at source */
> -   sx = dx / scale_w;
> -   sy = dy / scale_h;
> -
> -   /* pixel point (translated) */
> -   px = src_region_x + sx;
> -   py = src_region_y + sy;
> -   EINA_SAFETY_ON_TRUE_GOTO(px >= src_w, error_oob);
> -   EINA_SAFETY_ON_TRUE_GOTO(py >= src_h, error_oob);
> -
> -   switch (im->cache_entry.space)
> -     {
> -     case EVAS_COLORSPACE_ARGB8888:
> -       {
> -          DATA32 *pixel = im->image.data;
> -          pixel += ((py * src_w) + px);
> -          *alpha = ((*pixel) >> 24) & 0xff;
> -       }
> -       break;
> -
> -     default:
> -        ERR("Colorspace %d not supported.", im->cache_entry.space);
> -        *alpha = 0;
> -     }
> -
> -   return EINA_TRUE;
> -
> - error_oob:
> -   ERR("Invalid region src=(%d, %d, %d, %d), dst=(%d, %d, %d, %d), 
> image=%dx%d",
> -       src_region_x, src_region_y, src_region_w, src_region_h,
> -       dst_region_x, dst_region_y, dst_region_w, dst_region_h,
> -       src_w, src_h);
> -   *alpha = 0;
> -   return EINA_TRUE;
> -}
> -
>  static int
>  evas_object_image_is_inside(Evas_Object *obj, Evas_Coord px, Evas_Coord py)
>  {
>     Evas_Object_Image *o;
>     int imagew, imageh, uvw, uvh;
>     void *pixels;
> +   Evas_Func *eng = obj->layer->evas->engine.func;
>     int is_inside = 0;
>
>     /* the following code is similar to evas_object_image_render(), but 
> doesn't
> @@ -3778,7 +3708,7 @@
>            }
>          else
>            {
> -             RGBA_Image *im;
> +             void *im;
>               DATA32 *data = NULL;
>               int err = 0;
>
> @@ -3786,7 +3716,8 @@
>                 (obj->layer->evas->engine.data.output, pixels, 0, &data, 
> &err);
>               if ((!im) || (!data) || (err))
>                 {
> -                  ERR("Couldn't get image pixels RGBA_Image %p: im=%p, 
> data=%p, err=%d", pixels, im, data, err);
> +                  ERR("Couldn't get image pixels %p: im=%p, data=%p, err=%d",
> +                      pixels, im, data, err);
>                    goto end;
>                 }
>
> @@ -3834,7 +3765,13 @@
>                               */
>                                {
>                                   DATA8 alpha = 0;
> -                                 if (_pixel_alpha_get(pixels, px, py, 
> &alpha, 0, 0, imagew, imageh, obj->cur.geometry.x + ix, obj->cur.geometry.y + 
> iy, iw, ih))
> +
> +                                 if (eng->pixel_alpha_get(pixels, px, py, 
> &alpha,
> +                                                          0, 0,
> +                                                          imagew, imageh,
> +                                                          
> obj->cur.geometry.x + ix,
> +                                                          
> obj->cur.geometry.y + iy,
> +                                                          iw, ih))
>                                     {
>                                        is_inside = alpha > 0;
>                                        dobreak_h = 1;
> @@ -3895,7 +3832,9 @@
>                              inw = bl; inh = bt;
>                              outx = ox; outy = oy;
>                              outw = bsl; outh = bst;
> -                            if (_pixel_alpha_get(pixels, px, py, &alpha, 
> inx, iny, inw, inh, outx, outy, outw, outh))
> +                            if (eng->pixel_alpha_get(pixels, px, py, &alpha,
> +                                                     inx, iny, inw, inh,
> +                                                     outx, outy, outw, outh))
>                                {
>                                   is_inside = alpha > 0;
>                                   dobreak_h = 1;
> @@ -3909,7 +3848,9 @@
>                              inw = imw - bl - br; inh = bt;
>                              outx = ox + bsl; outy = oy;
>                              outw = iw - bsl - bsr; outh = bst;
> -                            if (_pixel_alpha_get(pixels, px, py, &alpha, 
> inx, iny, inw, inh, outx, outy, outw, outh))
> +                            if (eng->pixel_alpha_get(pixels, px, py, &alpha,
> +                                                     inx, iny, inw, inh,
> +                                                     outx, outy, outw, outh))
>                                {
>                                   is_inside = alpha > 0;
>                                   dobreak_h = 1;
> @@ -3922,7 +3863,9 @@
>                              inw = br; inh = bt;
>                              outx = ox + iw - bsr; outy = oy;
>                              outw = bsr; outh = bst;
> -                            if (_pixel_alpha_get(pixels, px, py, &alpha, 
> inx, iny, inw, inh, outx, outy, outw, outh))
> +                            if (eng->pixel_alpha_get(pixels, px, py, &alpha,
> +                                                     inx, iny, inw, inh,
> +                                                     outx, outy, outw, outh))
>                                {
>                                   is_inside = alpha > 0;
>                                   dobreak_h = 1;
> @@ -3930,12 +3873,14 @@
>                                   break;
>                                }
>                              // .--
> -                            // #
> +                            // #
>                              inx = 0; iny = bt;
>                              inw = bl; inh = imh - bt - bb;
>                              outx = ox; outy = oy + bst;
>                              outw = bsl; outh = ih - bst - bsb;
> -                            if (_pixel_alpha_get(pixels, px, py, &alpha, 
> inx, iny, inw, inh, outx, outy, outw, outh))
> +                            if (eng->pixel_alpha_get(pixels, px, py, &alpha,
> +                                                     inx, iny, inw, inh,
> +                                                     outx, outy, outw, outh))
>                                {
>                                   is_inside = alpha > 0;
>                                   dobreak_h = 1;
> @@ -3950,7 +3895,9 @@
>                                   inw = imw - bl - br; inh = imh - bt - bb;
>                                   outx = ox + bsl; outy = oy + bst;
>                                   outw = iw - bsl - bsr; outh = ih - bst - 
> bsb;
> -                                 if (_pixel_alpha_get(pixels, px, py, 
> &alpha, inx, iny, inw, inh, outx, outy, outw, outh))
> +                                 if (eng->pixel_alpha_get(pixels, px, py, 
> &alpha,
> +                                                          inx, iny, inw, inh,
> +                                                          outx, outy, outw, 
> outh))
>                                     {
>                                        is_inside = alpha > 0;
>                                        dobreak_h = 1;
> @@ -3964,7 +3911,9 @@
>                              inw = br; inh = imh - bt - bb;
>                              outx = ox + iw - bsr; outy = oy + bst;
>                              outw = bsr; outh = ih - bst - bsb;
> -                            if (_pixel_alpha_get(pixels, px, py, &alpha, 
> inx, iny, inw, inh, outx, outy, outw, outh))
> +                            if (eng->pixel_alpha_get(pixels, px, py, &alpha,
> +                                                     inx, iny, inw, inh,
> +                                                     outx, outy, outw, outh))
>                                {
>                                   is_inside = alpha > 0;
>                                   dobreak_h = 1;
> @@ -3977,7 +3926,9 @@
>                              inw = bl; inh = bb;
>                              outx = ox; outy = oy + ih - bsb;
>                              outw = bsl; outh = bsb;
> -                            if (_pixel_alpha_get(pixels, px, py, &alpha, 
> inx, iny, inw, inh, outx, outy, outw, outh))
> +                            if (eng->pixel_alpha_get(pixels, px, py, &alpha,
> +                                                     inx, iny, inw, inh,
> +                                                     outx, outy, outw, outh))
>                                {
>                                   is_inside = alpha > 0;
>                                   dobreak_h = 1;
> @@ -3985,12 +3936,14 @@
>                                   break;
>                                }
>                              // |
> -                            // .##
> +                            // .##
>                              inx = bl; iny = imh - bb;
>                              inw = imw - bl - br; inh = bb;
>                              outx = ox + bsl; outy = oy + ih - bsb;
>                              outw = iw - bsl - bsr; outh = bsb;
> -                            if (_pixel_alpha_get(pixels, px, py, &alpha, 
> inx, iny, inw, inh, outx, outy, outw, outh))
> +                            if (eng->pixel_alpha_get(pixels, px, py, &alpha,
> +                                                     inx, iny, inw, inh,
> +                                                     outx, outy, outw, outh))
>                                {
>                                   is_inside = alpha > 0;
>                                   dobreak_h = 1;
> @@ -4003,7 +3956,9 @@
>                              inw = br; inh = bb;
>                              outx = ox + iw - bsr; outy = oy + ih - bsb;
>                              outw = bsr; outh = bsb;
> -                            if (_pixel_alpha_get(pixels, px, py, &alpha, 
> inx, iny, inw, inh, outx, outy, outw, outh))
> +                            if (eng->pixel_alpha_get(pixels, px, py, &alpha,
> +                                                     inx, iny, inw, inh,
> +                                                     outx, outy, outw, outh))
>                                {
>                                   is_inside = alpha > 0;
>                                   dobreak_h = 1;
>
> Modified: branches/evas-1.7/src/lib/include/evas_private.h
> ===================================================================
> --- branches/evas-1.7/src/lib/include/evas_private.h    2013-02-18 16:07:30 
> UTC (rev 84066)
> +++ branches/evas-1.7/src/lib/include/evas_private.h    2013-02-18 16:18:17 
> UTC (rev 84067)
> @@ -896,6 +896,8 @@
>
>     /* max size query */
>     void (*image_max_size_get)            (void *data, int *maxw, int *maxh);
> +
> +   Eina_Bool (*pixel_alpha_get)          (void *image, int x, int y, DATA8 
> *alpha, 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);
>  };
>
>  struct _Evas_Image_Load_Func
>
> Modified: branches/evas-1.7/src/modules/engines/gl_x11/evas_engine.c
> ===================================================================
> --- branches/evas-1.7/src/modules/engines/gl_x11/evas_engine.c  2013-02-18 
> 16:07:30 UTC (rev 84066)
> +++ branches/evas-1.7/src/modules/engines/gl_x11/evas_engine.c  2013-02-18 
> 16:18:17 UTC (rev 84067)
> @@ -4929,6 +4929,87 @@
>     if (maxh) *maxh = re->win->gl_context->shared->info.max_texture_size;
>  }
>
> +static Eina_Bool
> +eng_pixel_alpha_get(void *image, int x, int y, DATA8 *alpha, 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)
> +{
> +   Evas_GL_Image *im = image;
> +   int px, py, dx, dy, sx, sy, src_w, src_h;
> +   double scale_w, scale_h;
> +
> +   if (!im) return EINA_FALSE;
> +
> +   if ((dst_region_x > x) || (x >= (dst_region_x + dst_region_w)) ||
> +       (dst_region_y > y) || (y >= (dst_region_y + dst_region_h)))
> +     {
> +        *alpha = 0;
> +        return EINA_FALSE;
> +     }
> +
> +   src_w = im->im->cache_entry.w;
> +   src_h = im->im->cache_entry.h;
> +   if ((src_w == 0) || (src_h == 0))
> +     {
> +        *alpha = 0;
> +        return EINA_TRUE;
> +     }
> +
> +   EINA_SAFETY_ON_TRUE_GOTO(src_region_x < 0, error_oob);
> +   EINA_SAFETY_ON_TRUE_GOTO(src_region_y < 0, error_oob);
> +   EINA_SAFETY_ON_TRUE_GOTO(src_region_x + src_region_w > src_w, error_oob);
> +   EINA_SAFETY_ON_TRUE_GOTO(src_region_y + src_region_h > src_h, error_oob);
> +
> +   scale_w = (double)dst_region_w / (double)src_region_w;
> +   scale_h = (double)dst_region_h / (double)src_region_h;
> +
> +   /* point at destination */
> +   dx = x - dst_region_x;
> +   dy = y - dst_region_y;
> +
> +   /* point at source */
> +   sx = dx / scale_w;
> +   sy = dy / scale_h;
> +
> +   /* pixel point (translated) */
> +   px = src_region_x + sx;
> +   py = src_region_y + sy;
> +   EINA_SAFETY_ON_TRUE_GOTO(px >= src_w, error_oob);
> +   EINA_SAFETY_ON_TRUE_GOTO(py >= src_h, error_oob);
> +
> +   switch (im->im->cache_entry.space)
> +     {
> +     case EVAS_COLORSPACE_ARGB8888:
> +       {
> +          DATA32 *pixel;
> +
> +          evas_cache_image_load_data(&im->im->cache_entry);
> +          if (!im->im->cache_entry.flags.loaded)
> +            {
> +               ERR("im %p has no pixels loaded yet", im);
> +               return EINA_FALSE;
> +            }
> +
> +          pixel = im->im->image.data;
> +          pixel += ((py * src_w) + px);
> +          *alpha = ((*pixel) >> 24) & 0xff;
> +       }
> +       break;
> +
> +     default:
> +        ERR("Colorspace %d not supported.", im->im->cache_entry.space);
> +        *alpha = 0;
> +     }
> +
> +   return EINA_TRUE;
> +
> + error_oob:
> +   ERR("Invalid region src=(%d, %d, %d, %d), dst=(%d, %d, %d, %d), 
> image=%dx%d",
> +       src_region_x, src_region_y, src_region_w, src_region_h,
> +       dst_region_x, dst_region_y, dst_region_w, dst_region_h,
> +       src_w, src_h);
> +   *alpha = 0;
> +   return EINA_TRUE;
> +}
> +
>  static int
>  module_open(Evas_Module *em)
>  {
> @@ -5061,6 +5142,8 @@
>
>     ORD(image_max_size_get);
>
> +   ORD(pixel_alpha_get);
> +
>     /* now advertise out own api */
>     em->functions = (void *)(&func);
>     return 1;
>
> Modified: branches/evas-1.7/src/modules/engines/software_generic/evas_engine.c
> ===================================================================
> --- branches/evas-1.7/src/modules/engines/software_generic/evas_engine.c      
>   2013-02-18 16:07:30 UTC (rev 84066)
> +++ branches/evas-1.7/src/modules/engines/software_generic/evas_engine.c      
>   2013-02-18 16:18:17 UTC (rev 84067)
> @@ -1122,6 +1122,93 @@
>     return EINA_TRUE;
>  }
>
> +static Eina_Bool
> +eng_pixel_alpha_get(void *image, int x, int y, DATA8 *alpha, 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)
> +{
> +   RGBA_Image *im = image;
> +   int px, py, dx, dy, sx, sy, src_w, src_h;
> +   double scale_w, scale_h;
> +
> +   if (!im) return EINA_FALSE;
> +
> +   if ((dst_region_x > x) || (x >= (dst_region_x + dst_region_w)) ||
> +       (dst_region_y > y) || (y >= (dst_region_y + dst_region_h)))
> +     {
> +        *alpha = 0;
> +        return EINA_FALSE;
> +     }
> +
> +   src_w = im->cache_entry.w;
> +   src_h = im->cache_entry.h;
> +   if ((src_w == 0) || (src_h == 0))
> +     {
> +        *alpha = 0;
> +        return EINA_TRUE;
> +     }
> +
> +   EINA_SAFETY_ON_TRUE_GOTO(src_region_x < 0, error_oob);
> +   EINA_SAFETY_ON_TRUE_GOTO(src_region_y < 0, error_oob);
> +   EINA_SAFETY_ON_TRUE_GOTO(src_region_x + src_region_w > src_w, error_oob);
> +   EINA_SAFETY_ON_TRUE_GOTO(src_region_y + src_region_h > src_h, error_oob);
> +
> +   scale_w = (double)dst_region_w / (double)src_region_w;
> +   scale_h = (double)dst_region_h / (double)src_region_h;
> +
> +   /* point at destination */
> +   dx = x - dst_region_x;
> +   dy = y - dst_region_y;
> +
> +   /* point at source */
> +   sx = dx / scale_w;
> +   sy = dy / scale_h;
> +
> +   /* pixel point (translated) */
> +   px = src_region_x + sx;
> +   py = src_region_y + sy;
> +   EINA_SAFETY_ON_TRUE_GOTO(px >= src_w, error_oob);
> +   EINA_SAFETY_ON_TRUE_GOTO(py >= src_h, error_oob);
> +
> +   switch (im->cache_entry.space)
> +     {
> +     case EVAS_COLORSPACE_ARGB8888:
> +       {
> +          DATA32 *pixel;
> +
> +#if EVAS_CSERVE2
> +          if (evas_cserve2_use_get())
> +            evas_cache2_image_load_data(&im->cache_entry);
> +          else
> +#endif
> +            evas_cache_image_load_data(&im->cache_entry);
> +
> +          if (!im->cache_entry.flags.loaded)
> +            {
> +               ERR("im %p has no pixels loaded yet", im);
> +               return EINA_FALSE;
> +            }
> +
> +          pixel = im->image.data;
> +          pixel += ((py * src_w) + px);
> +          *alpha = ((*pixel) >> 24) & 0xff;
> +       }
> +       break;
> +
> +     default:
> +        ERR("Colorspace %d not supported.", im->cache_entry.space);
> +        *alpha = 0;
> +     }
> +
> +   return EINA_TRUE;
> +
> + error_oob:
> +   ERR("Invalid region src=(%d, %d, %d, %d), dst=(%d, %d, %d, %d), 
> image=%dx%d",
> +       src_region_x, src_region_y, src_region_w, src_region_h,
> +       dst_region_x, dst_region_y, dst_region_w, dst_region_h,
> +       src_w, src_h);
> +   *alpha = 0;
> +   return EINA_TRUE;
> +}
> +
>  static void
>  eng_image_cache_flush(void *data __UNUSED__)
>  {
> @@ -1879,7 +1966,8 @@
>       eng_image_animated_loop_count_get,
>       eng_image_animated_frame_duration_get,
>       eng_image_animated_frame_set,
> -     NULL
> +     NULL,
> +     eng_pixel_alpha_get,
>     /* FUTURE software generic calls go here */
>  };
>
>
>
> ------------------------------------------------------------------------------
> The Go Parallel Website, sponsored by Intel - in partnership with Geeknet,
> is your hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials, tech docs,
> whitepapers, evaluation guides, and opinion stories. Check out the most
> recent posts - join the conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> enlightenment-svn mailing list
> enlightenment-...@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-svn

------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, 
is your hub for all things parallel software development, from weekly thought 
leadership blogs to news, videos, case studies, tutorials, tech docs, 
whitepapers, evaluation guides, and opinion stories. Check out the most 
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to