diff options
author | Igor Melichev <igor.melichev@artifex.com> | 2004-02-20 15:04:59 +0000 |
---|---|---|
committer | Igor Melichev <igor.melichev@artifex.com> | 2004-02-20 15:04:59 +0000 |
commit | 3cab3d46d6e07e680c5fbab7ec0bf4c65dc6dde7 (patch) | |
tree | 82a9900cf5d42a1a20405b9e612e5916ad965679 /gs | |
parent | 407e3f87249a50b5fa4981c2a9663dd83acdfb27 (diff) |
A new implementation of shadings, step 14.
DETAILS :
This patch changes a disabled code only.
Optimized the trapping emulation.
EXPECTED DIFFERENCES :
None.
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@4788 a1074d23-0009-0410-80fe-cf8c14f379e6
Diffstat (limited to 'gs')
-rw-r--r-- | gs/src/gxshade4.c | 13 | ||||
-rw-r--r-- | gs/src/gxshade4.h | 2 | ||||
-rw-r--r-- | gs/src/gxshade6.c | 91 |
3 files changed, 43 insertions, 63 deletions
diff --git a/gs/src/gxshade4.c b/gs/src/gxshade4.c index 5c3f1813a..29a9f1bf5 100644 --- a/gs/src/gxshade4.c +++ b/gs/src/gxshade4.c @@ -348,7 +348,6 @@ Gt_fill_triangle(mesh_fill_state_t * pfs, const mesh_vertex_t * va, # else patch_color_t c0, c1, c2; patch_fill_state_t pfs1; - gs_fixed_point pole[4]; int code; memcpy(&pfs1, (shading_fill_state_t *)pfs, sizeof(shading_fill_state_t)); @@ -358,19 +357,13 @@ Gt_fill_triangle(mesh_fill_state_t * pfs, const mesh_vertex_t * va, memcpy(c1.cc.paint.values, vb->cc, sizeof(c1.cc.paint.values[0]) * pfs->num_components); memcpy(c2.cc.paint.values, vc->cc, sizeof(c2.cc.paint.values[0]) * pfs->num_components); if (INTERPATCH_PADDING) { - pole[0] = va->p; - pole[3] = vb->p; - code = padding(&pfs1, pole, &c0, &c1); + code = padding(&pfs1, &va->p, &vb->p, &c0, &c1); if (code < 0) return code; - pole[0] = vb->p; - pole[3] = vc->p; - code = padding(&pfs1, pole, &c1, &c2); + code = padding(&pfs1, &vb->p, &vc->p, &c1, &c2); if (code < 0) return code; - pole[0] = vc->p; - pole[3] = va->p; - code = padding(&pfs1, pole, &c2, &c0); + code = padding(&pfs1, &vc->p, &va->p, &c2, &c0); if (code < 0) return code; } diff --git a/gs/src/gxshade4.h b/gs/src/gxshade4.h index 2e272550b..57a839394 100644 --- a/gs/src/gxshade4.h +++ b/gs/src/gxshade4.h @@ -103,7 +103,7 @@ int triangle(patch_fill_state_t *pfs, const gs_fixed_point *p0, const gs_fixed_point *p1, const gs_fixed_point *p2, const patch_color_t *c0, const patch_color_t *c1, const patch_color_t *c2); -int padding(patch_fill_state_t *pfs, const gs_fixed_point pole[4], +int padding(patch_fill_state_t *pfs, const gs_fixed_point *p0, const gs_fixed_point *p1, const patch_color_t *c0, const patch_color_t *c1); #endif diff --git a/gs/src/gxshade6.c b/gs/src/gxshade6.c index bb4feb868..24e3ca4ba 100644 --- a/gs/src/gxshade6.c +++ b/gs/src/gxshade6.c @@ -1442,64 +1442,51 @@ triangles(patch_fill_state_t *pfs, const tensor_patch *p) } int -padding(patch_fill_state_t *pfs, const gs_fixed_point pole[4], +padding(patch_fill_state_t *pfs, const gs_fixed_point *p0, const gs_fixed_point *p1, const patch_color_t *c0, const patch_color_t *c1) { - tensor_patch p; + gs_fixed_point q0, q1; + const patch_color_t *cc0, *cc1; + fixed dx = p1->x - p0->x; + fixed dy = p1->y - p0->y; + bool swap_axes = (any_abs(dx) > any_abs(dy)); + gs_fixed_edge le, re; const fixed adjust = INTERPATCH_PADDING; - fixed dx = pole[3].x - pole[0].x; - fixed dy = pole[3].y - pole[0].y; - - if (any_abs(dx) > any_abs(dy)) { - if (dx > 0) { - p.pole[0][0].x = pole[0].x - adjust; - p.pole[0][3].x = pole[3].x + adjust; - p.pole[3][0].x = pole[0].x - adjust; - p.pole[3][3].x = pole[3].x + adjust; - } else { - p.pole[0][0].x = pole[0].x + adjust; - p.pole[0][3].x = pole[3].x - adjust; - p.pole[3][0].x = pole[0].x + adjust; - p.pole[3][3].x = pole[3].x - adjust; - } - if (dy > 0) { - p.pole[0][0].y = pole[0].y - adjust; - p.pole[0][3].y = pole[3].y - adjust; - p.pole[3][0].y = pole[0].y + adjust; - p.pole[3][3].y = pole[3].y + adjust; + + if (swap_axes) { + if (p0->x < p1->x) { + q0.x = p0->y; + q0.y = p0->x; + q1.x = p1->y; + q1.y = p1->x; + cc0 = c0; + cc1 = c1; } else { - p.pole[0][0].y = pole[0].y + adjust; - p.pole[0][3].y = pole[3].y + adjust; - p.pole[3][0].y = pole[0].y - adjust; - p.pole[3][3].y = pole[3].y - adjust; + q0.x = p1->y; + q0.y = p1->x; + q1.x = p0->y; + q1.y = p0->x; + cc0 = c1; + cc1 = c0; } + } else if (p0->y < p1->y) { + q0 = *p0; + q1 = *p1; + cc0 = c0; + cc1 = c1; } else { - if (dx > 0) { - p.pole[0][0].x = pole[0].x + adjust; - p.pole[0][3].x = pole[3].x + adjust; - p.pole[3][0].x = pole[0].x - adjust; - p.pole[3][3].x = pole[3].x - adjust; - } else { - p.pole[0][0].x = pole[0].x - adjust; - p.pole[0][3].x = pole[3].x - adjust; - p.pole[3][0].x = pole[0].x + adjust; - p.pole[3][3].x = pole[3].x + adjust; - } - if (dy > 0) { - p.pole[0][0].y = pole[0].y - adjust; - p.pole[0][3].y = pole[3].y + adjust; - p.pole[3][0].y = pole[0].y - adjust; - p.pole[3][3].y = pole[3].y + adjust; - } else { - p.pole[0][0].y = pole[0].y + adjust; - p.pole[0][3].y = pole[3].y - adjust; - p.pole[3][0].y = pole[0].y + adjust; - p.pole[3][3].y = pole[3].y - adjust; - } + q0 = *p1; + q1 = *p0; + cc0 = c1; + cc1 = c0; } - p.c[0][0] = p.c[1][0] = *c0; - p.c[0][1] = p.c[1][1] = *c1; - return triangles(pfs, &p); + le.start.x = q0.x - adjust; + re.start.x = q0.x + adjust; + le.start.y = re.start.y = q0.y - adjust; + le.end.x = q1.x - adjust; + re.end.x = q1.x + adjust; + le.end.y = re.end.y = q1.y + adjust; + return decompose_linear_color(pfs, &le, &re, le.start.y, le.end.y, swap_axes, cc0, cc1); } private int @@ -1521,7 +1508,7 @@ fill_wedges_aux(patch_fill_state_t *pfs, int k, int ka, return fill_wedges_aux(pfs, k / 2, ka, q[1], &c, c1, wedge_type); } else { if (INTERPATCH_PADDING && (wedge_type & interpatch_padding)) { - code = padding(pfs, pole, c0, c1); + code = padding(pfs, &pole[0], &pole[3], c0, c1); if (code < 0) return code; } |