| 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/geometry.h" | 
|---|
| 7 | #include "mupdf/fitz/store.h" | 
|---|
| 8 | #include "mupdf/fitz/pixmap.h" | 
|---|
| 9 | #include "mupdf/fitz/compressed-buffer.h" | 
|---|
| 10 |  | 
|---|
| 11 | /* | 
|---|
| 12 | * The shading code uses gouraud shaded triangle meshes. | 
|---|
| 13 | */ | 
|---|
| 14 |  | 
|---|
| 15 | enum | 
|---|
| 16 | { | 
|---|
| 17 | FZ_FUNCTION_BASED = 1, | 
|---|
| 18 | FZ_LINEAR = 2, | 
|---|
| 19 | FZ_RADIAL = 3, | 
|---|
| 20 | FZ_MESH_TYPE4 = 4, | 
|---|
| 21 | FZ_MESH_TYPE5 = 5, | 
|---|
| 22 | FZ_MESH_TYPE6 = 6, | 
|---|
| 23 | FZ_MESH_TYPE7 = 7 | 
|---|
| 24 | }; | 
|---|
| 25 |  | 
|---|
| 26 | /* | 
|---|
| 27 | Structure is public to allow derived classes. Do not | 
|---|
| 28 | access the members directly. | 
|---|
| 29 | */ | 
|---|
| 30 | typedef struct fz_shade_s | 
|---|
| 31 | { | 
|---|
| 32 | fz_storable storable; | 
|---|
| 33 |  | 
|---|
| 34 | fz_rect bbox;		/* can be fz_infinite_rect */ | 
|---|
| 35 | fz_colorspace *colorspace; | 
|---|
| 36 |  | 
|---|
| 37 | fz_matrix matrix;	/* matrix from pattern dict */ | 
|---|
| 38 | int use_background;	/* background color for fills but not 'sh' */ | 
|---|
| 39 | float background[FZ_MAX_COLORS]; | 
|---|
| 40 |  | 
|---|
| 41 | /* Just to be confusing, PDF Shadings of Type 1 (Function Based | 
|---|
| 42 | * Shadings), do NOT use_function, but all the others do. This | 
|---|
| 43 | * is because Type 1 shadings take 2 inputs, whereas all the | 
|---|
| 44 | * others (when used with a function take 1 input. The type 1 | 
|---|
| 45 | * data is in the 'f' field of the union below. */ | 
|---|
| 46 | int use_function; | 
|---|
| 47 | float function[256][FZ_MAX_COLORS + 1]; | 
|---|
| 48 |  | 
|---|
| 49 | int type; /* function, linear, radial, mesh */ | 
|---|
| 50 | union | 
|---|
| 51 | { | 
|---|
| 52 | struct | 
|---|
| 53 | { | 
|---|
| 54 | int extend[2]; | 
|---|
| 55 | float coords[2][3]; /* (x,y,r) twice */ | 
|---|
| 56 | } l_or_r; | 
|---|
| 57 | struct | 
|---|
| 58 | { | 
|---|
| 59 | int vprow; | 
|---|
| 60 | int bpflag; | 
|---|
| 61 | int bpcoord; | 
|---|
| 62 | int bpcomp; | 
|---|
| 63 | float x0, x1; | 
|---|
| 64 | float y0, y1; | 
|---|
| 65 | float c0[FZ_MAX_COLORS]; | 
|---|
| 66 | float c1[FZ_MAX_COLORS]; | 
|---|
| 67 | } m; | 
|---|
| 68 | struct | 
|---|
| 69 | { | 
|---|
| 70 | fz_matrix matrix; | 
|---|
| 71 | int xdivs; | 
|---|
| 72 | int ydivs; | 
|---|
| 73 | float domain[2][2]; | 
|---|
| 74 | float *fn_vals; | 
|---|
| 75 | } f; | 
|---|
| 76 | } u; | 
|---|
| 77 |  | 
|---|
| 78 | fz_compressed_buffer *buffer; | 
|---|
| 79 | } fz_shade; | 
|---|
| 80 |  | 
|---|
| 81 | fz_shade *fz_keep_shade(fz_context *ctx, fz_shade *shade); | 
|---|
| 82 | void fz_drop_shade(fz_context *ctx, fz_shade *shade); | 
|---|
| 83 |  | 
|---|
| 84 | void fz_drop_shade_imp(fz_context *ctx, fz_storable *shade); | 
|---|
| 85 |  | 
|---|
| 86 | fz_rect fz_bound_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm); | 
|---|
| 87 |  | 
|---|
| 88 | void fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_colorspace *override_cs, fz_matrix ctm, fz_pixmap *dest, fz_color_params color_params, fz_irect bbox, const fz_overprint *eop); | 
|---|
| 89 |  | 
|---|
| 90 | /* | 
|---|
| 91 | *	Handy routine for processing mesh based shades | 
|---|
| 92 | */ | 
|---|
| 93 | typedef struct fz_vertex_s fz_vertex; | 
|---|
| 94 |  | 
|---|
| 95 | struct fz_vertex_s | 
|---|
| 96 | { | 
|---|
| 97 | fz_point p; | 
|---|
| 98 | float c[FZ_MAX_COLORS]; | 
|---|
| 99 | }; | 
|---|
| 100 |  | 
|---|
| 101 | /* | 
|---|
| 102 | Callback function type for use with | 
|---|
| 103 | fz_process_shade. | 
|---|
| 104 |  | 
|---|
| 105 | arg: Opaque pointer from fz_process_shade caller. | 
|---|
| 106 |  | 
|---|
| 107 | v: Pointer to a fz_vertex structure to populate. | 
|---|
| 108 |  | 
|---|
| 109 | c: Pointer to an array of floats used to populate v. | 
|---|
| 110 | */ | 
|---|
| 111 | typedef void (fz_shade_prepare_fn)(fz_context *ctx, void *arg, fz_vertex *v, const float *c); | 
|---|
| 112 |  | 
|---|
| 113 | /* | 
|---|
| 114 | Callback function type for use with | 
|---|
| 115 | fz_process_shade. | 
|---|
| 116 |  | 
|---|
| 117 | arg: Opaque pointer from fz_process_shade caller. | 
|---|
| 118 |  | 
|---|
| 119 | av, bv, cv: Pointers to a fz_vertex structure describing | 
|---|
| 120 | the corner locations and colors of a triangle to be | 
|---|
| 121 | filled. | 
|---|
| 122 | */ | 
|---|
| 123 | typedef void (fz_shade_process_fn)(fz_context *ctx, void *arg, fz_vertex *av, fz_vertex *bv, fz_vertex *cv); | 
|---|
| 124 |  | 
|---|
| 125 | void fz_process_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_rect scissor, | 
|---|
| 126 | fz_shade_prepare_fn *prepare, | 
|---|
| 127 | fz_shade_process_fn *process, | 
|---|
| 128 | void *process_arg); | 
|---|
| 129 |  | 
|---|
| 130 | #endif | 
|---|
| 131 |  | 
|---|