diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-12-21 12:44:43 -0500 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-12-21 12:44:43 -0500 |
commit | bb03de6de3d616ea8f6812fcf664d987f29263e8 (patch) | |
tree | 5963dc08c6bc0d92ce58704127011348c0dc36a7 | |
parent | 040189274ec959afcf8d09ff2d33d8235984433d (diff) |
emit func
-rw-r--r-- | poly3.c | 29 |
1 files changed, 17 insertions, 12 deletions
@@ -4,6 +4,7 @@ #include <stdint.h> #include <string.h> #include <assert.h> +#include <cairo.h> typedef int32_t fixed_t; @@ -460,17 +461,12 @@ update_active (active_t *active, sample_t yi) return active; } -static void -emit (sample_t xi, sample_t yi) -{ - printf ("(%8x, %8x) => (%f, %f)\n", - xi, yi, - fixed_to_double (sample_to_pos_x (xi)), - fixed_to_double (sample_to_pos_y (yi))); -} +typedef void (* emit_func_t) (sample_t xi, sample_t yi, void *data); static void -polygon_rasterize (polygon_t *polygon, int x, int y, int width, int height) +polygon_rasterize (polygon_t *polygon, + int x, int y, int width, int height, + emit_func_t emit, void *data) { global_t *global = create_global (polygon, x, y, width, height); active_t *active = create_active (global); @@ -489,7 +485,7 @@ polygon_rasterize (polygon_t *polygon, int x, int y, int width, int height) { edge_t *edge = active->edges[j]; - emit (edge->common.xi, yi); + emit (edge->common.xi, yi, data); edge_small_step (edge); } @@ -504,7 +500,7 @@ polygon_rasterize (polygon_t *polygon, int x, int y, int width, int height) { edge_t *edge = active->edges[j]; - emit (edge->common.xi, yi); + emit (edge->common.xi, yi, data); edge_big_step (edge); } @@ -515,6 +511,15 @@ polygon_rasterize (polygon_t *polygon, int x, int y, int width, int height) #define df(a) double_to_fixed(a) +static void +emit (sample_t xi, sample_t yi, void *data) +{ + printf ("(%8x, %8x) => (%f, %f)\n", + xi, yi, + fixed_to_double (sample_to_pos_x (xi)), + fixed_to_double (sample_to_pos_y (yi))); +} + int main (int argc, char **argv) { @@ -535,7 +540,7 @@ main (int argc, char **argv) polygon_t *polygon = polygon_create ( pentagons, sizeof (pentagons) / sizeof (pentagons[0])); - polygon_rasterize (polygon, 0, 0, 45, 30); + polygon_rasterize (polygon, 0, 0, 45, 30, emit, NULL); return 0; } |