[gs-commits] rev 11347 - trunk/gs/base
ken at ghostscript.com
ken at ghostscript.com
Wed Jun 2 07:46:58 UTC 2010
Author: ken
Date: 2010-06-02 07:46:57 +0000 (Wed, 02 Jun 2010)
New Revision: 11347
Modified:
trunk/gs/base/gdevpdfb.h
trunk/gs/base/gdevpdft.c
trunk/gs/base/gdevpdfv.c
trunk/gs/base/gdevpdfx.h
Log:
Fix pdfwrite, faulty matrix transformations for Shading dictionaries
Bug #691352 "cairo pdf mis-distilled"
Patterns in PDF are unpleasantly complicated by the need to transform the pattern to
the 'default co-ordinate space'. Normally this means that we undo the resolution scaling
which is normally applied to the CTM.
For page streams this works well, but for forms the 'default co-ordinate space' is
the space of the parent. For one level of form there is therefore no difference between
the page and the form. When forms are nested however, the lower form's space becomes
that of the parent. This means that patterns inside forms, which are nested inside
another form, need to be transformed to the parent form co-ordinate space, not the
page space.
Since we don't currently emit forms from pdfwrite for anything except transparency
groups what this means in practice is that we don't undo the CTM transformation if
we are rendering a pattern inside a form, nested inside at least one other form.
Expected Differences
These files show progressions with this change:
Buig690831.pdf
Bug690208.pdf
Bug690206.pdf
Bug690115.pdf
Catx5233.pdf
These files show progressions, but also show regressions or are still not properly
converted to PDF:
Bug688807.pdf
Bug689918.pdf
This does not conclude the work for bug #691352, and the two files which still exhibit
issues also require further work.
Modified: trunk/gs/base/gdevpdfb.h
===================================================================
--- trunk/gs/base/gdevpdfb.h 2010-06-01 17:41:20 UTC (rev 11346)
+++ trunk/gs/base/gdevpdfb.h 2010-06-02 07:46:57 UTC (rev 11347)
@@ -220,6 +220,7 @@
0, /* sbstack_size */
0, /* sbstack_depth */
0, /* sbstack */
+ 0, /* FormDepth */
0, /* substream_Resources */
1, /* pcm_color_info_index == DeviceRGB */
false, /* skip_colors */
Modified: trunk/gs/base/gdevpdft.c
===================================================================
--- trunk/gs/base/gdevpdft.c 2010-06-01 17:41:20 UTC (rev 11346)
+++ trunk/gs/base/gdevpdft.c 2010-06-02 07:46:57 UTC (rev 11347)
@@ -208,8 +208,10 @@
gs_no_id, &pres, false, pdev->params.CompressPages);
if (code < 0)
return code;
+ pdev->FormDepth++;
return pdf_make_form_dict(pdev, pparams, pis, group_dict, (cos_dict_t *)pres->object);
}
+ pdev->FormDepth++;
return 0;
}
@@ -218,6 +220,7 @@
{
int bottom = (pdev->ResourcesBeforeUsage ? 1 : 0);
+ pdev->FormDepth--;
if (!is_in_page(pdev))
return 0; /* corresponds to check in pdf_begin_transparency_group */
if (pdev->image_with_SMask) {
Modified: trunk/gs/base/gdevpdfv.c
===================================================================
--- trunk/gs/base/gdevpdfv.c 2010-06-01 17:41:20 UTC (rev 11346)
+++ trunk/gs/base/gdevpdfv.c 2010-06-02 07:46:57 UTC (rev 11347)
@@ -934,11 +934,17 @@
/*
* In PDF, the Matrix is the transformation from the pattern space to
* the *default* user coordinate space, not the current space.
+ * NB. For a form the default space is the parent. This means that when a
+ * form is nested inside a form, the default space is the space of the
+ * first form, and therefore we do *not* remove the resolution scaling.
*/
gs_currentmatrix(pinst->saved, &smat);
{
- double xscale = 72.0 / pdev->HWResolution[0],
+ double xscale = 1.0, yscale = 1.0;
+ if (pdev->FormDepth <= 1) {
+ xscale = 72.0 / pdev->HWResolution[0];
yscale = 72.0 / pdev->HWResolution[1];
+ }
smat.xx *= xscale, smat.yx *= xscale, smat.tx *= xscale;
smat.xy *= yscale, smat.yy *= yscale, smat.ty *= yscale;
Modified: trunk/gs/base/gdevpdfx.h
===================================================================
--- trunk/gs/base/gdevpdfx.h 2010-06-01 17:41:20 UTC (rev 11346)
+++ trunk/gs/base/gdevpdfx.h 2010-06-02 07:46:57 UTC (rev 11347)
@@ -611,6 +611,15 @@
int sbstack_depth;
pdf_substream_save *sbstack;
+ /* Temporary workaround. The only way to get forms out of pdfwrite at present
+ * is via a transparency group or mask operation. Ordinarily we don't care
+ * much about forms, but Patterns within forms need to be scaled to the
+ * CTM of the Pattern, not the default page co-ordinate system. We use
+ * this value to know if we are nested inside a form or not. If we are
+ * we don't undo the resolution co-ordinate transform.
+ */
+ int FormDepth;
+
/* Accessories */
cos_dict_t *substream_Resources; /* Substream resources */
gs_color_space_index pcm_color_info_index; /* Index of the ProcessColorModel space. */
More information about the gs-commits
mailing list