From 357162fe1eaec81638611d57ed178d8dfc3cdc47 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 25 Aug 2014 14:15:08 +0200 Subject: Allow NULL callback functions in the mesh processor. Let either or both of the 'prepare' and 'process' callbacks be no-ops. --- source/fitz/shade.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'source/fitz/shade.c') diff --git a/source/fitz/shade.c b/source/fitz/shade.c index 99a0b716..4c6b1472 100644 --- a/source/fitz/shade.c +++ b/source/fitz/shade.c @@ -5,7 +5,10 @@ static inline void paint_tri(fz_mesh_processor *painter, fz_vertex *v0, fz_vertex *v1, fz_vertex *v2) { - painter->process(painter->process_arg, v0, v1, v2); + if (painter->process) + { + painter->process(painter->process_arg, v0, v1, v2); + } } static inline void @@ -30,21 +33,30 @@ paint_quad(fz_mesh_processor *painter, fz_vertex *v0, fz_vertex *v1, fz_vertex * * the process functions where it matters order the edges from top to * bottom before walking them. */ - painter->process(painter->process_arg, v0, v1, v3); - painter->process(painter->process_arg, v3, v2, v1); + if (painter->process) + { + painter->process(painter->process_arg, v0, v1, v3); + painter->process(painter->process_arg, v3, v2, v1); + } } static inline void fz_prepare_color(fz_mesh_processor *painter, fz_vertex *v, float *c) { - painter->prepare(painter->process_arg, v, c); + if (painter->prepare) + { + painter->prepare(painter->process_arg, v, c); + } } static inline void fz_prepare_vertex(fz_mesh_processor *painter, fz_vertex *v, const fz_matrix *ctm, float x, float y, float *c) { fz_transform_point_xy(&v->p, ctm, x, y); - painter->prepare(painter->process_arg, v, c); + if (painter->prepare) + { + painter->prepare(painter->process_arg, v, c); + } } static void -- cgit v1.2.3