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

« back to all changes in this revision

Viewing changes to base/gxshade4.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: gxshade4.h 8132 2007-07-16 21:24:42Z leonardo $ */
 
15
/* Internal definitions for triangle shading rendering */
 
16
 
 
17
#ifndef gxshade4_INCLUDED
 
18
#  define gxshade4_INCLUDED
 
19
 
 
20
/* Configuration flags for development needs only. Users should not modify them. */
 
21
#define USE_LINEAR_COLOR_PROCS 1 /* Old code = 0, new code = 1. */
 
22
 
 
23
#define QUADRANGLES 0 /* 0 = decompose by triangles, 1 = by quadrangles. */
 
24
/* The code QUADRANGLES 1 appears unuseful.
 
25
   We keep it because it stores a valuable code for constant_color_quadrangle,
 
26
   which decomposes a random quadrangle into 3 or 4 trapezoids.
 
27
   The color approximation looks worse than with triangles, and works some slower.
 
28
 */
 
29
#define INTERPATCH_PADDING (fixed_1 / 2) /* Emulate a trapping for poorly designed documents. */
 
30
/* When INTERPATCH_PADDING > 0, it generates paddings between patches,
 
31
   i.e. performs a patch expansion, being similar
 
32
   to the path adjustment in the filling algorithm.
 
33
   The expansion is an emulation of Adobe's trapping.
 
34
   The value specifies the width of paddings.
 
35
   We did some testing of Adobe RIP, and it looks as applying 
 
36
   same logicks as for clipping - any part of pixel inside.
 
37
   Therefore the expansion should be half pixel size.
 
38
 */
 
39
#define COLOR_CONTIGUITY 1 /* A smothness divisor for triangulation. */
 
40
/* This is a coefficient used to rich
 
41
   a better color contiguity. The value 1 corresponds to PLRM,
 
42
   bigger values mean more contiguity. The speed decreases as
 
43
   a square of COLOR_CONTIGUITY.
 
44
 */
 
45
#define LAZY_WEDGES 1 /* 0 = fill immediately, 1 = fill lazy. */
 
46
/* This mode delays creating wedges for a boundary until
 
47
   both neoghbour areas are painted. At that moment we can know
 
48
   all subdivision points for both right and left areas,
 
49
   and skip wedges for common points. Therefore the number of wadges 
 
50
   dramatically reduces, causing a significant speedup.
 
51
   The LAZY_WEDGES 0 mode was not systematically tested.
 
52
 */
 
53
#define VD_TRACE_DOWN 1 /* Developer's needs, not important for production. */
 
54
#define NOFILL_TEST 0 /* Developer's needs, must be off for production. */
 
55
#define SKIP_TEST 0 /* Developer's needs, must be off for production. */
 
56
/* End of configuration flags (we don't mean that users should modify the rest). */
 
57
 
 
58
typedef struct mesh_frame_s {   /* recursion frame */
 
59
    mesh_vertex_t va, vb, vc;   /* current vertices */
 
60
    bool check_clipping;
 
61
} mesh_frame_t;
 
62
/****** NEED GC DESCRIPTOR ******/
 
63
 
 
64
/*
 
65
 * Define the fill state structure for triangle shadings.  This is used
 
66
 * both for the Gouraud triangle shading types and for the Coons and
 
67
 * tensor patch types.
 
68
 *
 
69
 * The shading pointer is named pshm rather than psh in case subclasses
 
70
 * also want to store a pointer of a more specific type.
 
71
 */
 
72
#define mesh_fill_state_common\
 
73
  shading_fill_state_common;\
 
74
  const gs_shading_mesh_t *pshm;\
 
75
  gs_fixed_rect rect
 
76
typedef struct mesh_fill_state_s {
 
77
    mesh_fill_state_common;
 
78
} mesh_fill_state_t;
 
79
/****** NEED GC DESCRIPTOR ******/
 
80
 
 
81
typedef struct wedge_vertex_list_elem_s wedge_vertex_list_elem_t;
 
82
struct wedge_vertex_list_elem_s {
 
83
    gs_fixed_point p;
 
84
    int level;
 
85
    bool divide_count;
 
86
    wedge_vertex_list_elem_t *next, *prev;
 
87
};
 
88
typedef struct {
 
89
    bool last_side;
 
90
    wedge_vertex_list_elem_t *beg, *end;    
 
91
} wedge_vertex_list_t;
 
92
 
 
93
#define LAZY_WEDGES_MAX_LEVEL 9 /* memory consumption is 
 
94
    sizeof(wedge_vertex_list_elem_t) * LAZY_WEDGES_MAX_LEVEL * (1 << LAZY_WEDGES_MAX_LEVEL) */
 
95
 
 
96
#define SHADING_COLOR_STACK_SIZE 200; /* Should be enough for max 64 decomposition levels. */
 
97
 
 
98
/* Define a color to be used in curve rendering. */
 
99
/* This may be a real client color, or a parametric function argument. */
 
100
struct patch_color_s {
 
101
    float t[2];                 /* parametric value */
 
102
    gs_client_color cc;
 
103
    /* NOTE : The structure gs_client_color ends with a big array, but only few elements
 
104
       are used in most cases. Therefore sometimes we allocate a shorter area,
 
105
       so that ending elements are not allocated and must not be accessed/modified.
 
106
       The number of allocated elements are known from the shading color space
 
107
       and from patch_fill_state_s::num_components. */
 
108
};
 
109
 
 
110
#ifndef patch_color_t_DEFINED
 
111
#  define patch_color_t_DEFINED
 
112
typedef struct patch_color_s patch_color_t;
 
113
#endif
 
114
 
 
115
#ifndef gs_color_index_cache_DEFINED
 
116
#  define gs_color_index_cache_DEFINED
 
117
typedef struct gs_color_index_cache_s gs_color_index_cache_t;
 
118
#endif
 
119
 
 
120
#ifndef patch_fill_state_t_DEFINED
 
121
#  define patch_fill_state_t_DEFINED
 
122
typedef struct patch_fill_state_s  patch_fill_state_t;
 
123
#endif
 
124
 
 
125
/* Define the common state for rendering Coons and tensor patches. */
 
126
struct patch_fill_state_s {
 
127
    mesh_fill_state_common;
 
128
    const gs_function_t *Function;
 
129
    int function_arg_shift;
 
130
    bool vectorization;
 
131
    int n_color_args;
 
132
    fixed max_small_coord; /* Length restriction for intersection_of_small_bars. */
 
133
    wedge_vertex_list_elem_t *wedge_vertex_list_elem_buffer;
 
134
    wedge_vertex_list_elem_t *free_wedge_vertex;
 
135
    int wedge_vertex_list_elem_count;
 
136
    int wedge_vertex_list_elem_count_max;
 
137
    gs_client_color color_domain;
 
138
    fixed decomposition_limit;
 
139
    fixed fixed_flat;
 
140
    double smoothness;
 
141
    bool maybe_self_intersecting;
 
142
    bool monotonic_color;
 
143
    bool linear_color;
 
144
    bool unlinear;
 
145
    bool inside;
 
146
    int color_stack_size;
 
147
    int color_stack_step;
 
148
    byte *color_stack_ptr;
 
149
    byte *color_stack; /* A storage for shortened patch_color_t structures. */
 
150
    byte *color_stack_limit;
 
151
    gs_memory_t *memory; /* Where color_buffer is allocated. */
 
152
    gs_color_index_cache_t *pcic;
 
153
} ;
 
154
 
 
155
/* Define a structure for mesh or patch vertex. */
 
156
struct shading_vertex_s {
 
157
    gs_fixed_point p;
 
158
    const patch_color_t *c;
 
159
};
 
160
 
 
161
/* Define one segment (vertex and next control points) of a curve. */
 
162
typedef struct patch_curve_s {
 
163
    mesh_vertex_t vertex;
 
164
    gs_fixed_point control[2];
 
165
    bool straight;
 
166
} patch_curve_t;
 
167
 
 
168
typedef struct {
 
169
    const shading_vertex_t *p[2][2]; /* [v][u] */
 
170
    wedge_vertex_list_t *l0001, *l0111, *l1110, *l1000;
 
171
} quadrangle_patch;
 
172
 
 
173
/* Initialize the fill state for triangle shading. */
 
174
int mesh_init_fill_state(mesh_fill_state_t * pfs,
 
175
                          const gs_shading_mesh_t * psh,
 
176
                          const gs_fixed_rect * rect_clip,
 
177
                          gx_device * dev, gs_imager_state * pis);
 
178
 
 
179
int init_patch_fill_state(patch_fill_state_t *pfs);
 
180
bool term_patch_fill_state(patch_fill_state_t *pfs);
 
181
int gx_init_patch_fill_state_for_clist(gx_device *dev, patch_fill_state_t *pfs, gs_memory_t *memory);
 
182
 
 
183
int mesh_triangle(patch_fill_state_t *pfs, 
 
184
    const shading_vertex_t *p0, const shading_vertex_t *p1, const shading_vertex_t *p2);
 
185
 
 
186
int mesh_padding(patch_fill_state_t *pfs, const gs_fixed_point *p0, const gs_fixed_point *p1, 
 
187
            const patch_color_t *c0, const patch_color_t *c1);
 
188
 
 
189
int patch_fill(patch_fill_state_t * pfs, const patch_curve_t curve[4],
 
190
           const gs_fixed_point interior[4],
 
191
           void (*transform) (gs_fixed_point *, const patch_curve_t[4],
 
192
                              const gs_fixed_point[4], floatp, floatp));
 
193
 
 
194
int constant_color_quadrangle(patch_fill_state_t *pfs, const quadrangle_patch *p, bool self_intersecting);
 
195
 
 
196
int wedge_vertex_list_elem_buffer_alloc(patch_fill_state_t *pfs);
 
197
void wedge_vertex_list_elem_buffer_free(patch_fill_state_t *pfs);
 
198
 
 
199
void patch_resolve_color(patch_color_t * ppcr, const patch_fill_state_t *pfs);
 
200
 
 
201
int gx_shade_background(gx_device *pdev, const gs_fixed_rect *rect, 
 
202
        const gx_device_color *pdevc, gs_logical_operation_t log_op);
 
203
 
 
204
int patch_color_to_device_color(const patch_fill_state_t *pfs, 
 
205
        const patch_color_t *c, gx_device_color *pdevc);
 
206
 
 
207
byte *reserve_colors(patch_fill_state_t *pfs, patch_color_t *c0[], int n);
 
208
void release_colors(patch_fill_state_t *pfs, byte *ptr, int n);
 
209
 
 
210
dev_proc_fill_linear_color_triangle(gx_fill_triangle_small);
 
211
 
 
212
#endif /* gxshade4_INCLUDED */