enum fz_shade_type
{
FZ_FUNCTION_BASED = 1,
FZ_LINEAR = 2,
FZ_RADIAL = 3,
FZ_MESH_TYPE4 = 4,
FZ_MESH_TYPE5 = 5,
FZ_MESH_TYPE6 = 6,
FZ_MESH_TYPE7 = 7
}
The shading code uses gouraud shaded triangle meshes.
struct fz_shade
{
fz_storable storable;
fz_rect bbox; /* can be fz_infinite_rect */
fz_colorspace *colorspace;
fz_matrix matrix; /* matrix from pattern dict */
int use_background; /* background color for fills but not 'sh' */
float background[FZ_MAX_COLORS];
/* Just to be confusing, PDF Shadings of Type 1 (Function Based
* Shadings), do NOT use function, but all the others do. This
* is because Type 1 shadings take 2 inputs, whereas all the
* others (when used with a function take 1 input. The type 1
* data is in the 'f' field of the union below. */
/* If function_stride = 0, then function is not used. Otherwise
* function points to 256*function_stride entries. */
int function_stride;
float *function;
int type; /* function, linear, radial, mesh */
union
{
struct
{
int extend[2];
float coords[2][3]; /* (x,y,r) twice */
} l_or_r;
struct
{
int vprow;
int bpflag;
int bpcoord;
int bpcomp;
float x0, x1;
float y0, y1;
float c0[FZ_MAX_COLORS];
float c1[FZ_MAX_COLORS];
} m;
struct
{
fz_matrix matrix;
int xdivs;
int ydivs;
float domain[2][2];
float *fn_vals;
} f;
} u;
fz_compressed_buffer *buffer;
}
Structure is public to allow derived classes. Do not access the members directly.
fz_shade *
fz_keep_shade (
fz_context *ctx,
fz_shade *shade
)
Increment the reference count for the shade structure. The same pointer is returned.
Never throws exceptions.
void
fz_drop_shade (
fz_context *ctx,
fz_shade *shade
)
Decrement the reference count for the shade structure. When the reference count hits zero, the structure is freed.
Never throws exceptions.
fz_rect
fz_bound_shade (
fz_context *ctx,
fz_shade *shade,
fz_matrix ctm
)
Bound a given shading.
Returns r, updated to contain the bounds for the shading.
typedef struct fz_shade_color_cache fz_shade_color_cache
void
fz_drop_shade_color_cache (
fz_context *ctx,
fz_shade_color_cache *cache
)
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
)
Render a shade to a given pixmap.
struct fz_vertex
{
fz_point p;
float c[FZ_MAX_COLORS];
}
Vertexes used when processing mesh based shades.
typedef void (fz_shade_prepare_fn)(
fz_context *ctx,
void *arg,
fz_vertex *v,
const float *c
)
Callback function type for use with fz_process_shade.
typedef void (fz_shade_process_fn)(
fz_context *ctx,
void *arg,
fz_vertex *av,
fz_vertex *bv,
fz_vertex *cv
)
Callback function type for use with fz_process_shade.
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
)
Process a shade, using supplied callback functions. This decomposes the shading to a mesh (even ones that are not natively meshes, such as linear or radial shadings), and processes triangles from those meshes.
Implementation details: subject to change.
void
fz_drop_shade_imp (
fz_context *ctx,
fz_storable *shade
)
Internal function to destroy a shade. Only exposed for use with the fz_store.