From 9988e6ed4c29e44cd875c7caf789a226cf222ec5 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 1 Oct 2014 12:59:29 +0100 Subject: [PATCH] tor: Walk fullrow edges between precise endpoints Signed-off-by: Chris Wilson --- src/cairo-tor-scan-converter.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/cairo-tor-scan-converter.c b/src/cairo-tor-scan-converter.c index 1c89798..b7a2c2e 100644 --- a/src/cairo-tor-scan-converter.c +++ b/src/cairo-tor-scan-converter.c @@ -791,10 +791,13 @@ cell_list_render_edge(struct cell_list *cells, { grid_scaled_x_t fx1, fx2; int ix1, ix2; + struct quorem x1, x2; + x1 = edge->x; GRID_X_TO_INT_FRAC(edge->cell, ix1, fx1); full_step (edge); GRID_X_TO_INT_FRAC(edge->cell, ix2, fx2); + x2 = edge->x; /* Edge is entirely within a column? */ if (ix1 == ix2) { @@ -808,6 +811,7 @@ cell_list_render_edge(struct cell_list *cells, /* Orient the edge left-to-right. */ if (ix2 < ix1) { + struct quorem tx; int t; t = ix1; @@ -817,6 +821,10 @@ cell_list_render_edge(struct cell_list *cells, t = fx1; fx1 = fx2; fx2 = t; + + tx = x1; + x1 = x2; + x2 = tx; } /* Add coverage for all pixels [ix1,ix2] on this row crossed @@ -824,14 +832,17 @@ cell_list_render_edge(struct cell_list *cells, { struct cell_pair pair; struct quorem y; - int32_t dx; + int64_t tmp, dx; int y_last; - dx = (ix2 - ix1) * GRID_X + (fx2 - fx1); - assert (dx > 0); + dx = (x2.quo - x1.quo) * edge->dy + (x2.rem - x1.rem); + + tmp = (ix1 + 1) * GRID_X * edge->dy - edge->dy/2; + tmp -= x1.quo * edge->dy + x1.rem; + tmp *= GRID_Y; - y.quo = (GRID_X - fx1) * GRID_Y / dx; - y.rem = (GRID_X - fx1) * GRID_Y % dx; + y.quo = tmp / dx; + y.rem = tmp % dx; /* When rendering a previous edge on the active list we may * advance the cell list cursor past the leftmost pixel of the @@ -862,8 +873,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 / dx; - dydx_full.rem = GRID_Y * GRID_X % dx; + dydx_full.quo = GRID_Y * GRID_X * edge->dy / dx; + dydx_full.rem = GRID_Y * GRID_X * edge->dy % dx; ++ix1; do { -- 2.1.1