evas/line: Refactor common code for line drawing
authorPaulo Alcantara <pcacjr@profusion.mobi>
Thu, 29 Nov 2012 20:48:24 +0000 (20:48 +0000)
committerGustavo Sverzut Barbieri <barbieri@gmail.com>
Thu, 29 Nov 2012 20:48:24 +0000 (20:48 +0000)
This patch refactors common code for line draws - so that it can be used
by other engines and *threaded* X11.

Signed-off-by: Paulo Alcantara <pcacjr@profusion.mobi>
Patch by: Paulo Alcantara <pcacjr@profusion.mobi>

SVN revision: 79854

src/lib/evas/common/evas_line.h
src/lib/evas/common/evas_line_main.c

index 9d45e3d..1cdff08 100644 (file)
@@ -1,9 +1,11 @@
 #ifndef _EVAS_LINE_H
 #define _EVAS_LINE_H
 
+typedef void (*Evas_Common_Line_Draw_Cb)(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1);
 
 EAPI void          evas_common_line_init               (void);
 
+EAPI void          evas_common_line_draw_cb            (RGBA_Image *dst, RGBA_Draw_Context *dc, int x1, int y1, int x2, int y2, Evas_Common_Line_Draw_Cb cb);
 EAPI void          evas_common_line_draw               (RGBA_Image *dst, RGBA_Draw_Context *dc, int x1, int y1, int x2, int y2);
 
 
index 76417f5..51f851b 100644 (file)
@@ -41,7 +41,7 @@ evas_common_line_init(void)
 }
 
 EAPI void
-evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1)
+evas_common_line_draw_cb(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1, Evas_Common_Line_Draw_Cb cb)
 {
    int  x, y, w, h;
    int  clx, cly, clw, clh;
@@ -88,10 +88,7 @@ evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, in
    dc->clip.w = clw;
    dc->clip.h = clh;
 
-   if (dc->anti_alias)
-       _evas_draw_line_aa(dst, dc, x0, y0, x1, y1);
-   else
-       _evas_draw_line(dst, dc, x0, y0, x1, y1);
+   cb(dst, dc, x0, y0, x1, y1);
 
    /* restore clip info */
    dc->clip.use = cuse;
@@ -101,6 +98,14 @@ evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, in
    dc->clip.h = ch;
 }
 
+EAPI void
+evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1)
+{
+   Evas_Common_Line_Draw_Cb cb;
+
+   cb = dc->anti_alias ? _evas_draw_line_aa : _evas_draw_line;
+   evas_common_line_draw_cb(dst, dc, x0, y0, x1, y1, cb);
+}
 
 static void
 _evas_draw_point(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y)