From f6fee91130f0cff49e334d7191b7a49bcd7d8afd Mon Sep 17 00:00:00 2001 From: Massimo Valentini Date: Sun, 5 Oct 2014 09:24:53 +0200 Subject: [PATCH] EXTRA_Y --- src/cairo-tor-scan-converter.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/cairo-tor-scan-converter.c b/src/cairo-tor-scan-converter.c index 4adcafb..21d639e 100644 --- a/src/cairo-tor-scan-converter.c +++ b/src/cairo-tor-scan-converter.c @@ -117,6 +117,7 @@ typedef cairo_status_t glitter_status_t; #define GLITTER_INPUT_BITS CAIRO_FIXED_FRAC_BITS #define GRID_X_BITS CAIRO_FIXED_FRAC_BITS #define GRID_Y 15 +#define EXTRA_Y 17 /* Set glitter up to use a cairo span renderer to do the coverage * blitting. */ @@ -237,7 +238,7 @@ typedef int grid_scaled_y_t; * vertices are given in grid scaled coordinates. The scale factor * comes from needing to accurately represent the area 0.5*dx*dy of a * triangle with base dx and height dy in grid scaled numbers. */ -#define GRID_XY (2*GRID_X*GRID_Y) /* Unit area on the grid. */ +#define GRID_XY (2*GRID_X*GRID_Y*EXTRA_Y) /* Unit area on the grid. */ /* GRID_AREA_TO_ALPHA(area): map [0,GRID_XY] to [0,255]. */ #if GRID_XY == 510 @@ -404,8 +405,8 @@ struct polygon { struct cell { struct cell *next; int x; - int16_t uncovered_area; - int16_t covered_height; + int32_t uncovered_area; + int32_t covered_height; }; /* A cell list represents the scan line sparsely as cells ordered by @@ -649,7 +650,8 @@ cell_list_alloc (struct cell_list *cells, cell->next = tail->next; tail->next = cell; cell->x = x; - *(uint32_t *)&cell->uncovered_area = 0; + cell->uncovered_area = 0; + cell->covered_height = 0; return cell; } @@ -737,13 +739,13 @@ cell_list_add_subspan(struct cell_list *cells, if (ix1 != ix2) { struct cell_pair p; p = cell_list_find_pair(cells, ix1, ix2); - p.cell1->uncovered_area += 2*fx1; - ++p.cell1->covered_height; - p.cell2->uncovered_area -= 2*fx2; - --p.cell2->covered_height; + p.cell1->uncovered_area += 2*fx1 * EXTRA_Y; + p.cell1->covered_height += EXTRA_Y; + p.cell2->uncovered_area -= 2*fx2 * EXTRA_Y; + p.cell2->covered_height -= EXTRA_Y; } else { struct cell *cell = cell_list_find(cells, ix1); - cell->uncovered_area += 2*(fx1-fx2); + cell->uncovered_area += 2*(fx1-fx2) * EXTRA_Y; } } @@ -829,8 +831,8 @@ cell_list_render_edge(struct cell_list *cells, /* We always know that ix1 is >= the cell list cursor in this * case due to the no-intersections precondition. */ struct cell *cell = cell_list_find(cells, ix1); - cell->covered_height += sign*GRID_Y; - cell->uncovered_area += sign*(fx1 + fx2)*GRID_Y; + cell->covered_height += sign*GRID_Y * EXTRA_Y; + cell->uncovered_area += sign*(fx1 + fx2)*GRID_Y * EXTRA_Y; return; } @@ -864,7 +866,7 @@ cell_list_render_edge(struct cell_list *cells, tmp = (ix1 + 1) * GRID_X * edge->dy; tmp -= x1.quo * edge->dy + x1.rem; - tmp *= GRID_Y; + tmp *= GRID_Y * EXTRA_Y; y.quo = tmp / dx; y.rem = tmp % dx; @@ -894,8 +896,8 @@ cell_list_render_edge(struct cell_list *cells, struct cell *cell = pair.cell2; struct quorem dydx_full; - dydx_full.quo = GRID_Y * GRID_X * edge->dy / dx; - dydx_full.rem = GRID_Y * GRID_X * edge->dy % dx; + dydx_full.quo = EXTRA_Y * GRID_Y * GRID_X * edge->dy / dx; + dydx_full.rem = EXTRA_Y * GRID_Y * GRID_X * edge->dy % dx; ++ix1; do { @@ -916,8 +918,8 @@ cell_list_render_edge(struct cell_list *cells, pair.cell2 = cell; } - pair.cell2->uncovered_area += sign*(GRID_Y - y_last)*fx2; - pair.cell2->covered_height += sign*(GRID_Y - y_last); + pair.cell2->uncovered_area += sign*(EXTRA_Y * GRID_Y - y_last)*fx2; + pair.cell2->covered_height += sign*(EXTRA_Y * GRID_Y - y_last); } } @@ -1576,7 +1578,7 @@ blit_a8 (struct cell_list *cells, { struct cell *cell = cells->head.next; int prev_x = xmin, last_x = -1; - int16_t cover = 0, last_cover = 0; + int32_t cover = 0, last_cover = 0; unsigned num_spans; if (cell == &cells->tail) @@ -1593,7 +1595,7 @@ blit_a8 (struct cell_list *cells, num_spans = 0; for (; cell->x < xmax; cell = cell->next) { int x = cell->x; - int16_t area; + int32_t area; if (x > prev_x && cover != last_cover) { spans[num_spans].x = prev_x; @@ -1645,7 +1647,7 @@ blit_a1 (struct cell_list *cells, { struct cell *cell = cells->head.next; int prev_x = xmin, last_x = -1; - int16_t cover = 0; + int32_t cover = 0; uint8_t coverage, last_cover = 0; unsigned num_spans; @@ -1663,7 +1665,7 @@ blit_a1 (struct cell_list *cells, num_spans = 0; for (; cell->x < xmax; cell = cell->next) { int x = cell->x; - int16_t area; + int32_t area; coverage = GRID_AREA_TO_A1 (cover); if (x > prev_x && coverage != last_cover) { -- 1.9.3