On 7/10/07, Gustavo Sverzut Barbieri <[EMAIL PROTECTED]> wrote:
On 7/10/07, Gustavo Sverzut Barbieri <[EMAIL PROTECTED]> wrote:
> On 7/9/07, Andre Magalhaes <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > On 7/9/07, Gustavo Sverzut Barbieri <[EMAIL PROTECTED]> wrote:
> > > On 7/9/07, Andre Magalhaes <[EMAIL PROTECTED]> wrote:
> > > > Hey Raster,
> > > >
> > > > On 7/9/07, The Rasterman Carsten Haitzler <[EMAIL PROTECTED]> wrote:
> > > > > On Fri, 6 Jul 2007 18:00:08 -0300 "Andre Magalhaes" <[EMAIL 
PROTECTED]>
> > > +   o->engine_data =
> > > 
obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
> > > +                                                                 
o->engine_data,
> > > +                                                                 0,
> > > +                                                                 &data);
> > > +   data += (y * w) + x;
> > > +   a = (*data >> 24) & 0xff;
> > >
> > > this will not work for engines != 32bpp, like my 16bpp. If not
> > > existent, we need to write an engine-provided get_pixel(), that give
> > > normalized 0-255 components.
> > I imagined that but in the documentation of evas_object_image_data_get it 
says:
> >  * @return  A pointer to the raw data as 32 bit unsigned integer in format 
ARGB.
> > I thought that all engines should convert it to 32 bits in this case,
> > as it's stated on documentation. I am using the same method as
> > evas_object_image_data_get uses. Please someone could clarify this.
>
> Hum... I need to update this doc since it's not true anymore (since
> 16bpp engine, the first non-32bpp), maybe also providing engine
> functions to manipulate this data.
>
> It's a no-go to convert image buffers to 32bpp for these operations,
> some images would take a lot of CPU and memory (800x600 = 480,000
> iterations, 1440,000 bytes, to access one value of interest (alpha).

talking to andré in private and also reading recent commits by raster
about colorspace, we have noticed that is still impossible to get the
pixel with available info, since buffer is not based on just width and
height, but also on row stride, this is used (at least in 16bpp) to
provide better alignment.

I've fixed the evas patch to take into account the has_alpha value of
the image and also the colorspace. For now i am using width instead of
stride (i know it's wrong), so we need to decide whether to have a
get_pixel on the engine or export the stride attr to
Evas_Object_Image.

I've also fixed the coding styles parentheses issue :D

BR
Andrunko
Index: src/lib/Evas.h
===================================================================
RCS file: /var/cvs/e/e17/libs/evas/src/lib/Evas.h,v
retrieving revision 1.100
diff -u -r1.100 Evas.h
--- src/lib/Evas.h	10 Jul 2007 00:13:25 -0000	1.100
+++ src/lib/Evas.h	10 Jul 2007 05:04:40 -0000
@@ -767,6 +767,9 @@
    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 -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	10 Jul 2007 05:04:42 -0000
@@ -57,7 +57,9 @@
 		    }
 		  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_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_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 @@
    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 -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	10 Jul 2007 05:04:47 -0000
@@ -67,6 +67,7 @@
 
 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 @@
      NULL,
      evas_object_image_is_opaque,
      evas_object_image_was_opaque,
-     NULL,
+     evas_object_image_is_inside,
      NULL,
      NULL
 };
@@ -2320,3 +2321,48 @@
 	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;
+   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;
+
+   o->engine_data = obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
+								  o->engine_data,
+								  0,
+								  (DATA32**) &data);
+   switch (o->cur.cspace)
+     {
+	case EVAS_COLORSPACE_ARGB8888:
+	  data = ((DATA32*)(data) + ((y * w) + x));
+	  a = (*((DATA32*)(data)) >> 24) & 0xff;
+	  break;
+	case EVAS_COLORSPACE_RGB565_A5P:
+	  /* FIXME use stride instead of width (w) */
+	  data = ((DATA16*)(data) + (y * w));
+	  data = ((DATA8*)(data) + ((y * w) + x));
+	  a = (*((DATA8*)(data))) & 0xff;
+	  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 -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	10 Jul 2007 05:04:50 -0000
@@ -419,6 +419,23 @@
    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 @@
    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 -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	10 Jul 2007 05:04:53 -0000
@@ -448,6 +448,8 @@
    unsigned short              in_layer : 1;
    unsigned short              no_propagate : 1;
 
+   unsigned short              precise_is_inside : 1;
+
    unsigned char               delete_me;
 };
 
@@ -678,6 +680,8 @@
 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);
-------------------------------------------------------------------------
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