diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-07-05 16:56:32 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-07-05 17:05:08 +0100 |
commit | ee382eb9e03bd609bc0da95a77e7b7232d7e56d5 (patch) | |
tree | 6485a2e7144657a992c43f445fff6551ca827b5a /draw/draw_blend.c | |
parent | 8ff2db02dba00a0fbc53ee4c89dcab60aab181ec (diff) | |
download | mupdf-ee382eb9e03bd609bc0da95a77e7b7232d7e56d5.tar.xz |
Move to static inline functions from macros.
Instead of using macros for min/max/abs/clamp, we move to using
inline functions. These are more typesafe, and should produce
equivalent code on compilers that support inline (i.e. pretty much
everything we care about these days).
People can always do their own macro versions if they prefer.
Diffstat (limited to 'draw/draw_blend.c')
-rw-r--r-- | draw/draw_blend.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/draw/draw_blend.c b/draw/draw_blend.c index 8a751c08..e70699d4 100644 --- a/draw/draw_blend.c +++ b/draw/draw_blend.c @@ -63,12 +63,12 @@ static inline int fz_overlay_byte(int b, int s) static inline int fz_darken_byte(int b, int s) { - return MIN(b, s); + return fz_mini(b, s); } static inline int fz_lighten_byte(int b, int s) { - return MAX(b, s); + return fz_maxi(b, s); } static inline int fz_color_dodge_byte(int b, int s) @@ -111,7 +111,7 @@ static inline int fz_soft_light_byte(int b, int s) static inline int fz_difference_byte(int b, int s) { - return ABS(b - s); + return fz_absi(b - s); } static inline int fz_exclusion_byte(int b, int s) @@ -139,13 +139,13 @@ fz_luminosity_rgb(unsigned char *rd, unsigned char *gd, unsigned char *bd, int r if (delta > 0) { int max; - max = MAX(r, MAX(g, b)); + max = fz_maxi(r, fz_maxi(g, b)); scale = (max == y ? 0 : ((255 - y) << 16) / (max - y)); } else { int min; - min = MIN(r, MIN(g, b)); + min = fz_mini(r, fz_mini(g, b)); scale = (y == min ? 0 : (y << 16) / (y - min)); } r = y + (((r - y) * scale + 0x8000) >> 16); @@ -153,9 +153,9 @@ fz_luminosity_rgb(unsigned char *rd, unsigned char *gd, unsigned char *bd, int r b = y + (((b - y) * scale + 0x8000) >> 16); } - *rd = CLAMP(r, 0, 255); - *gd = CLAMP(g, 0, 255); - *bd = CLAMP(b, 0, 255); + *rd = fz_clampi(r, 0, 255); + *gd = fz_clampi(g, 0, 255); + *bd = fz_clampi(b, 0, 255); } static void @@ -167,20 +167,20 @@ fz_saturation_rgb(unsigned char *rd, unsigned char *gd, unsigned char *bd, int r int scale; int r, g, b; - minb = MIN(rb, MIN(gb, bb)); - maxb = MAX(rb, MAX(gb, bb)); + minb = fz_mini(rb, fz_mini(gb, bb)); + maxb = fz_maxi(rb, fz_maxi(gb, bb)); if (minb == maxb) { /* backdrop has zero saturation, avoid divide by 0 */ - gb = CLAMP(gb, 0, 255); + gb = fz_clampi(gb, 0, 255); *rd = gb; *gd = gb; *bd = gb; return; } - mins = MIN(rs, MIN(gs, bs)); - maxs = MAX(rs, MAX(gs, bs)); + mins = fz_mini(rs, fz_mini(gs, bs)); + maxs = fz_maxi(rs, fz_maxi(gs, bs)); scale = ((maxs - mins) << 16) / (maxb - minb); y = (rb * 77 + gb * 151 + bb * 28 + 0x80) >> 8; @@ -193,8 +193,8 @@ fz_saturation_rgb(unsigned char *rd, unsigned char *gd, unsigned char *bd, int r int scalemin, scalemax; int min, max; - min = MIN(r, MIN(g, b)); - max = MAX(r, MAX(g, b)); + min = fz_mini(r, fz_mini(g, b)); + max = fz_maxi(r, fz_maxi(g, b)); if (min < 0) scalemin = (y << 16) / (y - min); @@ -206,15 +206,15 @@ fz_saturation_rgb(unsigned char *rd, unsigned char *gd, unsigned char *bd, int r else scalemax = 0x10000; - scale = MIN(scalemin, scalemax); + scale = fz_mini(scalemin, scalemax); r = y + (((r - y) * scale + 0x8000) >> 16); g = y + (((g - y) * scale + 0x8000) >> 16); b = y + (((b - y) * scale + 0x8000) >> 16); } - *rd = CLAMP(r, 0, 255); - *gd = CLAMP(g, 0, 255); - *bd = CLAMP(b, 0, 255); + *rd = fz_clampi(r, 0, 255); + *gd = fz_clampi(g, 0, 255); + *bd = fz_clampi(b, 0, 255); } static void |