[gs-cvs] rev 7211 - trunk/gs/src
leonardo at ghostscript.com
leonardo at ghostscript.com
Fri Nov 17 17:50:22 PST 2006
Author: leonardo
Date: 2006-11-17 17:50:21 -0800 (Fri, 17 Nov 2006)
New Revision: 7211
Modified:
trunk/gs/src/gxshade.c
trunk/gs/src/gxshade.h
trunk/gs/src/gxshade4.c
trunk/gs/src/gxshade6.c
Log:
Fix (shadings) : Align coordinate data and color data to byte boundary.
DETAILS :
Debugged with CET 09-47K.PS SpecialTestJ02Test05 and
09-47K.PS SpecialTestJ02Test05
The old code didn't align to byte boundary.
PLRM requires to align "each vertex data" to byte boundary.
Howebver PLRM doesn't clearly explains, what does "each vertex data" mean.
We make GS to be compatible to CPSI with CET tests.
>From these tests we know that it wants to align color data when there is no flag,
and to align the flag only, when it presents. Actually we also align
whenever a vertex ends, because it looks reasonable.
We didn't find practical tests for all cases allowed by PLRM,
so this logick may need a further improvement.
EXPECTED DIFFERENCES :
None.
Modified: trunk/gs/src/gxshade.c
===================================================================
--- trunk/gs/src/gxshade.c 2006-11-17 23:58:38 UTC (rev 7210)
+++ trunk/gs/src/gxshade.c 2006-11-18 01:50:21 UTC (rev 7211)
@@ -41,6 +41,8 @@
const float[2], float *);
private int cs_next_array_decoded(shade_coord_stream_t *, int,
const float[2], float *);
+private void cs_packed_align(shade_coord_stream_t *cs, int radix);
+private void cs_array_align(shade_coord_stream_t *cs, int radix);
private bool cs_eod(const shade_coord_stream_t * cs);
/* Initialize a packed value stream. */
@@ -71,9 +73,11 @@
if (data_source_is_array(params->DataSource)) {
cs->get_value = cs_next_array_value;
cs->get_decoded = cs_next_array_decoded;
+ cs->align = cs_array_align;
} else {
cs->get_value = cs_next_packed_value;
cs->get_decoded = cs_next_packed_decoded;
+ cs->align = cs_packed_align;
}
cs->is_eod = cs_eod;
cs->left = 0;
@@ -195,6 +199,17 @@
return 0;
}
+private void
+cs_packed_align(shade_coord_stream_t *cs, int radix)
+{
+ cs->left = cs->left / radix * radix;
+}
+
+private void
+cs_array_align(shade_coord_stream_t *cs, int radix)
+{
+}
+
/* Get the next flag value. */
/* Note that this always starts a new data byte. */
int
@@ -282,12 +297,16 @@
/* Get the next vertex for a mesh element. */
int
-shade_next_vertex(shade_coord_stream_t * cs, shading_vertex_t * vertex, patch_color_t *c)
+shade_next_vertex(shade_coord_stream_t * cs, shading_vertex_t * vertex, patch_color_t *c, bool align_color_data)
{ /* Assuming p->c == c, provides a non-const access. */
int code = shade_next_coords(cs, &vertex->p, 1);
+ if (code >= 0 && align_color_data)
+ cs->align(cs, 8);
if (code >= 0)
code = shade_next_color(cs, c->cc.paint.values);
+ if (code >= 0)
+ cs->align(cs, 8); /* CET 09-47J.PS SpecialTestI04Test01. */
return code;
}
Modified: trunk/gs/src/gxshade.h
===================================================================
--- trunk/gs/src/gxshade.h 2006-11-17 23:58:38 UTC (rev 7210)
+++ trunk/gs/src/gxshade.h 2006-11-18 01:50:21 UTC (rev 7211)
@@ -117,6 +117,7 @@
int (*get_value)(shade_coord_stream_t *cs, int num_bits, uint *pvalue);
int (*get_decoded)(shade_coord_stream_t *cs, int num_bits,
const float decode[2], float *pvalue);
+ void (*align)(shade_coord_stream_t *cs, int radix);
bool (*is_eod)(const shade_coord_stream_t *cs);
};
@@ -150,7 +151,8 @@
int shade_next_color(shade_coord_stream_t * cs, float *pc);
/* Get the next vertex for a mesh element. */
-int shade_next_vertex(shade_coord_stream_t * cs, shading_vertex_t * vertex, patch_color_t *c);
+int shade_next_vertex(shade_coord_stream_t * cs, shading_vertex_t * vertex,
+ patch_color_t *c, bool align_color_data);
/*
Currently, all shading fill procedures follow the same algorithm:
Modified: trunk/gs/src/gxshade4.c
===================================================================
--- trunk/gs/src/gxshade4.c 2006-11-17 23:58:38 UTC (rev 7210)
+++ trunk/gs/src/gxshade4.c 2006-11-18 01:50:21 UTC (rev 7211)
@@ -48,9 +48,9 @@
private int
Gt_next_vertex(const gs_shading_mesh_t * psh, shade_coord_stream_t * cs,
- shading_vertex_t * vertex, patch_color_t *c)
+ shading_vertex_t * vertex, patch_color_t *c, bool align_color_data)
{
- int code = shade_next_vertex(cs, vertex, c);
+ int code = shade_next_vertex(cs, vertex, c, align_color_data);
if (code >= 0 && psh->params.Function) {
c->t[0] = c->cc.paint.values[0];
@@ -116,14 +116,15 @@
vc.c = cc = C[2];
shade_next_init(&cs, (const gs_shading_mesh_params_t *)&psh->params,
pis);
+ /* CET 09-47J.PS SpecialTestI04Test01 does not need the color data alignment. */
while ((flag = shade_next_flag(&cs, num_bits)) >= 0) {
switch (flag) {
default:
return_error(gs_error_rangecheck);
case 0:
- if ((code = Gt_next_vertex(pshm, &cs, &va, ca)) < 0 ||
+ if ((code = Gt_next_vertex(pshm, &cs, &va, ca, false)) < 0 ||
(code = shade_next_flag(&cs, num_bits)) < 0 ||
- (code = Gt_next_vertex(pshm, &cs, &vb, cb)) < 0 ||
+ (code = Gt_next_vertex(pshm, &cs, &vb, cb, false)) < 0 ||
(code = shade_next_flag(&cs, num_bits)) < 0
)
break;
@@ -138,7 +139,7 @@
vb = vc;
cb = cc;
vc.c = cc = c;
-v2: if ((code = Gt_next_vertex(pshm, &cs, &vc, cc)) < 0)
+v2: if ((code = Gt_next_vertex(pshm, &cs, &vc, cc, false)) < 0)
break;
if ((code = Gt_fill_triangle(&pfs, &va, &vb, &vc)) < 0)
break;
@@ -206,14 +207,15 @@
code = gs_note_error(gs_error_VMerror);
goto out;
}
+ /* CET 09-47K.PS SpecialTestJ02Test05 needs the color data alignment. */
for (i = 0; i < per_row; ++i) {
color_buffer_ptrs[i] = (patch_color_t *)(color_buffer + pfs.color_stack_step * i);
vertex[i].c = color_buffer_ptrs[i];
- if ((code = Gt_next_vertex(pshm, &cs, &vertex[i], color_buffer_ptrs[i])) < 0)
+ if ((code = Gt_next_vertex(pshm, &cs, &vertex[i], color_buffer_ptrs[i], true)) < 0)
goto out;
}
while (!seofp(cs.s)) {
- code = Gt_next_vertex(pshm, &cs, &next, cn);
+ code = Gt_next_vertex(pshm, &cs, &next, cn, true);
if (code < 0)
goto out;
for (i = 1; i < per_row; ++i) {
@@ -224,7 +226,7 @@
vertex[i - 1] = next;
color_buffer_ptrs[i - 1] = cn;
next.c = cn = c;
- code = Gt_next_vertex(pshm, &cs, &next, cn);
+ code = Gt_next_vertex(pshm, &cs, &next, cn, true);
if (code < 0)
goto out;
code = Gt_fill_triangle(&pfs, &vertex[i], &vertex[i - 1], &next);
Modified: trunk/gs/src/gxshade6.c
===================================================================
--- trunk/gs/src/gxshade6.c 2006-11-17 23:58:38 UTC (rev 7210)
+++ trunk/gs/src/gxshade6.c 2006-11-18 01:50:21 UTC (rev 7211)
@@ -177,6 +177,7 @@
num_colors)) < 0
)
return code;
+ cs->align(cs, 8); /* See shade_next_vertex. */
}
return 0;
}
More information about the gs-cvs
mailing list