mupdf
Loading...
Searching...
No Matches
shade.h
Go to the documentation of this file.
1// Copyright (C) 2004-2025 Artifex Software, Inc.
2//
3// This file is part of MuPDF.
4//
5// MuPDF is free software: you can redistribute it and/or modify it under the
6// terms of the GNU Affero General Public License as published by the Free
7// Software Foundation, either version 3 of the License, or (at your option)
8// any later version.
9//
10// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
11// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Affero General Public License
16// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
17//
18// Alternative licensing terms are available from the licensor.
19// For commercial licensing, see <https://www.artifex.com/> or contact
20// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
21// CA 94129, USA, for further information.
22
23#ifndef MUPDF_FITZ_SHADE_H
24#define MUPDF_FITZ_SHADE_H
25
26#include "mupdf/fitz/system.h"
27#include "mupdf/fitz/context.h"
28#include "mupdf/fitz/geometry.h"
29#include "mupdf/fitz/store.h"
30#include "mupdf/fitz/pixmap.h"
32
36
37enum
38{
46};
47
52typedef struct
53{
55
56 fz_rect bbox; /* can be fz_infinite_rect */
58
59 fz_matrix matrix; /* matrix from pattern dict */
60 int use_background; /* background color for fills but not 'sh' */
62
63 /* Just to be confusing, PDF Shadings of Type 1 (Function Based
64 * Shadings), do NOT use function, but all the others do. This
65 * is because Type 1 shadings take 2 inputs, whereas all the
66 * others (when used with a function take 1 input. The type 1
67 * data is in the 'f' field of the union below. */
68 /* If function_stride = 0, then function is not used. Otherwise
69 * function points to 256*function_stride entries. */
71 float *function;
72
73 int type; /* function, linear, radial, mesh */
74 union
75 {
76 struct
77 {
78 int extend[2];
79 float coords[2][3]; /* (x,y,r) twice */
80 } l_or_r;
81 struct
82 {
83 int vprow;
84 int bpflag;
86 int bpcomp;
87 float x0, x1;
88 float y0, y1;
91 } m;
92 struct
93 {
94 fz_matrix matrix;
95 int xdivs;
96 int ydivs;
97 float domain[2][2];
98 float *fn_vals;
99 } f;
100 } u;
101
103} fz_shade;
104
112
120
133
135
137
161void 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, fz_shade_color_cache **cache);
162
166typedef struct
167{
170} fz_vertex;
171
182typedef void (fz_shade_prepare_fn)(fz_context *ctx, void *arg, fz_vertex *v, const float *c);
183
194typedef void (fz_shade_process_fn)(fz_context *ctx, void *arg, fz_vertex *av, fz_vertex *bv, fz_vertex *cv);
195
217void fz_process_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_rect scissor,
218 fz_shade_prepare_fn *prepare,
219 fz_shade_process_fn *process,
220 void *process_arg);
221
222
223/* Implementation details: subject to change. */
224
232
233#endif
@ FZ_MAX_COLORS
Definition color.h:102
void HEAP_TYPE_NAME HEAP_CONTAINER_TYPE v
Definition heap-imp.h:51
struct fz_overprint fz_overprint
Definition pixmap.h:41
void fz_shade_process_fn(fz_context *ctx, void *arg, fz_vertex *av, fz_vertex *bv, fz_vertex *cv)
Definition shade.h:194
struct fz_shade_color_cache fz_shade_color_cache
Definition shade.h:134
@ FZ_LINEAR
Definition shade.h:40
@ FZ_MESH_TYPE6
Definition shade.h:44
@ FZ_MESH_TYPE4
Definition shade.h:42
@ FZ_MESH_TYPE5
Definition shade.h:43
@ FZ_RADIAL
Definition shade.h:41
@ FZ_FUNCTION_BASED
Definition shade.h:39
@ FZ_MESH_TYPE7
Definition shade.h:45
void fz_drop_shade_imp(fz_context *ctx, fz_storable *shade)
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, fz_shade_color_cache **cache)
void fz_shade_prepare_fn(fz_context *ctx, void *arg, fz_vertex *v, const float *c)
Definition shade.h:182
fz_rect fz_bound_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm)
fz_shade * fz_keep_shade(fz_context *ctx, fz_shade *shade)
void fz_drop_shade_color_cache(fz_context *ctx, fz_shade_color_cache *cache)
void fz_process_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_rect scissor, fz_shade_prepare_fn *prepare, fz_shade_process_fn *process, void *process_arg)
void fz_drop_shade(fz_context *ctx, fz_shade *shade)
Definition color.h:72
Definition color.h:417
Definition compressed-buffer.h:93
Definition context.h:886
Definition geometry.h:248
Definition geometry.h:388
Definition pixmap.h:432
Definition geometry.h:187
Definition geometry.h:231
Definition shade.h:53
int vprow
Definition shade.h:83
float * function
Definition shade.h:71
float x0
Definition shade.h:87
float c1[FZ_MAX_COLORS]
Definition shade.h:90
fz_matrix matrix
Definition shade.h:59
int bpcoord
Definition shade.h:85
float * fn_vals
Definition shade.h:98
float y0
Definition shade.h:88
float domain[2][2]
Definition shade.h:97
fz_storable storable
Definition shade.h:54
float c0[FZ_MAX_COLORS]
Definition shade.h:89
fz_rect bbox
Definition shade.h:56
int xdivs
Definition shade.h:95
float y1
Definition shade.h:88
float coords[2][3]
Definition shade.h:79
int bpflag
Definition shade.h:84
float background[FZ_MAX_COLORS]
Definition shade.h:61
int use_background
Definition shade.h:60
int bpcomp
Definition shade.h:86
int type
Definition shade.h:73
float x1
Definition shade.h:87
int ydivs
Definition shade.h:96
int function_stride
Definition shade.h:70
int extend[2]
Definition shade.h:78
fz_colorspace * colorspace
Definition shade.h:57
fz_compressed_buffer * buffer
Definition shade.h:102
Definition store.h:76
Definition shade.h:167
float c[FZ_MAX_COLORS]
Definition shade.h:169
fz_point p
Definition shade.h:168