From: Enlightenment C. <no...@cv...> - 2007-12-10 23:04:36
|
Enlightenment CVS committal Author : turran Project : e17 Module : proto/enesim Dir : e17/proto/enesim/src/lib/raster/rasterizer Modified Files: rasterizer.c kiia.h kiia16.c cpsc.c kiia.c rasterizer.h kiia8.c Log Message: + Disable building the scanline directory + Add DeCasteljau bezier subdivision (the flat test isnt done yet) + Clean the renderer to use new API + Make extenders for different types (float, int) + Fix the vector components / container to use new Edata_Array API =================================================================== RCS file: /cvs/e/e17/proto/enesim/src/lib/raster/rasterizer/rasterizer.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- rasterizer.c 2 Dec 2007 23:28:43 -0000 1.3 +++ rasterizer.c 10 Dec 2007 23:04:04 -0000 1.4 @@ -44,21 +44,17 @@ * To be documented * FIXME: To be fixed */ -EAPI int enesim_rasterizer_generate(Enesim_Rasterizer *r, int sl, Enesim_Scanline_Callback cb, void *data) +EAPI int enesim_rasterizer_generate(Enesim_Rasterizer *r, + Enesim_Scanline_Callback cb, void *data) { assert(r); assert(r->funcs); assert(r->funcs->generate); assert(cb); - if (!(r->types & sl)) - { - ENESIM_WARNING("Scanline not supported"); - return -ENESIM_ERROR_SCANLINE_NOT_SUPPORTED; - } r->user_data = data; r->scanline_callback = cb; - r->funcs->generate(r->data, sl); + r->funcs->generate(r->data); return ENESIM_OK; } =================================================================== RCS file: /cvs/e/e17/proto/enesim/src/lib/raster/rasterizer/kiia.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- kiia.h 2 Dec 2007 23:28:43 -0000 1.1 +++ kiia.h 10 Dec 2007 23:04:04 -0000 1.2 @@ -7,6 +7,8 @@ * * TODO: * - Support NonZero Rule + * - Support for multiple _generates_ without new/delete + * - Support the clipping? */ /* TODO Move the fixed point thing to a common place */ @@ -59,7 +61,7 @@ Kiia_Vertex vertex_last; int vertex_pos; - Enesim_Extender extender; + Enesim_Extender_Int extender; KIIA_SUBPIXEL_DATA *mask; DATA8 *coverages; @@ -106,8 +108,8 @@ k->table[line_first] = e; /* accumulate the maxy and miny */ - enesim_extender_add(&k->extender, line_first, line_last); - printf("edge added yfirst = %d, ylast = %d, x = %d, slope = %d slope_fix = %d\n", e->yfirst, e->ylast, e->x, e->slope, e->slope_fix); + enesim_extender_int_add(&k->extender, line_first, line_last); + //printf("edge added yfirst = %d, ylast = %d, x = %d, slope = %d slope_fix = %d\n", e->yfirst, e->ylast, e->x, e->slope, e->slope_fix); } static void _edge_add(Kiia *k, Kiia_Vertex *v) @@ -205,7 +207,7 @@ return x; } -static void _rasterize_edge(Kiia *k, Kiia_Edge **aet, Enesim_Extender *length, +static void _rasterize_edge(Kiia *k, Kiia_Edge **aet, Enesim_Extender_Int *length, int curr_line) { Kiia_Edge *curr_edge = *aet, *prev_edge = NULL; @@ -223,7 +225,7 @@ x = _dda(k, curr_edge->x, 0, ye, curr_edge->slope, 1); xe = FIXED_TO_INT(x - curr_edge->slope); - enesim_extender_add_sort(length, FIXED_TO_INT(curr_edge->x), xe); + enesim_extender_int_unsorted_add(length, FIXED_TO_INT(curr_edge->x), xe); /* remove the edge from the AET */ curr_edge = curr_edge->gnext; if (prev_edge) @@ -238,7 +240,7 @@ x = _dda(k, curr_edge->x, 0, KIIA_SUBPIXEL_COUNT - 1, curr_edge->slope, 1); xe = FIXED_TO_INT(x - curr_edge->slope); - enesim_extender_add_sort(length, FIXED_TO_INT(curr_edge->x), xe); + enesim_extender_int_unsorted_add(length, FIXED_TO_INT(curr_edge->x), xe); /* update the edge */ if ((curr_line & SLOPE_FIX_SCANLINE_MASK) == 0) curr_edge->x = x + curr_edge->slope_fix; @@ -268,7 +270,7 @@ ys = curr_edge->yfirst & (KIIA_SUBPIXEL_COUNT - 1); x = _dda(k, curr_edge->x, ys, ye, curr_edge->slope, 1 << ys); xe = FIXED_TO_INT(x - curr_edge->slope); - enesim_extender_add_sort(length, FIXED_TO_INT(curr_edge->x), xe); + enesim_extender_int_unsorted_add(length, FIXED_TO_INT(curr_edge->x), xe); /* ignore this edge */ } else @@ -279,7 +281,7 @@ ys = curr_edge->yfirst & (KIIA_SUBPIXEL_COUNT - 1); x = _dda(k, curr_edge->x, ys, KIIA_SUBPIXEL_COUNT - 1, curr_edge->slope, 1 << ys); xe = FIXED_TO_INT(x - curr_edge->slope); - enesim_extender_add_sort(length, FIXED_TO_INT(curr_edge->x), xe); + enesim_extender_int_unsorted_add(length, FIXED_TO_INT(curr_edge->x), xe); curr_edge->x = x; /* add the edge to the AET */ if (prev_edge) @@ -298,27 +300,31 @@ } } -static void _generate(Kiia *k, int sl) +#define DIRECT + +static void _generate(Kiia *k) { int y; int ymin = k->extender.min; int ymax = k->extender.max; - Enesim_Extender length; /* to keep track of min and max x */ + Enesim_Extender_Int length; /* to keep track of min and max x */ Kiia_Edge *edge = NULL; - Enesim_Scanline_Alias alias; //printf("ymin %d ymax %d\n", ymin, ymax); for (y = 0; y <= ymax; y++) { int xmin; int xmax; +#ifdef DIRECT + int x; +#endif KIIA_SUBPIXEL_DATA *mp; KIIA_SUBPIXEL_DATA *end; KIIA_SUBPIXEL_DATA mask; DATA8 *cov; - enesim_extender_reset(&length); + enesim_extender_int_reset(&length); _rasterize_edge(k, &edge, &length, y); xmin = length.min; xmax = length.max + 1; @@ -330,11 +336,15 @@ mp = &k->mask[xmin]; end = &k->mask[xmax + 1]; *end = KIIA_FULL_COVERAGE; +#ifdef DIRECT + x = xmin; +#else cov = k->coverages + xmin; k->sl.y = y; k->sl.x = xmin; k->sl.w = xmax - xmin + 1; k->sl.coverages = cov; +#endif mask = *mp; *mp++ = 0; while (mp <= end) @@ -344,40 +354,76 @@ do { mask = *mp++; +#ifndef DIRECT *cov = 0; cov++; +#endif +#ifdef DIRECT + x++; +#endif } while (mask == 0); mp[-1] = 0; } else if (mask == KIIA_FULL_COVERAGE) { + KIIA_SUBPIXEL_DATA tmp; +#ifdef DIRECT /* FIXME here instead of sending a mask scanline * send an alias */ - KIIA_SUBPIXEL_DATA tmp; + Enesim_Scanline_Alias sl; + + sl.y = y; + sl.x = x; +#endif do { tmp = *mp++; +#ifndef DIRECT *cov = 255; cov++; +#endif +#ifdef DIRECT + x++; +#endif } while (tmp == 0); mp[-1] = 0; mask ^= tmp; +#ifdef DIRECT + sl.w = x - sl.x; + k->r->scanline_callback(&sl, ENESIM_SCANLINE_ALIAS, k->r->user_data); +#endif } else { +#ifdef DIRECT /* FIXME here send a mask scanline directly */ + Enesim_Scanline_Mask sl; + + sl.y = y; + sl.x = x; + cov = k->coverages + x; +#endif do { - // TODO fix this! /* coverages from 0 to subpixel_count */ *cov = KIIA_SUBPIXEL_COVERAGE(mask) << KIIA_COVERAGE_SHIFT; cov++; mask ^= *mp; *mp++ = 0; +#ifdef DIRECT + x++; +#endif } while (!((mask == 0) || (mask == KIIA_FULL_COVERAGE))); +#ifdef DIRECT + sl.w = x - sl.x + 1; + sl.coverages = k->coverages + sl.x; + k->r->scanline_callback(&sl, ENESIM_SCANLINE_MASK, k->r->user_data); +#endif } } - k->r->scanline_callback(&k->sl, k->r->user_data); +#ifndef DIRECT + k->r->scanline_callback(&k->sl, ENESIM_SCANLINE_MASK, k->r->user_data); +#endif } } =================================================================== RCS file: /cvs/e/e17/proto/enesim/src/lib/raster/rasterizer/kiia16.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- kiia16.c 2 Dec 2007 23:28:43 -0000 1.1 +++ kiia16.c 10 Dec 2007 23:04:04 -0000 1.2 @@ -8,7 +8,7 @@ #include "enesim_private.h" #include "rasterizer.h" #include "scanline.h" -#include "extender.h" +#include "extender_int.h" #define KIIA_SUBPIXEL_SHIFT 4 #define KIIA_SUBPIXEL_DATA unsigned short int =================================================================== RCS file: /cvs/e/e17/proto/enesim/src/lib/raster/rasterizer/cpsc.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- cpsc.c 2 Dec 2007 23:28:43 -0000 1.4 +++ cpsc.c 10 Dec 2007 23:04:04 -0000 1.5 @@ -7,7 +7,6 @@ #include "enesim_private.h" #include "rasterizer.h" #include "scanline.h" -//#include "alias.h" // This header should be fixed /* Code based on the algorithm "Concave Polygon Scan Conversion" by * Paul Heckbert from "Graphics Gems". @@ -130,7 +129,7 @@ r->num_vertices++; } -static void _generate(Cpsc *r, int sl) +static void _generate(Cpsc *r) { Enesim_Scanline_Alias alias; Cpsc_Vertex *vertices; @@ -214,8 +213,7 @@ alias.y = y; alias.x = xl; alias.w = xr - xl + 1; - r->r->scanline_callback(&alias, r->r->user_data); - //sl->funcs->add(sl->data, y, xl, xr, 255); + r->r->scanline_callback(&alias, ENESIM_SCANLINE_ALIAS, r->r->user_data); } aet[j].x += aet[j].dx; aet[j + 1].x += aet[j + 1].dx; @@ -250,7 +248,7 @@ c = calloc(1, sizeof(Cpsc)); c->a = edata_array_new(c, EDATA_ARRAY_ALLOC(_a_alloc), - EDATA_ARRAY_FREE(_a_free)); + EDATA_ARRAY_FREE(_a_free), 0); r = enesim_rasterizer_new(c, &cpsc_func, boundaries, ENESIM_SCANLINE_ALIAS); c->r = r; return r; =================================================================== RCS file: /cvs/e/e17/proto/enesim/src/lib/raster/rasterizer/kiia.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- kiia.c 2 Dec 2007 23:28:43 -0000 1.2 +++ kiia.c 10 Dec 2007 23:04:04 -0000 1.3 @@ -7,8 +7,6 @@ #include "Enesim.h" #include "enesim_private.h" #include "rasterizer.h" -#include "scanline.h" -#include "extender.h" /*============================================================================* * API * =================================================================== RCS file: /cvs/e/e17/proto/enesim/src/lib/raster/rasterizer/rasterizer.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- rasterizer.h 2 Dec 2007 23:28:43 -0000 1.3 +++ rasterizer.h 10 Dec 2007 23:04:04 -0000 1.4 @@ -10,17 +10,18 @@ * - add a function/struct element to set up the odd/even/zero fill rule * - im not sure about using a rectangle for the boundaries, maybe only * width and height? + * - support passing edges directly instead of vertices (useful for + * subpaths) */ typedef void (*Enesim_Rasterizer_Vertex_Add)(void *r, float x, float y); -typedef void (*Enesim_Rasterizer_Generate)(void *r, int sl); +typedef void (*Enesim_Rasterizer_Generate)(void *r); typedef void (*Enesim_Rasterizer_Delete)(void *r); typedef struct _Enesim_Rasterizer_Func { Enesim_Rasterizer_Vertex_Add vertex_add; Enesim_Rasterizer_Generate generate; Enesim_Rasterizer_Delete delete; - /* TODO free */ } Enesim_Rasterizer_Func; #define ENESIM_RASTERIZER_VERTEX_ADD(func) ((Enesim_Rasterizer_Vertex_Add)func) =================================================================== RCS file: /cvs/e/e17/proto/enesim/src/lib/raster/rasterizer/kiia8.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- kiia8.c 2 Dec 2007 23:28:43 -0000 1.1 +++ kiia8.c 10 Dec 2007 23:04:04 -0000 1.2 @@ -8,7 +8,7 @@ #include "enesim_private.h" #include "rasterizer.h" #include "scanline.h" -#include "extender.h" +#include "extender_int.h" #define KIIA_SUBPIXEL_SHIFT 3 #define KIIA_SUBPIXEL_DATA unsigned char |