Hi again,

I found a bug on the patch when using the 16 bits engine, and here is
a new fixed patch. The patch also fixes the documentation as described
by Gustavo. I tested it against software_x11 and software_16_x11
engines.

BR
Andrunko

On 7/11/07, Gustavo Sverzut Barbieri <[EMAIL PROTECTED]> wrote:
On 7/11/07, Andre Magalhaes <[EMAIL PROTECTED]> wrote:
> Hi again,
>
> So i wrote a new version of the patch supporting stride. The new patch
> adds a new public method evas_object_image_stride_get that returns the
> row stride of the image. In etk/ewl there are some places that make
> use of image_data directly as if it was a 32 bits ARGB data. These
> codes can be fixed by testing the cspace and using the row stride to
> get a certain pixel and the rgba component, but maybe it would be
> interesting to have some functions to get/set the rgba of a certain
> image pixel. This is not done in this patch, as i will wait for a
> review first.

IMHO it's fine now.

Just a minor notice about stride_get documentation, it's not the
number of bytes, but numer of units, so you have to multiply by unit
size, example in 16bpp: sizeof(DATA16) for color, sizeof(DATA8) for
alpha.

--
Gustavo Sverzut Barbieri
--------------------------------------
Jabber: [EMAIL PROTECTED]
   MSN: [EMAIL PROTECTED]
  ICQ#: 17249123
 Skype: gsbarbieri
Mobile: +55 (81) 9927 0010

Index: src/lib/Evas.h
===================================================================
RCS file: /var/cvs/e/e17/libs/evas/src/lib/Evas.h,v
retrieving revision 1.100
diff -u -3 -p -r1.100 Evas.h
--- src/lib/Evas.h      10 Jul 2007 00:13:25 -0000      1.100
+++ src/lib/Evas.h      12 Jul 2007 20:40:47 -0000
@@ -469,6 +469,7 @@ extern "C" {
    EAPI void              evas_object_image_fill_get        (Evas_Object *obj, 
Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
    EAPI void              evas_object_image_size_set        (Evas_Object *obj, 
int w, int h);
    EAPI void              evas_object_image_size_get        (Evas_Object *obj, 
int *w, int *h);
+   EAPI void              evas_object_image_stride_get      (Evas_Object *obj, 
int *stride);
    EAPI int               evas_object_image_load_error_get  (Evas_Object *obj);
    EAPI void              evas_object_image_data_set        (Evas_Object *obj, 
void *data);
    EAPI void             *evas_object_image_data_get        (Evas_Object *obj, 
Evas_Bool for_writing);
@@ -767,6 +768,9 @@ extern "C" {
    EAPI void              evas_object_propagate_events_set  (Evas_Object *obj, 
Evas_Bool prop);
    EAPI Evas_Bool         evas_object_propagate_events_get  (Evas_Object *obj);
        
+   EAPI void              evas_object_precise_is_inside_set (Evas_Object *obj, 
Evas_Bool precise);
+   EAPI Evas_Bool         evas_object_precise_is_inside_get (Evas_Object *obj);
+
    EAPI void              evas_object_event_callback_add    (Evas_Object *obj, 
Evas_Callback_Type type, void (*func) (void *data, Evas *e, Evas_Object *obj, 
void *event_info), const void *data);
    EAPI void             *evas_object_event_callback_del    (Evas_Object *obj, 
Evas_Callback_Type type, void (*func) (void *data, Evas *e, Evas_Object *obj, 
void *event_info));
 
Index: src/lib/canvas/evas_events.c
===================================================================
RCS file: /var/cvs/e/e17/libs/evas/src/lib/canvas/evas_events.c,v
retrieving revision 1.51
diff -u -3 -p -r1.51 evas_events.c
--- src/lib/canvas/evas_events.c        30 Apr 2007 04:22:42 -0000      1.51
+++ src/lib/canvas/evas_events.c        12 Jul 2007 20:40:47 -0000
@@ -57,7 +57,9 @@ _evas_event_object_list_in_get(Evas *e, 
                    }
                  else
                    {
-                      if (evas_object_is_in_output_rect(obj, x, y, 1, 1))
+                      if (evas_object_is_in_output_rect(obj, x, y, 1, 1) &&
+                          ((!obj->precise_is_inside) ||
+                           (evas_object_is_inside(obj, x, y))))
                         {
                            in = evas_list_append(in, obj);
                            if (!obj->repeat_events)
@@ -584,7 +586,9 @@ evas_event_feed_mouse_move(Evas *e, int 
                 (evas_object_clippers_is_visible(obj)) &&
                 (evas_list_find(ins, obj)) &&
                 (!evas_event_passes_through(obj)) &&
-                (!obj->clip.clipees))
+                (!obj->clip.clipees) &&
+                ((!obj->precise_is_inside) ||
+                 (evas_object_is_inside(obj, x, y))))
               {
                  if ((px != x) || (py != y))
                    {
@@ -989,7 +993,11 @@ evas_object_pass_events_set(Evas_Object 
    evas_object_smart_member_cache_invalidate(obj);
    if (evas_object_is_in_output_rect(obj,
                                     obj->layer->evas->pointer.x,
-                                    obj->layer->evas->pointer.y, 1, 1))
+                                    obj->layer->evas->pointer.y, 1, 1) &&
+       ((!obj->precise_is_inside) ||
+       (evas_object_is_inside(obj,
+                               obj->layer->evas->pointer.x,
+                               obj->layer->evas->pointer.y))))
      evas_event_feed_mouse_move(obj->layer->evas,
                                obj->layer->evas->pointer.x,
                                obj->layer->evas->pointer.y,
@@ -1036,7 +1044,11 @@ evas_object_repeat_events_set(Evas_Objec
    obj->repeat_events = repeat;
    if (evas_object_is_in_output_rect(obj,
                                     obj->layer->evas->pointer.x,
-                                    obj->layer->evas->pointer.y, 1, 1))
+                                    obj->layer->evas->pointer.y, 1, 1) &&
+       ((!obj->precise_is_inside) ||
+       (evas_object_is_inside(obj,
+                               obj->layer->evas->pointer.x,
+                               obj->layer->evas->pointer.y))))
      evas_event_feed_mouse_move(obj->layer->evas,
                                obj->layer->evas->pointer.x,
                                obj->layer->evas->pointer.y,
Index: src/lib/canvas/evas_object_image.c
===================================================================
RCS file: /var/cvs/e/e17/libs/evas/src/lib/canvas/evas_object_image.c,v
retrieving revision 1.53
diff -u -3 -p -r1.53 evas_object_image.c
--- src/lib/canvas/evas_object_image.c  10 Jul 2007 00:13:26 -0000      1.53
+++ src/lib/canvas/evas_object_image.c  12 Jul 2007 20:40:47 -0000
@@ -16,7 +16,7 @@ struct _Evas_Object_Image
         Evas_Coord  x, y, w, h;
       } fill;
       struct {
-        short       w, h;
+        short       w, h, stride;
       } image;
       struct {
         short         l, r, t, b;
@@ -67,6 +67,7 @@ static void evas_object_image_render_pos
 
 static int evas_object_image_is_opaque(Evas_Object *obj);
 static int evas_object_image_was_opaque(Evas_Object *obj);
+static int evas_object_image_is_inside(Evas_Object *obj, Evas_Coord x, 
Evas_Coord y);
 
 static const Evas_Object_Func object_func =
 {
@@ -82,7 +83,7 @@ static const Evas_Object_Func object_fun
      NULL,
      evas_object_image_is_opaque,
      evas_object_image_was_opaque,
-     NULL,
+     evas_object_image_is_inside,
      NULL,
      NULL
 };
@@ -241,15 +242,22 @@ evas_object_image_file_set(Evas_Object *
    if (o->engine_data)
      {
        int w, h;
+       int stride;
 
        
obj->layer->evas->engine.func->image_size_get(obj->layer->evas->engine.data.output,
                                                      o->engine_data, &w, &h);
+       if (obj->layer->evas->engine.func->image_stride_get)
+         
obj->layer->evas->engine.func->image_stride_get(obj->layer->evas->engine.data.output,
+                                                         o->engine_data, 
&stride);
+       else
+         stride = w;
        o->cur.has_alpha = 
obj->layer->evas->engine.func->image_alpha_get(obj->layer->evas->engine.data.output,
                                                                          
o->engine_data);
        o->cur.cspace = 
obj->layer->evas->engine.func->image_colorspace_get(obj->layer->evas->engine.data.output,
                                                                            
o->engine_data);
        o->cur.image.w = w;
        o->cur.image.h = h;
+       o->cur.image.stride = stride;
      }
    else
      {
@@ -258,6 +266,7 @@ evas_object_image_file_set(Evas_Object *
        o->cur.cspace = EVAS_COLORSPACE_ARGB8888;
        o->cur.image.w = 0;
        o->cur.image.h = 0;
+       o->cur.image.stride = 0;
      }
    o->changed = 1;
    evas_object_change(obj);
@@ -562,6 +571,7 @@ EAPI void
 evas_object_image_size_set(Evas_Object *obj, int w, int h)
 {
    Evas_Object_Image *o;
+   int stride;
 
    MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
    return;
@@ -586,6 +596,14 @@ evas_object_image_size_set(Evas_Object *
      o->engine_data = obj->layer->evas->engine.func->image_new_from_copied_data
      (obj->layer->evas->engine.data.output, w, h, NULL, o->cur.has_alpha,
       o->cur.cspace);
+
+   if (obj->layer->evas->engine.func->image_stride_get)
+     
obj->layer->evas->engine.func->image_stride_get(obj->layer->evas->engine.data.output,
+                                                    o->engine_data, &stride);
+   else
+     stride = w;
+   o->cur.image.stride = stride;
+
 /* FIXME - in engine call above
    if (o->engine_data)
      o->engine_data = 
obj->layer->evas->engine.func->image_alpha_set(obj->layer->evas->engine.data.output,
@@ -627,6 +645,30 @@ evas_object_image_size_get(Evas_Object *
 }
 
 /**
+ * Retrieves the row stride, which is the number of units between the start of 
a row and the start of the next row.
+ * @param   obj    The given image object.
+ * @param   stride A pointer to an integer in which to store the stride.  Can 
be
+ *                 @c NULL.
+ * @ingroup Evas_Object_Image_Size
+ */
+EAPI void
+evas_object_image_stride_get(Evas_Object *obj, int *stride)
+{
+   Evas_Object_Image *o;
+
+   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+   if (stride) *stride = 0;
+   return;
+   MAGIC_CHECK_END();
+   o = (Evas_Object_Image *)(obj->object_data);
+   MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
+   if (stride) *stride = 0;
+   return;
+   MAGIC_CHECK_END();
+   if (stride) *stride = o->cur.image.stride;
+}
+
+/**
  * Retrieves a number representing any error that occurred during the last
  * load for the given image object.
  * @param obj The given image object.
@@ -693,6 +735,7 @@ evas_object_image_data_set(Evas_Object *
        o->load_error = EVAS_LOAD_ERROR_NONE;
        o->cur.image.w = 0;
        o->cur.image.h = 0;
+       o->cur.image.stride = 0;
        o->engine_data = NULL;
      }
 /* FIXME - in engine call above
@@ -1643,6 +1686,7 @@ evas_object_image_unload(Evas_Object *ob
    o->cur.cspace = EVAS_COLORSPACE_ARGB8888;
    o->cur.image.w = 0;
    o->cur.image.h = 0;
+   o->cur.image.stride = 0;
 }
 
 static void
@@ -1666,15 +1710,22 @@ evas_object_image_load(Evas_Object *obj)
    if (o->engine_data)
      {
        int w, h;
+       int stride;
 
        
obj->layer->evas->engine.func->image_size_get(obj->layer->evas->engine.data.output,
                                                      o->engine_data, &w, &h);
+       if (obj->layer->evas->engine.func->image_stride_get)
+         
obj->layer->evas->engine.func->image_stride_get(obj->layer->evas->engine.data.output,
+                                                         o->engine_data, 
&stride);
+       else
+         stride = w;
        o->cur.has_alpha = 
obj->layer->evas->engine.func->image_alpha_get(obj->layer->evas->engine.data.output,
                                                                          
o->engine_data);
        o->cur.cspace = 
obj->layer->evas->engine.func->image_colorspace_get(obj->layer->evas->engine.data.output,
                                                                            
o->engine_data);
        o->cur.image.w = w;
        o->cur.image.h = h;
+       o->cur.image.stride = stride;
      }
    else
      {
@@ -2320,3 +2371,52 @@ evas_object_image_was_opaque(Evas_Object
        return 0;
    return 1;
 }
+
+static int
+evas_object_image_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
+{
+   Evas_Object_Image *o;
+   void *data;
+   int w, h, stride;
+   int a;
+
+   o = (Evas_Object_Image *)(obj->object_data);
+
+   x -= obj->cur.cache.clip.x;
+   y -= obj->cur.cache.clip.y;
+   w = o->cur.image.w;
+   h = o->cur.image.h;
+
+   if ((x > w) || (y > h))
+     return 0;
+
+   if (!o->cur.has_alpha)
+     return 1;
+
+   stride = o->cur.image.stride;
+
+   o->engine_data = 
obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
+                                                                 
o->engine_data,
+                                                                 0,
+                                                                 (DATA32**) 
&data);
+   if (!data)
+     return 0;
+
+   switch (o->cur.cspace)
+     {
+       case EVAS_COLORSPACE_ARGB8888:
+         data = ((DATA32*)(data) + ((y * stride) + x));
+         a = (*((DATA32*)(data)) >> 24) & 0xff;
+         break;
+       case EVAS_COLORSPACE_RGB565_A5P:
+         data = ((DATA16*)(data) + (h * stride));
+         data = ((DATA8*)(data) + ((y * stride) + x));
+         a = (*((DATA8*)(data))) & 0x1f;
+         break;
+       default:
+         return 1;
+         break;
+     }
+
+   return (a != 0);
+}
Index: src/lib/canvas/evas_object_main.c
===================================================================
RCS file: /var/cvs/e/e17/libs/evas/src/lib/canvas/evas_object_main.c,v
retrieving revision 1.56
diff -u -3 -p -r1.56 evas_object_main.c
--- src/lib/canvas/evas_object_main.c   21 Feb 2007 21:43:45 -0000      1.56
+++ src/lib/canvas/evas_object_main.c   12 Jul 2007 20:40:47 -0000
@@ -419,6 +419,23 @@ evas_object_was_opaque(Evas_Object *obj)
    return 0;
 }
 
+int
+evas_object_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
+{
+   if (obj->smart.smart) return 0;
+   if (obj->func->is_inside)
+     return obj->func->is_inside(obj, x, y);
+   return 0;
+}
+
+int
+evas_object_was_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
+{
+   if (obj->smart.smart) return 0;
+   if (obj->func->was_inside)
+     return obj->func->was_inside(obj, x, y);
+   return 0;
+}
 /* routines apps will call */
 
 /**
@@ -1221,3 +1238,33 @@ evas_object_type_get(Evas_Object *obj)
    if (obj->delete_me) return "";
    return obj->type;
 }
+
+/**
+ * Set whether to use a precise (usually expensive) point collision detection.
+ * @param obj The given object.
+ * @param precise wheter to use a precise point collision detection or not
+ * The default value is false.
+ * @ingroup Evas_Object_Group
+ */
+EAPI void
+evas_object_precise_is_inside_set(Evas_Object *obj, Evas_Bool precise)
+{
+   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+   return;
+   MAGIC_CHECK_END();
+   obj->precise_is_inside = precise;
+}
+
+/**
+ * Determine whether an object is set to use a precise point collision 
detection.
+ * @param obj The given object.
+ * @ingroup Evas_Object_Group
+ */
+EAPI Evas_Bool
+evas_object_precise_is_inside_get(Evas_Object *obj)
+{
+   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+   return 0;
+   MAGIC_CHECK_END();
+   return obj->precise_is_inside;
+}
Index: src/lib/include/evas_private.h
===================================================================
RCS file: /var/cvs/e/e17/libs/evas/src/lib/include/evas_private.h,v
retrieving revision 1.85
diff -u -3 -p -r1.85 evas_private.h
--- src/lib/include/evas_private.h      28 Jun 2007 23:22:20 -0000      1.85
+++ src/lib/include/evas_private.h      12 Jul 2007 20:40:47 -0000
@@ -448,6 +448,8 @@ struct _Evas_Object
    unsigned short              in_layer : 1;
    unsigned short              no_propagate : 1;
 
+   unsigned short              precise_is_inside : 1;
+
    unsigned char               delete_me;
 };
 
@@ -587,6 +589,7 @@ struct _Evas_Func
    void (*image_free)                      (void *data, void *image);
    void (*image_size_get)                  (void *data, void *image, int *w, 
int *h);
    void *(*image_size_set)                 (void *data, void *image, int w, 
int h);
+   void (*image_stride_get)                (void *data, void *image, int 
*stride);
    void *(*image_dirty_region)             (void *data, void *image, int x, 
int y, int w, int h);
    void *(*image_data_get)                 (void *data, void *image, int 
to_write, DATA32 **image_data);
    void *(*image_data_put)                 (void *data, void *image, DATA32 
*image_data);
@@ -678,6 +681,8 @@ int evas_object_is_visible(Evas_Object *
 int evas_object_was_visible(Evas_Object *obj);
 int evas_object_is_opaque(Evas_Object *obj);
 int evas_object_was_opaque(Evas_Object *obj);
+int evas_object_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
+int evas_object_was_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
 //void evas_object_recalc_clippees(Evas_Object *obj);
 int evas_object_clippers_is_visible(Evas_Object *obj);
 int evas_object_clippers_was_visible(Evas_Object *obj);
Index: src/modules/engines/cairo_x11/evas_engine.c
===================================================================
RCS file: /var/cvs/e/e17/libs/evas/src/modules/engines/cairo_x11/evas_engine.c,v
retrieving revision 1.11
diff -u -3 -p -r1.11 evas_engine.c
--- src/modules/engines/cairo_x11/evas_engine.c 17 Dec 2006 15:48:51 -0000      
1.11
+++ src/modules/engines/cairo_x11/evas_engine.c 12 Jul 2007 20:40:47 -0000
@@ -193,6 +193,7 @@ static Evas_Func eng_func =
      eng_image_free,
      eng_image_size_get,
      eng_image_size_set,
+     NULL,
      eng_image_dirty_region,
      eng_image_data_get,
      eng_image_data_put,
Index: src/modules/engines/software_16/evas_engine.c
===================================================================
RCS file: 
/var/cvs/e/e17/libs/evas/src/modules/engines/software_16/evas_engine.c,v
retrieving revision 1.5
diff -u -3 -p -r1.5 evas_engine.c
--- src/modules/engines/software_16/evas_engine.c       10 Jul 2007 15:01:52 
-0000      1.5
+++ src/modules/engines/software_16/evas_engine.c       12 Jul 2007 20:40:48 
-0000
@@ -416,6 +416,17 @@ eng_image_size_set(void *data, void *ima
    return image;
 }
 
+static void
+eng_image_stride_get(void *data, void *image, int *stride)
+{
+   Soft16_Image *im;
+
+   if (stride) *stride = 0;
+   if (!image) return;
+   im = image;
+   if (stride) *stride = im->stride;
+}
+
 static void *
 eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h)
 {
@@ -725,6 +736,7 @@ static Evas_Func func =
      eng_image_free,
      eng_image_size_get,
      eng_image_size_set,
+     eng_image_stride_get,
      eng_image_dirty_region,
      eng_image_data_get,
      eng_image_data_put,
Index: src/modules/engines/software_generic/evas_engine.c
===================================================================
RCS file: 
/var/cvs/e/e17/libs/evas/src/modules/engines/software_generic/evas_engine.c,v
retrieving revision 1.18
diff -u -3 -p -r1.18 evas_engine.c
--- src/modules/engines/software_generic/evas_engine.c  17 Jun 2007 02:56:58 
-0000      1.18
+++ src/modules/engines/software_generic/evas_engine.c  12 Jul 2007 20:40:48 
-0000
@@ -981,6 +981,7 @@ static Evas_Func func =
      eng_image_free,
      eng_image_size_get,
      eng_image_size_set,
+     NULL,
      eng_image_dirty_region,
      eng_image_data_get,
      eng_image_data_put,
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to