Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/* Copyright (C) 1998, 1999 Aladdin Enterprises.  All rights reserved.
2
 
3
  This software is provided AS-IS with no warranty, either express or
4
  implied.
5
 
6
  This software is distributed under license and may not be copied,
7
  modified or distributed except as expressly authorized under the terms
8
  of the license contained in the file LICENSE in this distribution.
9
 
10
  For more information about licensing, please refer to
11
  http://www.ghostscript.com/licensing/. For information on
12
  commercial licensing, go to http://www.artifex.com/licensing/ or
13
  contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14
  San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15
*/
16
 
17
/* $Id: gxshade4.h,v 1.41 2005/04/19 12:22:08 igor Exp $ */
18
/* Internal definitions for triangle shading rendering */
19
 
20
#ifndef gxshade4_INCLUDED
21
#  define gxshade4_INCLUDED
22
 
23
/* Configuration flags for development needs only. Users should not modify them. */
24
#define USE_LINEAR_COLOR_PROCS 1 /* Old code = 0, new code = 1. */
25
 
26
#define QUADRANGLES 0 /* 0 = decompose by triangles, 1 = by quadrangles. */
27
/* The code QUADRANGLES 1 appears unuseful.
28
   We keep it because it stores a valuable code for constant_color_quadrangle,
29
   which decomposes a random quadrangle into 3 or 4 trapezoids.
30
   The color approximation looks worse than with triangles, and works some slower.
31
 */
32
#define INTERPATCH_PADDING (fixed_1 / 2) /* Emulate a trapping for poorly designed documents. */
33
/* When INTERPATCH_PADDING > 0, it generates paddings between patches,
34
   i.e. performs a patch expansion, being similar
35
   to the path adjustment in the filling algorithm.
36
   The expansion is an emulation of Adobe's trapping.
37
   The value specifies the width of paddings.
38
   We did some testing of Adobe RIP, and it looks as applying 
39
   same logicks as for clipping - any part of pixel inside.
40
   Therefore the expansion should be half pixel size.
41
 */
42
#define COLOR_CONTIGUITY 1 /* A smothness divisor for triangulation. */
43
/* This is a coefficient used to rich
44
   a better color contiguity. The value 1 corresponds to PLRM,
45
   bigger values mean more contiguity. The speed decreases as
46
   a square of COLOR_CONTIGUITY.
47
 */
48
#define LAZY_WEDGES 1 /* 0 = fill immediately, 1 = fill lazy. */
49
/* This mode delays creating wedges for a boundary until
50
   both neoghbour areas are painted. At that moment we can know
51
   all subdivision points for both right and left areas,
52
   and skip wedges for common points. Therefore the number of wadges 
53
   dramatically reduces, causing a significant speedup.
54
   The LAZY_WEDGES 0 mode was not systematically tested.
55
 */
56
#define VD_TRACE_DOWN 1 /* Developer's needs, not important for production. */
57
#define NOFILL_TEST 0 /* Developer's needs, must be off for production. */
58
#define SKIP_TEST 0 /* Developer's needs, must be off for production. */
59
/* End of configuration flags (we don't mean that users should modify the rest). */
60
 
61
#define mesh_max_depth (16 * 3 + 1)	/* each recursion adds 3 entries */
62
typedef struct mesh_frame_s {	/* recursion frame */
63
    mesh_vertex_t va, vb, vc;	/* current vertices */
64
    bool check_clipping;
65
} mesh_frame_t;
66
/****** NEED GC DESCRIPTOR ******/
67
 
68
/*
69
 * Define the fill state structure for triangle shadings.  This is used
70
 * both for the Gouraud triangle shading types and for the Coons and
71
 * tensor patch types.
72
 *
73
 * The shading pointer is named pshm rather than psh in case subclasses
74
 * also want to store a pointer of a more specific type.
75
 */
76
#define mesh_fill_state_common\
77
  shading_fill_state_common;\
78
  const gs_shading_mesh_t *pshm;\
79
  gs_fixed_rect rect;\
80
  int depth;\
81
  mesh_frame_t frames[mesh_max_depth]
82
typedef struct mesh_fill_state_s {
83
    mesh_fill_state_common;
84
} mesh_fill_state_t;
85
/****** NEED GC DESCRIPTOR ******/
86
 
87
typedef struct wedge_vertex_list_elem_s wedge_vertex_list_elem_t;
88
struct wedge_vertex_list_elem_s {
89
    gs_fixed_point p;
90
    int level;
91
    bool divide_count;
92
    wedge_vertex_list_elem_t *next, *prev;
93
};
94
typedef struct {
95
    bool last_side;
96
    wedge_vertex_list_elem_t *beg, *end;    
97
} wedge_vertex_list_t;
98
 
99
#define LAZY_WEDGES_MAX_LEVEL 9 /* memory consumption is 
100
    sizeof(wedge_vertex_list_elem_t) * LAZY_WEDGES_MAX_LEVEL * (1 << LAZY_WEDGES_MAX_LEVEL) */
101
 
102
/* Define the common state for rendering Coons and tensor patches. */
103
typedef struct patch_fill_state_s {
104
    mesh_fill_state_common;
105
    const gs_function_t *Function;
106
    bool vectorization;
107
    int n_color_args;
108
    fixed max_small_coord; /* Length restriction for intersection_of_small_bars. */
109
    wedge_vertex_list_elem_t *wedge_vertex_list_elem_buffer;
110
    wedge_vertex_list_elem_t *free_wedge_vertex;
111
    int wedge_vertex_list_elem_count;
112
    int wedge_vertex_list_elem_count_max;
113
    gs_client_color color_domain;
114
    fixed fixed_flat;
115
    double smoothness;
116
    bool maybe_self_intersecting;
117
    bool monotonic_color;
118
    bool linear_color;
119
    bool unlinear;
120
    bool inside;
121
} patch_fill_state_t;
122
/* Define a color to be used in curve rendering. */
123
/* This may be a real client color, or a parametric function argument. */
124
typedef struct patch_color_s {
125
    float t[2];			/* parametric value */
126
    gs_client_color cc;
127
} patch_color_t;
128
 
129
/* Define a structure for mesh or patch vertex. */
130
struct shading_vertex_s {
131
    gs_fixed_point p;
132
    patch_color_t c;
133
};
134
 
135
/* Define one segment (vertex and next control points) of a curve. */
136
typedef struct patch_curve_s {
137
    mesh_vertex_t vertex;
138
    gs_fixed_point control[2];
139
    bool straight;
140
} patch_curve_t;
141
 
142
/* Initialize the fill state for triangle shading. */
143
int mesh_init_fill_state(mesh_fill_state_t * pfs,
144
			  const gs_shading_mesh_t * psh,
145
			  const gs_fixed_rect * rect_clip,
146
			  gx_device * dev, gs_imager_state * pis);
147
 
148
int init_patch_fill_state(patch_fill_state_t *pfs);
149
void term_patch_fill_state(patch_fill_state_t *pfs);
150
 
151
int mesh_triangle(patch_fill_state_t *pfs, 
152
    const shading_vertex_t *p0, const shading_vertex_t *p1, const shading_vertex_t *p2);
153
 
154
int mesh_padding(patch_fill_state_t *pfs, const gs_fixed_point *p0, const gs_fixed_point *p1, 
155
	    const patch_color_t *c0, const patch_color_t *c1);
156
 
157
int patch_fill(patch_fill_state_t * pfs, const patch_curve_t curve[4],
158
	   const gs_fixed_point interior[4],
159
	   void (*transform) (gs_fixed_point *, const patch_curve_t[4],
160
			      const gs_fixed_point[4], floatp, floatp));
161
 
162
int wedge_vertex_list_elem_buffer_alloc(patch_fill_state_t *pfs);
163
void wedge_vertex_list_elem_buffer_free(patch_fill_state_t *pfs);
164
 
165
void patch_resolve_color(patch_color_t * ppcr, const patch_fill_state_t *pfs);
166
 
167
int gx_shade_background(gx_device *pdev, const gs_fixed_rect *rect, 
168
	const gx_device_color *pdevc, gs_logical_operation_t log_op);
169
 
170
#endif /* gxshade4_INCLUDED */