Re: [E-devel] Line + width support.
We decided to improve the line implementation to speed up the use of evas-lines in python (our case). Yes, we could just use polygons, but we are trying to reduce processor usage at this point. Its faster to draw lines (with lines implementation) directly, specially dealing with vertical/horizontal/45 deg. lines. Calculating where points of polygons must be drawn relative to width of line in python-side is a lost of processing too. Being faster, simpler and without breaking any compatibility, I dont know why Lines should not to have width support. Specially thinking about how simpler it makes to work with Lines. Yes, the code may be optimized, but its working fine and fast here. Greetings, Diego B. Contezini On Sun, May 18, 2008 at 11:51 PM, The Rasterman Carsten Haitzler [EMAIL PROTECTED] wrote: On Tue, 13 May 2008 17:20:27 -0300 Diego Bitencourt Contezini [EMAIL PROTECTED] babbled: any reason you didnt just use polygons? :) Hello all. Working with evas+Lines in python, is fast. But if you need a line with more then one pixel of width, it gets very slow (in dispositives like N800), because object Line dont have width support, so its needen to use Rectangles to make it works. I made a modification to support width in Lines object. It is composed by 3 patchs. *First*, in evas/lib/*, it changes internal call to engine line drawer, inserting more one argument to the same function. It is a callback, so, no modification is needen in any engine module that dosnt support Lines with more then 1 pixel (they will just draw with only 1 pixel). Has added new functions to deal with width, without breaking any compatibility of other functions. *Second*, in evas/engine/software16 to add support to width. *Third,* in python-evas binding, to add support to use the modifications made in evas. If anyone get any bug or suggest any modification to patch, im a listener. Thanks all Diego Bitencourt Contezini -- - Codito, ergo sum - I code, therefore I am -- The Rasterman (Carsten Haitzler)[EMAIL PROTECTED] --- evas-0.9.9.042/src/lib/canvas/evas_object_line.c 2008-05-07 17:22:34.0 -0300 +++ evas-linha/src/lib/canvas/evas_object_line.c 2008-05-20 09:50:03.0 -0300 @@ -18,6 +18,7 @@ } object; } cache; Evas_Coord x1, y1, x2, y2; + int width; } cur, prev; void *engine_data; @@ -86,7 +87,6 @@ evas_object_inject(obj, e); return obj; } - /** * Sets the coordinates of the end points of the given evas line object. * @param obj The given evas line object. @@ -143,12 +143,12 @@ obj-cur.geometry.y = min_y; obj-cur.geometry.w = max_x - min_x + 2.0; obj-cur.geometry.h = max_y - min_y + 2.0; - obj-cur.cache.geometry.validity = 0; o-cur.x1 = x1 - min_x; o-cur.y1 = y1 - min_y; o-cur.x2 = x2 - min_x; o-cur.y2 = y2 - min_y; o-changed = 1; + o-cur.width = 1; evas_object_change(obj); evas_object_coords_recalc(obj); if (obj-layer-evas-events_frozen = 0) @@ -171,6 +171,122 @@ } /** + * Sets the coordinates of the end points of the given evas line object with width param. + * @param objThe given evas line object. + * @param x1 The X coordinate of the first point. + * @param y1 The Y coordinate of the first point. + * @param x2 The X coordinate of the second point. + * @param y2 The Y coordinate of the second point. + * @param width The width of the line. + * @ingroup Evas_Line_Group + */ +EAPI void +evas_object_line_xyw_set(Evas_Object *obj, Evas_Coord x1, Evas_Coord y1, Evas_Coord x2, Evas_Coord y2, int width) +{ + Evas_Object_Line *o; + Evas_Coord min_x, max_x, min_y, max_y; + int is, was = 0; + + MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ); + return; + MAGIC_CHECK_END(); + o = (Evas_Object_Line *)(obj-object_data); + MAGIC_CHECK(o, Evas_Object_Line, MAGIC_OBJ_LINE); + return; + MAGIC_CHECK_END(); + if ((x1 == o-cur.x1) (y1 == o-cur.y1) + (x2 == o-cur.x2) (y2 == o-cur.y2)) return; + + if (obj-layer-evas-events_frozen = 0) + { + if (!evas_event_passes_through(obj)) + was = evas_object_is_in_output_rect(obj, + obj-layer-evas-pointer.x, + obj-layer-evas-pointer.y, 1, 1); + } + + if (x1 x2) + { + min_x = x1; + max_x = x2; + } + else + { + min_x = x2; + max_x = x1; + } + + if (y1 y2) + { + min_y = y1; + max_y = y2; + } + else + { + min_y = y2; + max_y = y1; + } + + if(width 1) + { + int tsum; // type of Sum (x = 0, y = 1) + if(x1 == x2) + { // vertical line + if(y1 == y2) + tsum = 1; + else + tsum = 0; + } else if(y1 == y2) // horizontal line + tsum = 1; + else if((max_x - min_x) (max_y - min_y)) // dx dy + tsum = 1; + else // dx = dy + tsum = 0; + + if(tsum 0) + { + min_y -= (width/2)+1 - width%2; + max_y += (width/2); + } + else + { + min_x
Re: [E-devel] Line + width support.
This patches I sent last mail are the last working, sorry, I forgot to tell. They are with two corrections we've got here in testing. Diego - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
[E-devel] Line + width support.
Hello all. Working with evas+Lines in python, is fast. But if you need a line with more then one pixel of width, it gets very slow (in dispositives like N800), because object Line dont have width support, so its needen to use Rectangles to make it works. I made a modification to support width in Lines object. It is composed by 3 patchs. *First*, in evas/lib/*, it changes internal call to engine line drawer, inserting more one argument to the same function. It is a callback, so, no modification is needen in any engine module that dosnt support Lines with more then 1 pixel (they will just draw with only 1 pixel). Has added new functions to deal with width, without breaking any compatibility of other functions. *Second*, in evas/engine/software16 to add support to width. *Third,* in python-evas binding, to add support to use the modifications made in evas. If anyone get any bug or suggest any modification to patch, im a listener. Thanks all Diego Bitencourt Contezini diff -Naur evas-0.9.9.042/src/modules/engines/software_16/evas_engine.c evas-linha/src/modules/engines/software_16/evas_engine.c --- evas-0.9.9.042/src/modules/engines/software_16/evas_engine.c 2008-05-07 17:22:35.0 -0300 +++ evas-linha/src/modules/engines/software_16/evas_engine.c 2008-05-13 14:35:03.0 -0300 @@ -149,9 +149,9 @@ } static void -eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2) +eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2, int width) { - soft16_line_draw(surface, context, x1, y1, x2, y2); + soft16_line_draw(surface, context, x1, y1, x2, y2, width); } static void * diff -Naur evas-0.9.9.042/src/modules/engines/software_16/evas_soft16.h evas-linha/src/modules/engines/software_16/evas_soft16.h --- evas-0.9.9.042/src/modules/engines/software_16/evas_soft16.h 2008-05-07 17:22:35.0 -0300 +++ evas-linha/src/modules/engines/software_16/evas_soft16.h 2008-05-13 14:35:03.0 -0300 @@ -139,7 +139,7 @@ * Line (evas_soft16_line.c) */ void -soft16_line_draw(Soft16_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1); +soft16_line_draw(Soft16_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1, int width); /** diff -Naur evas-0.9.9.042/src/modules/engines/software_16/evas_soft16_line.c evas-linha/src/modules/engines/software_16/evas_soft16_line.c --- evas-0.9.9.042/src/modules/engines/software_16/evas_soft16_line.c 2008-05-07 17:22:35.0 -0300 +++ evas-linha/src/modules/engines/software_16/evas_soft16_line.c 2008-05-13 14:35:03.0 -0300 @@ -71,8 +71,8 @@ dst_itr = dst-pixels + (dst-stride * y) + x; alpha = A_VAL(dc-col.col) 3; rgb565 = RGB_565_FROM_COMPONENTS(R_VAL(dc-col.col), -G_VAL(dc-col.col), -B_VAL(dc-col.col)); + G_VAL(dc-col.col), + B_VAL(dc-col.col)); if (alpha == 31) _soft16_pt_fill_solid_solid(dst_itr, rgb565); @@ -87,52 +87,62 @@ } static void -_soft16_line_horiz(Soft16_Image *dst, RGBA_Draw_Context *dc, int x0, int x1, int y) +_soft16_line_horiz(Soft16_Image *dst, RGBA_Draw_Context *dc, int x0, int x1, int y, int width) { DATA16 rgb565, *dst_itr; DATA8 alpha; + int dx; int w; - - if (!_is_y_inside_clip(y, dc-clip)) - return; - if (x0 dc-clip.x) x0 = dc-clip.x; if (x1 = dc-clip.x + dc-clip.w) x1 = dc-clip.x + dc-clip.w - 1; - w = x1 - x0; - if (w 1) + dx = x1 - x0; + if (dx 1) return; - dst_itr = dst-pixels + (dst-stride * y) + x0; - alpha = A_VAL(dc-col.col) 3; - rgb565 = RGB_565_FROM_COMPONENTS(R_VAL(dc-col.col), -G_VAL(dc-col.col), -B_VAL(dc-col.col)); + dx++; - if (alpha == 31) - _soft16_scanline_fill_solid_solid(dst_itr, w, rgb565); - else if (alpha 0) + for(w = 0; w width; w++) { - DATA32 rgb565_unpack; + int ay; + if(w%2) // not pair + ay = y+(w/2) + 1; + else // pair + ay = y-(w/2); + if (!_is_y_inside_clip(ay, dc-clip)) + continue; + + dst_itr = dst-pixels + (dst-stride * ay) + x0; + alpha = A_VAL(dc-col.col) 3; + rgb565 = RGB_565_FROM_COMPONENTS(R_VAL(dc-col.col), + G_VAL(dc-col.col), + B_VAL(dc-col.col)); + + if (alpha == 31) + _soft16_scanline_fill_solid_solid(dst_itr, dx, rgb565); + else if (alpha 0) + { + DATA32 rgb565_unpack; - rgb565_unpack = RGB_565_UNPACK(rgb565); - alpha++; - _soft16_scanline_fill_transp_solid(dst_itr, w, rgb565_unpack, alpha); + rgb565_unpack = RGB_565_UNPACK(rgb565); + alpha++; + _soft16_scanline_fill_transp_solid(dst_itr, dx, rgb565_unpack, alpha); + } } + return; } static void -_soft16_line_vert(Soft16_Image *dst, RGBA_Draw_Context *dc, int x, int y0, int y1) +_soft16_line_vert(Soft16_Image *dst, RGBA_Draw_Context *dc, int x, int y0, int y1, int width) { DATA16 rgb565, *dst_itr; DATA8 alpha; - int h; - - if (!_is_x_inside_clip(x, dc-clip)) - return; + int dy; + int dx; + int x0