Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
7858 views
1
#ifndef MUPDF_FITZ_SHADE_H
2
#define MUPDF_FITZ_SHADE_H
3
4
#include "mupdf/fitz/system.h"
5
#include "mupdf/fitz/context.h"
6
#include "mupdf/fitz/math.h"
7
#include "mupdf/fitz/store.h"
8
#include "mupdf/fitz/colorspace.h"
9
#include "mupdf/fitz/pixmap.h"
10
#include "mupdf/fitz/compressed-buffer.h"
11
12
/*
13
* The shading code uses gouraud shaded triangle meshes.
14
*/
15
16
enum
17
{
18
FZ_FUNCTION_BASED = 1,
19
FZ_LINEAR = 2,
20
FZ_RADIAL = 3,
21
FZ_MESH_TYPE4 = 4,
22
FZ_MESH_TYPE5 = 5,
23
FZ_MESH_TYPE6 = 6,
24
FZ_MESH_TYPE7 = 7
25
};
26
27
typedef struct fz_shade_s fz_shade;
28
29
struct fz_shade_s
30
{
31
fz_storable storable;
32
33
fz_rect bbox; /* can be fz_infinite_rect */
34
fz_colorspace *colorspace;
35
36
fz_matrix matrix; /* matrix from pattern dict */
37
int use_background; /* background color for fills but not 'sh' */
38
float background[FZ_MAX_COLORS];
39
40
int use_function;
41
float function[256][FZ_MAX_COLORS + 1];
42
43
int type; /* function, linear, radial, mesh */
44
union
45
{
46
struct
47
{
48
int extend[2];
49
float coords[2][3]; /* (x,y,r) twice */
50
} l_or_r;
51
struct
52
{
53
int vprow;
54
int bpflag;
55
int bpcoord;
56
int bpcomp;
57
float x0, x1;
58
float y0, y1;
59
float c0[FZ_MAX_COLORS];
60
float c1[FZ_MAX_COLORS];
61
} m;
62
struct
63
{
64
fz_matrix matrix;
65
int xdivs;
66
int ydivs;
67
float domain[2][2];
68
float *fn_vals;
69
} f;
70
} u;
71
72
fz_compressed_buffer *buffer;
73
};
74
75
fz_shade *fz_keep_shade(fz_context *ctx, fz_shade *shade);
76
void fz_drop_shade(fz_context *ctx, fz_shade *shade);
77
void fz_drop_shade_imp(fz_context *ctx, fz_storable *shade);
78
79
fz_rect *fz_bound_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_rect *r);
80
void fz_paint_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_pixmap *dest, const fz_irect *bbox);
81
82
/*
83
* Handy routine for processing mesh based shades
84
*/
85
typedef struct fz_vertex_s fz_vertex;
86
87
struct fz_vertex_s
88
{
89
fz_point p;
90
float c[FZ_MAX_COLORS];
91
};
92
93
typedef void (fz_mesh_prepare_fn)(fz_context *ctx, void *arg, fz_vertex *v, const float *c);
94
typedef void (fz_mesh_process_fn)(fz_context *ctx, void *arg, fz_vertex *av, fz_vertex *bv, fz_vertex *cv);
95
96
void fz_process_mesh(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm,
97
fz_mesh_prepare_fn *prepare, fz_mesh_process_fn *process, void *process_arg);
98
99
#ifndef NDEBUG
100
void fz_print_shade(fz_context *ctx, FILE *out, fz_shade *shade);
101
#endif
102
103
#endif
104
105