Sorry, I just realized that I mailed to the wrong list.
On Wed, Sep 17, 2008 at 09:44:15AM -0300, Gustavo Sverzut Barbieri wrote:
> > I am working on a map application and I would like to draw the GPS track
> > on the map. The track is basically lots (thousands) of line segments,
> > with each segment begins at where the previous one ends. Is it a good
> > idea to represent each line segment by a line object?
> No, since most algorithms we use are linear or exponential on the
> number of objects, so more objects, more slowdown.
> Also, Evas has no line width property, so you'll not be able to make
> it with lines. Use Polygons instead. Polygons are not the most
> optimized bit of Evas, however it is counted as just one object and
> it's processed using the scanline polygon fill mode.
I have made a simple patch to give polygon the option not to fill its
enclosed region. It adds the following functions:
void evas_object_polygon_fill_set (Evas_Object *obj, int fill);
int evas_object_polygon_fill_get (const Evas_Object *obj);
void evas_object_polygon_close_set (Evas_Object *obj, int close);
int evas_object_polygon_close_get (const Evas_Object *obj);
By default, polygon has "fill" and "close" set to TRUE. When "fill" is
FALSE, line_draw is called instead polygon_draw. "close" makes sense
only when "fill" is FALSE. It decides whether the polygon should close
the path, that is, draw a line from the last point to the first point.
--
Regards,
olv
Index: evas/src/lib/Evas.h
===================================================================
--- evas/src/lib/Evas.h (revision 36040)
+++ evas/src/lib/Evas.h (working copy)
@@ -491,6 +491,10 @@
EAPI Evas_Object *evas_object_polygon_add (Evas *e);
EAPI void evas_object_polygon_point_add (Evas_Object *obj, Evas_Coord x, Evas_Coord y);
EAPI void evas_object_polygon_points_clear (Evas_Object *obj);
+ EAPI void evas_object_polygon_fill_set (Evas_Object *obj, int fill);
+ EAPI int evas_object_polygon_fill_get (const Evas_Object *obj);
+ EAPI void evas_object_polygon_close_set (Evas_Object *obj, int close);
+ EAPI int evas_object_polygon_close_get (const Evas_Object *obj);
/* image objects */
EAPI Evas_Object *evas_object_image_add (Evas *e);
Index: evas/src/lib/canvas/evas_object_polygon.c
===================================================================
--- evas/src/lib/canvas/evas_object_polygon.c (revision 36040)
+++ evas/src/lib/canvas/evas_object_polygon.c (working copy)
@@ -16,6 +16,8 @@
void *engine_data;
char changed : 1;
+ char close : 1; /* close the path */
+ char fill : 1; /* fill the enclosed region */
};
struct _Evas_Polygon_Point
@@ -217,10 +219,105 @@
evas_object_inform_call_resize(obj);
}
+/**
+ * Set whether the given evas polygon object should fill the region enclosed
+ * by the path.
+ * @param obj The given polygon object.
+ * @param fill Set the fill property.
+ * @ingroup Evas_Polygon_Group
+ */
+EAPI void
+evas_object_polygon_fill_set(Evas_Object *obj, int fill)
+{
+ Evas_Object_Polygon *o;
+ MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+ return;
+ MAGIC_CHECK_END();
+ o = (Evas_Object_Polygon *)(obj->object_data);
+ MAGIC_CHECK(o, Evas_Object_Polygon, MAGIC_OBJ_POLYGON);
+ return;
+ MAGIC_CHECK_END();
+ fill = !!fill;
+ if (o->fill != fill)
+ {
+ o->fill = fill;
+ o->changed = 1;
+ evas_object_change(obj);
+ }
+}
+/**
+ * Get the fill property of the given evas polygon object.
+ * @param obj The given polygon object.
+ * @ingroup Evas_Polygon_Group
+ */
+EAPI int
+evas_object_polygon_fill_get(const Evas_Object *obj)
+{
+ Evas_Object_Polygon *o;
+ MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+ return 0;
+ MAGIC_CHECK_END();
+ o = (Evas_Object_Polygon *)(obj->object_data);
+ MAGIC_CHECK(o, Evas_Object_Polygon, MAGIC_OBJ_POLYGON);
+ return 0;
+ MAGIC_CHECK_END();
+ return o->fill;
+}
+
+/**
+ * Set whether the given evas polygon object should close the path.
+ * @param obj The given polygon object.
+ * @param close Set the close property.
+ * @ingroup Evas_Polygon_Group
+ */
+EAPI void
+evas_object_polygon_close_set(Evas_Object *obj, int close)
+{
+ Evas_Object_Polygon *o;
+
+ MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+ return;
+ MAGIC_CHECK_END();
+ o = (Evas_Object_Polygon *)(obj->object_data);
+ MAGIC_CHECK(o, Evas_Object_Polygon, MAGIC_OBJ_POLYGON);
+ return;
+ MAGIC_CHECK_END();
+
+ close = !!close;
+ if (o->close != close)
+ {
+ o->close = close;
+ o->changed = 1;
+ evas_object_change(obj);
+ }
+}
+
+/**
+ * Get the close property of the given evas polygon object.
+ * @param obj The given polygon object.
+ * @ingroup Evas_Polygon_Group
+ */
+EAPI int
+evas_object_polygon_close_get(const Evas_Object *obj)
+{
+ Evas_Object_Polygon *o;
+
+ MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+ return 0;
+ MAGIC_CHECK_END();
+ o = (Evas_Object_Polygon *)(obj->object_data);
+ MAGIC_CHECK(o, Evas_Object_Polygon, MAGIC_OBJ_POLYGON);
+ return 0;
+ MAGIC_CHECK_END();
+ return o->close;
+}
+
+
+
/* all nice and private */
static void
evas_object_polygon_init(Evas_Object *obj)
@@ -252,6 +349,8 @@
/* alloc obj private data */
o = calloc(1, sizeof(Evas_Object_Polygon));
o->magic = MAGIC_OBJ_POLYGON;
+ o->fill = 1;
+ o->close = 1;
return o;
}
@@ -296,6 +395,47 @@
context);
obj->layer->evas->engine.func->context_render_op_set(output, context,
obj->cur.render_op);
+ if (!o->fill)
+ {
+ Evas_Polygon_Point *prev = NULL, *cur;
+ int num_points = 0;
+
+ for (l = o->points; l; l = l->next)
+ {
+ cur = l->data;
+ if (!prev)
+ {
+ prev = cur;
+ num_points++;
+ continue;
+ }
+
+ obj->layer->evas->engine.func->line_draw(output,
+ context,
+ surface,
+ prev->x + x,
+ prev->y + y,
+ cur->x + x,
+ cur->y + y);
+
+ prev = cur;
+ num_points++;
+ }
+
+ if (o->close && num_points > 2)
+ {
+ cur = o->points->data;
+ obj->layer->evas->engine.func->line_draw(output,
+ context,
+ surface,
+ prev->x + x,
+ prev->y + y,
+ cur->x + x,
+ cur->y + y);
+ }
+ return;
+ }
+
o->engine_data = obj->layer->evas->engine.func->polygon_points_clear(obj->layer->evas->engine.data.output,
obj->layer->evas->engine.data.context,
o->engine_data);
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel