~ubuntu-branches/ubuntu/jaunty/ghostscript/jaunty-updates

« back to all changes in this revision

Viewing changes to src/zdps.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-01-20 16:40:45 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120164045-lnfhi0n30o5lwhwa
Tags: 8.64.dfsg.1~svn9377-0ubuntu1
* New upstream release (SVN rev 9377)
   o Fixes many bugs concerning PDF rendering, to make the PDF printing
     workflow correctly working.
   o Fixes long-standing bugs in many drivers, like input paper tray and
     duplex options not working for the built-in PCL 4, 5, 5c, 5e, and
     6/XL drivers, PDF input not working for bjc600, bjc800, and cups
     output devices, several options not working and uninitialized
     memory with cups output device.
   o Merged nearly all patches of the Ubuntu and Debian packages upstream.
   o Fixes LP: #317810, LP: #314439, LP: #314018.
* debian/patches/03_libpaper_support.dpatch,
  debian/patches/11_gs-cjk_font_glyph_handling_fix.dpatch,
  debian/patches/12_gs-cjk_vertical_writing_metrics_fix.dpatch,
  debian/patches/13_gs-cjk_cjkps_examples.dpatch,
  debian/patches/20_bbox_segv_fix.dpatch,
  debian/patches/21_brother_7x0_gdi_fix.dpatch,
  debian/patches/22_epsn_margin_workaround.dpatch,
  debian/patches/24_gs_man_fix.dpatch,
  debian/patches/25_toolbin_insecure_tmp_usage_fix.dpatch,
  debian/patches/26_assorted_script_fixes.dpatch,
  debian/patches/29_gs_css_fix.dpatch,
  debian/patches/30_ps2pdf_man_improvement.dpatch,
  debian/patches/31_fix-gc-sigbus.dpatch,
  debian/patches/34_ftbfs-on-hurd-fix.dpatch,
  debian/patches/35_disable_libcairo.dpatch,
  debian/patches/38_pxl-duplex.dpatch,
  debian/patches/39_pxl-resolution.dpatch,
  debian/patches/42_gs-init-ps-delaybind-fix.dpatch,
  debian/patches/45_bjc600-bjc800-pdf-input.dpatch,
  debian/patches/48_cups-output-device-pdf-duplex-uninitialized-memory-fix.dpatch,
  debian/patches/50_lips4-floating-point-exception.dpatch,
  debian/patches/52_cups-device-logging.dpatch,
  debian/patches/55_pcl-input-slot-fix.dpatch,
  debian/patches/57_pxl-input-slot-fix.dpatch,
  debian/patches/60_pxl-cups-driver-pdf.dpatch,
  debian/patches/62_onebitcmyk-pdf.dpatch,
  debian/patches/65_too-big-temp-files-1.dpatch,
  debian/patches/67_too-big-temp-files-2.dpatch,
  debian/patches/70_take-into-account-data-in-stream-buffer-before-refill.dpatch:
  Removed, applied upstream.
* debian/patches/01_docdir_fix_for_debian.dpatch,
  debian/patches/02_gs_man_fix_debian.dpatch,
  debian/patches/01_docdir-fix-for-debian.dpatch,
  debian/patches/02_docdir-fix-for-debian.dpatch: Renamed patches to
  make merging with Debian easier.
* debian/patches/32_improve-handling-of-media-size-changes-from-gv.dpatch, 
  debian/patches/33_bad-params-to-xinitimage-on-large-bitmaps.dpatch:
  regenerated for new source directory structure.
* debian/rules: Corrected paths to remove cidfmap (it is in Resource/Init/
  in GS 8.64) and to install headers (source paths are psi/ and base/ now).
* debian/rules: Remove all fontmaps, as DeFoMa replaces them.
* debian/local/pdftoraster/pdftoraster.c,
  debian/local/pdftoraster/pdftoraster.convs, debian/rules: Removed
  added pdftoraster filter and use the one which comes with Ghostscript.
* debian/ghostscript.links: s/8.63/8.64/

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2001-2006 Artifex Software, Inc.
2
 
   All Rights Reserved.
3
 
  
4
 
   This software is provided AS-IS with no warranty, either express or
5
 
   implied.
6
 
 
7
 
   This software is distributed under license and may not be copied, modified
8
 
   or distributed except as expressly authorized under the terms of that
9
 
   license.  Refer to licensing information at http://www.artifex.com/
10
 
   or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
11
 
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
 
*/
13
 
 
14
 
/* $Id: zdps.c 8250 2007-09-25 13:31:24Z giles $ */
15
 
/* Display PostScript extensions */
16
 
#include "ghost.h"
17
 
#include "oper.h"
18
 
#include "gsstate.h"
19
 
#include "gsdps.h"
20
 
#include "gsimage.h"
21
 
#include "gsiparm2.h"
22
 
#include "gxalloc.h"            /* for names_array in allocator */
23
 
#include "gxfixed.h"            /* for gxpath.h */
24
 
#include "gxpath.h"
25
 
#include "btoken.h"             /* for user_names_p */
26
 
#include "iddict.h"
27
 
#include "idparam.h"
28
 
#include "igstate.h"
29
 
#include "iimage2.h"
30
 
#include "iname.h"
31
 
#include "store.h"
32
 
 
33
 
/* Import the procedure for constructing user paths. */
34
 
extern int make_upath(i_ctx_t *, ref *, const gs_state *, gx_path *, bool);
35
 
 
36
 
/* ------ Graphics state ------ */
37
 
 
38
 
/* <screen_index> <x> <y> .setscreenphase - */
39
 
static int
40
 
zsetscreenphase(i_ctx_t *i_ctx_p)
41
 
{
42
 
    os_ptr op = osp;
43
 
    int code;
44
 
    long x, y;
45
 
 
46
 
    check_type(op[-2], t_integer);
47
 
    check_type(op[-1], t_integer);
48
 
    check_type(*op, t_integer);
49
 
    x = op[-1].value.intval;
50
 
    y = op->value.intval;
51
 
    if (x != (int)x || y != (int)y ||
52
 
        op[-2].value.intval < -1 ||
53
 
        op[-2].value.intval >= gs_color_select_count
54
 
        )
55
 
        return_error(e_rangecheck);
56
 
    code = gs_setscreenphase(igs, (int)x, (int)y,
57
 
                             (gs_color_select_t) op[-2].value.intval);
58
 
    if (code >= 0)
59
 
        pop(3);
60
 
    return code;
61
 
}
62
 
 
63
 
/* <screen_index> .currentscreenphase <x> <y> */
64
 
static int
65
 
zcurrentscreenphase(i_ctx_t *i_ctx_p)
66
 
{
67
 
    os_ptr op = osp;
68
 
    gs_int_point phase;
69
 
    int code;
70
 
 
71
 
    check_type(*op, t_integer);
72
 
    if (op->value.intval < -1 ||
73
 
        op->value.intval >= gs_color_select_count
74
 
        )
75
 
        return_error(e_rangecheck);
76
 
    code = gs_currentscreenphase(igs, &phase,
77
 
                                 (gs_color_select_t)op->value.intval);
78
 
    if (code < 0)
79
 
        return code;
80
 
    push(1);
81
 
    make_int(op - 1, phase.x);
82
 
    make_int(op, phase.y);
83
 
    return 0;
84
 
}
85
 
 
86
 
/* ------ Device-source images ------ */
87
 
 
88
 
/* <dict> .image2 - */
89
 
static int
90
 
zimage2(i_ctx_t *i_ctx_p)
91
 
{
92
 
    os_ptr op = osp;
93
 
    int code;
94
 
 
95
 
    check_type(*op, t_dictionary);
96
 
    check_dict_read(*op);
97
 
    {
98
 
        gs_image2_t image;
99
 
        ref *pDataSource;
100
 
 
101
 
        gs_image2_t_init(&image);
102
 
        if ((code = dict_matrix_param(imemory, op, "ImageMatrix",
103
 
                                      &image.ImageMatrix)) < 0 ||
104
 
            (code = dict_find_string(op, "DataSource", &pDataSource)) < 0 ||
105
 
            (code = dict_float_param(op, "XOrigin", 0.0,
106
 
                                     &image.XOrigin)) != 0 ||
107
 
            (code = dict_float_param(op, "YOrigin", 0.0,
108
 
                                     &image.YOrigin)) != 0 ||
109
 
            (code = dict_float_param(op, "Width", 0.0,
110
 
                                     &image.Width)) != 0 ||
111
 
            image.Width <= 0 ||
112
 
            (code = dict_float_param(op, "Height", 0.0,
113
 
                                     &image.Height)) != 0 ||
114
 
            image.Height <= 0 ||
115
 
            (code = dict_bool_param(op, "PixelCopy", false,
116
 
                                    &image.PixelCopy)) < 0
117
 
            )
118
 
            return (code < 0 ? code : gs_note_error(e_rangecheck));
119
 
        check_stype(*pDataSource, st_igstate_obj);
120
 
        image.DataSource = igstate_ptr(pDataSource);
121
 
        {
122
 
            ref *ignoref;
123
 
 
124
 
            if (dict_find_string(op, "UnpaintedPath", &ignoref) > 0) {
125
 
                check_dict_write(*op);
126
 
                image.UnpaintedPath = gx_path_alloc(imemory,
127
 
                                                    ".image2 UnpaintedPath");
128
 
                if (image.UnpaintedPath == 0)
129
 
                    return_error(e_VMerror);
130
 
            } else
131
 
                image.UnpaintedPath = 0;
132
 
        }
133
 
        code = process_non_source_image(i_ctx_p,
134
 
                                        (const gs_image_common_t *)&image,
135
 
                                        ".image2");
136
 
        if (image.UnpaintedPath) {
137
 
            ref rupath;
138
 
 
139
 
            if (code < 0)
140
 
                return code;
141
 
            if (gx_path_is_null(image.UnpaintedPath))
142
 
                make_null(&rupath);
143
 
            else
144
 
                code = make_upath(i_ctx_p, &rupath, igs, image.UnpaintedPath,
145
 
                                  false);
146
 
            gx_path_free(image.UnpaintedPath, ".image2 UnpaintedPath");
147
 
            if (code < 0)
148
 
                return code;
149
 
            code = idict_put_string(op, "UnpaintedPath", &rupath);
150
 
        }
151
 
    }
152
 
    if (code >= 0)
153
 
        pop(1);
154
 
    return code;
155
 
}
156
 
 
157
 
/* ------ View clipping ------ */
158
 
 
159
 
/* - viewclip - */
160
 
static int
161
 
zviewclip(i_ctx_t *i_ctx_p)
162
 
{
163
 
    return gs_viewclip(igs);
164
 
}
165
 
 
166
 
/* - eoviewclip - */
167
 
static int
168
 
zeoviewclip(i_ctx_t *i_ctx_p)
169
 
{
170
 
    return gs_eoviewclip(igs);
171
 
}
172
 
 
173
 
/* - initviewclip - */
174
 
static int
175
 
zinitviewclip(i_ctx_t *i_ctx_p)
176
 
{
177
 
    return gs_initviewclip(igs);
178
 
}
179
 
 
180
 
/* - viewclippath - */
181
 
static int
182
 
zviewclippath(i_ctx_t *i_ctx_p)
183
 
{
184
 
    return gs_viewclippath(igs);
185
 
}
186
 
 
187
 
/* ------ User names ------ */
188
 
 
189
 
/* <index> <name> defineusername - */
190
 
static int
191
 
zdefineusername(i_ctx_t *i_ctx_p)
192
 
{
193
 
    os_ptr op = osp;
194
 
    ref uname;
195
 
 
196
 
    check_int_ltu(op[-1], max_array_size);
197
 
    check_type(*op, t_name);
198
 
    if (user_names_p == 0) {
199
 
        int code = create_names_array(&user_names_p, imemory_local,
200
 
                                      "defineusername");
201
 
 
202
 
        if (code < 0)
203
 
            return code;
204
 
    }
205
 
    if (array_get(imemory, user_names_p, 
206
 
                  op[-1].value.intval, &uname) >= 0) {
207
 
        switch (r_type(&uname)) {
208
 
            case t_null:
209
 
                break;
210
 
            case t_name:
211
 
                if (name_eq(&uname, op))
212
 
                    goto ret;
213
 
                /* falls through */
214
 
            default:
215
 
                return_error(e_invalidaccess);
216
 
        }
217
 
    } else {                    /* Expand the array. */
218
 
        ref new_array;
219
 
        uint old_size = r_size(user_names_p);
220
 
        uint new_size = (uint) op[-1].value.intval + 1;
221
 
 
222
 
        if (new_size < 100)
223
 
            new_size = 100;
224
 
        else if (new_size > max_array_size / 2)
225
 
            new_size = max_array_size;
226
 
        else if (new_size >> 1 < old_size)
227
 
            new_size = (old_size > max_array_size / 2 ? max_array_size :
228
 
                        old_size << 1);
229
 
        else
230
 
            new_size <<= 1;
231
 
        /*
232
 
         * The user name array is allocated in stable local VM,
233
 
         * because it must be immune to save/restore.
234
 
         */
235
 
        {
236
 
            gs_ref_memory_t *slmem =
237
 
                (gs_ref_memory_t *)gs_memory_stable(imemory_local);
238
 
            int code;
239
 
 
240
 
            code = gs_alloc_ref_array(slmem, &new_array, a_all, new_size,
241
 
                                      "defineusername(new)");
242
 
            if (code < 0)
243
 
                return code;
244
 
            refcpy_to_new(new_array.value.refs, user_names_p->value.refs,
245
 
                          old_size, idmemory);
246
 
            refset_null(new_array.value.refs + old_size,
247
 
                        new_size - old_size);
248
 
            if (old_size)
249
 
                gs_free_ref_array(slmem, user_names_p, "defineusername(old)");
250
 
        }
251
 
        ref_assign(user_names_p, &new_array);
252
 
    }
253
 
    ref_assign(user_names_p->value.refs + op[-1].value.intval, op);
254
 
  ret:
255
 
    pop(2);
256
 
    return 0;
257
 
}
258
 
 
259
 
/* ------ Initialization procedure ------ */
260
 
 
261
 
const op_def zdps_op_defs[] =
262
 
{
263
 
                /* Graphics state */
264
 
    {"1.currentscreenphase", zcurrentscreenphase},
265
 
    {"3.setscreenphase", zsetscreenphase},
266
 
                /* Device-source images */
267
 
    {"1.image2", zimage2},
268
 
                /* View clipping */
269
 
    {"0eoviewclip", zeoviewclip},
270
 
    {"0initviewclip", zinitviewclip},
271
 
    {"0viewclip", zviewclip},
272
 
    {"0viewclippath", zviewclippath},
273
 
                /* User names */
274
 
    {"2defineusername", zdefineusername},
275
 
    op_def_end(0)
276
 
};