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

« back to all changes in this revision

Viewing changes to src/gxdevmem.h

  • 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: gxdevmem.h 8528 2008-02-17 22:32:15Z leonardo $ */
15
 
/* Structure and procedures for memory devices */
16
 
/* Requires gxdevice.h */
17
 
 
18
 
#ifndef gxdevmem_INCLUDED
19
 
#  define gxdevmem_INCLUDED
20
 
 
21
 
#include "gxrplane.h"
22
 
 
23
 
/*
24
 
 * A 'memory' device is essentially a stored bitmap.
25
 
 * There are several different kinds: 1-bit black and white,
26
 
 * 2-, 4-, and 8-bit mapped color, 16- and 24-bit RGB color,
27
 
 * and 32-bit CMYK color.  (16-bit uses 5/6/5 bits per color.)
28
 
 * All use the same structure, since it's so awkward to get the effect of
29
 
 * subclasses in C.
30
 
 *
31
 
 * Memory devices come in two flavors: standard, which always stores bytes
32
 
 * big-endian, and word-oriented, which stores bytes in the machine order
33
 
 * within 32-bit "words".  The source data for copy_mono and
34
 
 * copy_color must be in big-endian order, and since memory devices
35
 
 * also are guaranteed to allocate the bitmap consecutively,
36
 
 * the bitmap of a standard memory device can serve directly as input
37
 
 * to copy_mono or copy_color operations.  This is not true of word-oriented
38
 
 * memory devices, which are provided only in response to a request by
39
 
 * a customer with their own image processing library that uses this format.
40
 
 *
41
 
 * In addition to the device structure itself, memory devices require two
42
 
 * other pieces of storage: the bitmap, and a table of pointers to the scan
43
 
 * lines of the bitmap.  Clients have several options for allocating these:
44
 
 *
45
 
 *      1) Set bitmap_memory to an allocator before opening the device.
46
 
 *      With this option, opening the device allocates the bitmap and the
47
 
 *      line pointer table (contiguously), and closing the device frees
48
 
 *      them.
49
 
 *
50
 
 *      2) Set line_pointer_memory to an allocator, base to the base address
51
 
 *      of the bitmap, and raster to the length of each scan line (distance
52
 
 *      from one scan line to the next) before opening the device.  With
53
 
 *      this option, opening the device allocates the line table, but not
54
 
 *      the bitmap; closing the device frees the table.
55
 
 *
56
 
 *      3) Set line_pointer_memory but not base or raster.  Opening /
57
 
 *      closing the device will allocate / free the line pointer table, but
58
 
 *      the client must set the pointers with a subsequent call of
59
 
 *      gdev_mem_set_line_ptrs.
60
 
 *
61
 
 *      4) Set neither _memory field.  In this case, it's up to the client
62
 
 *      to call gdev_mem_set_line_ptrs and to manage storage for the
63
 
 *      line pointers and the bitmap.
64
 
 *
65
 
 * In cases (2) through (4), it is the client's responsibility to set
66
 
 * foreign_bits (and foreign_line_pointers, if the line pointers are not
67
 
 * contiguous with the bits) to tell the GC whether to trace the pointers.
68
 
 * By default, anything allocated by bitmap_memory or line_pointer_memory is
69
 
 * assumed GC'able (i.e., case (1) assumes that the bits + line pointers are
70
 
 * GC'able, and cases (2) and (3) assume that the line pointers are GC'able,
71
 
 * but not the bits), but the client can change the foreign_* flag(s) after
72
 
 * opening the device if this is not the case.
73
 
 */
74
 
#ifndef gx_device_memory_DEFINED
75
 
#  define gx_device_memory_DEFINED
76
 
typedef struct gx_device_memory_s gx_device_memory;
77
 
#endif
78
 
 
79
 
struct gx_device_memory_s {
80
 
    gx_device_forward_common;   /* (see gxdevice.h) */
81
 
    /*
82
 
     * The following may be set by the client before or just after
83
 
     * opening the device.  See above.
84
 
     */
85
 
    uint raster;                /* bytes per scan line */
86
 
    byte *base;
87
 
#define scan_line_base(dev,y) ((dev)->line_ptrs[y])
88
 
    gs_memory_t *bitmap_memory; /* allocator for bits + line pointers */
89
 
    bool foreign_bits;          /* if true, bits are not in GC-able space */
90
 
    gs_memory_t *line_pointer_memory;  /* allocate for line pointers */
91
 
    bool foreign_line_pointers;  /* if true, line_ptrs are not in GC-able space */
92
 
    /*
93
 
     * The following are only used for planar devices.  num_planes == 0
94
 
     * means this is a chunky device.  Note that for planar devices, we
95
 
     * require color_info.depth = the sum of the individual plane depths.
96
 
     */
97
 
    int num_planes;
98
 
    gx_render_plane_t planes[GX_DEVICE_COLOR_MAX_COMPONENTS];
99
 
    /*
100
 
     * End of client-initializable fields.
101
 
     */
102
 
    gs_matrix initial_matrix;   /* the initial transformation */
103
 
    byte **line_ptrs;           /* scan line pointers */
104
 
    /* Following is used for mapped color, */
105
 
    /* including 1-bit devices (to specify polarity). */
106
 
    gs_const_string palette;    /* RGB triples */
107
 
    /* Following is only used for 24-bit color. */
108
 
    struct _c24 {
109
 
        gx_color_index rgb;     /* cache key */
110
 
        bits32 rgbr, gbrg, brgb;        /* cache value */
111
 
    } color24;
112
 
    /* Following is only used for 40-bit color. */
113
 
    struct _c40 {
114
 
        gx_color_index abcde;   /* cache key */
115
 
        bits32 abcd, bcde, cdea, deab, eabc;    /* cache value */
116
 
    } color40;
117
 
    /* Following is only used for 48-bit color. */
118
 
    struct _c48 {
119
 
        gx_color_index abcdef;  /* cache key */
120
 
        bits32 abcd, cdef, efab;        /* cache value */
121
 
    } color48;
122
 
    /* Following is only used for 56-bit color. */
123
 
    struct _c56 {
124
 
        gx_color_index abcdefg; /* cache key */
125
 
        bits32 abcd, bcde, cdef, defg, efga, fgab, gabc;        /* cache value */
126
 
    } color56;
127
 
    /* Following is only used for 64-bit color. */
128
 
    struct _c64 {
129
 
        gx_color_index abcdefgh;        /* cache key */
130
 
        bits32 abcd, efgh;      /* cache value */
131
 
    } color64;
132
 
    /* Following are only used for alpha buffers. */
133
 
    /* The client initializes those marked with $; */
134
 
    /* they don't change after initialization. */
135
 
    gs_log2_scale_point log2_scale;     /* $ oversampling scale factors */
136
 
    int log2_alpha_bits;        /* $ log2 of # of alpha bits being produced */
137
 
    int mapped_x;               /* $ X value mapped to buffer X=0 */
138
 
    int mapped_y;               /* lowest Y value mapped to buffer */
139
 
    int mapped_height;          /* # of Y values mapped to buffer */
140
 
    int mapped_start;           /* local Y value corresponding to mapped_y */
141
 
    gx_color_index save_color;  /* last (only) color displayed */
142
 
    /* Following are used only for planar devices. */
143
 
    int plane_depth;            /* if non-zero, depth of all planes */
144
 
    int band_y; /* Debug purpose only. */
145
 
};
146
 
 
147
 
extern_st(st_device_memory);
148
 
#define public_st_device_memory() /* in gdevmem.c */\
149
 
  gs_public_st_composite_use_final(st_device_memory, gx_device_memory,\
150
 
    "gx_device_memory", device_memory_enum_ptrs, device_memory_reloc_ptrs,\
151
 
    gx_device_finalize)
152
 
#define st_device_memory_max_ptrs (st_device_forward_max_ptrs + 2)
153
 
#define mem_device_init_private\
154
 
        0,                      /* raster */\
155
 
        (byte *)0,              /* base */\
156
 
        0,                      /* bitmap_memory */\
157
 
        true,                   /* foreign_bits (default) */\
158
 
        0,                      /* line_pointer_memory */\
159
 
        true,                   /* foreign_line_pointers (default) */\
160
 
        0,                      /* num_planes (default) */\
161
 
        { { 0 } },              /* planes (only used for planar) */\
162
 
        { identity_matrix_body },       /* initial matrix (filled in) */\
163
 
        (byte **)0,             /* line_ptrs (filled in by mem_open) */\
164
 
        { (byte *)0, 0 },       /* palette (filled in for color) */\
165
 
        { gx_no_color_index },  /* color24 */\
166
 
        { gx_no_color_index },  /* color40 */\
167
 
        { gx_no_color_index },  /* color48 */\
168
 
        { gx_no_color_index },  /* color56 */\
169
 
        { gx_no_color_index },  /* color64 */\
170
 
        { 0, 0 }, 0,            /* scale, log2_alpha_bits */\
171
 
        0, 0, 0, 0,             /* mapped_* */\
172
 
        gx_no_color_index       /* save_color */
173
 
 
174
 
/*
175
 
 * Memory devices may have special setup requirements.  In particular, it
176
 
 * may not be obvious how much space to allocate for the bitmap.  Here is
177
 
 * the routine that computes this from the width and height.  Note that this
178
 
 * size includes both the bitmap and the line pointers.
179
 
 */
180
 
/* bits only */
181
 
int gdev_mem_bits_size(const gx_device_memory *mdev, int width,
182
 
                         int height, ulong *size);
183
 
/* line pointers only */
184
 
ulong gdev_mem_line_ptrs_size(const gx_device_memory *mdev, int width,
185
 
                              int height);
186
 
/* bits + line pointers */
187
 
int gdev_mem_data_size(const gx_device_memory *mdev, int width,
188
 
                         int height, ulong *size);
189
 
 
190
 
#define gdev_mem_bitmap_size(mdev, size)\
191
 
  gdev_mem_data_size(mdev, (mdev)->width, (mdev)->height, size)
192
 
 
193
 
/*
194
 
 * Do the inverse computation: given the device width and a buffer size,
195
 
 * compute the maximum height.
196
 
 */
197
 
int gdev_mem_max_height(const gx_device_memory * dev, int width, ulong size,
198
 
                bool page_uses_transparency);
199
 
 
200
 
/*
201
 
 * Compute the standard raster (data bytes per line) similarly.
202
 
 */
203
 
#define gdev_mem_raster(mdev)\
204
 
  gx_device_raster((const gx_device *)(mdev), true)
205
 
 
206
 
/* Determine the appropriate memory device for a given */
207
 
/* number of bits per pixel (0 if none suitable). */
208
 
const gx_device_memory *gdev_mem_device_for_bits(int);
209
 
 
210
 
/* Determine the word-oriented memory device for a given depth. */
211
 
const gx_device_memory *gdev_mem_word_device_for_bits(int);
212
 
 
213
 
/* Make a memory device. */
214
 
/* mem is 0 if the device is temporary and local, */
215
 
/* or the allocator that was used to allocate it if it is a real object. */
216
 
/* page_device is 1 if the device should be a page device, */
217
 
/* 0 if it should propagate this property from its target, or */
218
 
/* -1 if it should not be a page device. */
219
 
void gs_make_mem_mono_device(gx_device_memory * mdev, gs_memory_t * mem,
220
 
                             gx_device * target);
221
 
void gs_make_mem_device(gx_device_memory * mdev,
222
 
                        const gx_device_memory * mdproto,
223
 
                        gs_memory_t * mem, int page_device,
224
 
                        gx_device * target);
225
 
void gs_make_mem_abuf_device(gx_device_memory * adev, gs_memory_t * mem,
226
 
                             gx_device * target,
227
 
                             const gs_log2_scale_point * pscale,
228
 
                             int alpha_bits, int mapped_x);
229
 
void gs_make_mem_alpha_device(gx_device_memory * adev, gs_memory_t * mem,
230
 
                              gx_device * target, int alpha_bits);
231
 
 
232
 
/*
233
 
 * Open a memory device, only setting line pointers to a subset of its
234
 
 * scan lines.  Banding devices use this (see gxclread.c).
235
 
 */
236
 
int gdev_mem_open_scan_lines(gx_device_memory *mdev, int setup_height);
237
 
 
238
 
/*
239
 
 * Initialize the line pointers of a memory device.  base and/or line_ptrs
240
 
 * may be NULL, in which case the value already stored in the device is
241
 
 * used; if base is NULL, raster is also ignored and the existing value is
242
 
 * used.  Note that this takes raster and setup_height arguments.
243
 
 * If the base is not NULL and the device is planar, all planes must have
244
 
 * the same depth, since otherwise a single raster value is not sufficient.
245
 
 *
246
 
 * Note that setup_height may be less than height.  In this case, for
247
 
 * planar devices, only setup_height * num_planes line pointers are set,
248
 
 * in the expectation that the device's height will be reset to
249
 
 * setup_height.
250
 
 */
251
 
int gdev_mem_set_line_ptrs(gx_device_memory *mdev,
252
 
                           byte *base, int raster, byte **line_ptrs,
253
 
                           int setup_height);
254
 
 
255
 
/* Define whether a monobit memory device is inverted (black=1). */
256
 
void gdev_mem_mono_set_inverted(gx_device_memory * mdev, bool black_is_1);
257
 
 
258
 
/* Test whether a device is a memory device. */
259
 
bool gs_device_is_memory(const gx_device *);
260
 
 
261
 
/* Test whether a device is an alpha-buffering device. */
262
 
bool gs_device_is_abuf(const gx_device *);
263
 
 
264
 
#endif /* gxdevmem_INCLUDED */