From acf5738a82afb51a2284f5e61d9fac8dae7a47d5 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 16 Jul 2009 15:28:05 +0200 Subject: [PATCH] Clarify color dodge code - no semantical changes - Improve documentation to be equal to Proposed ISO32000 Extension - Simplify code in default case --- pixman/pixman-combine.c.template | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pixman/pixman-combine.c.template b/pixman/pixman-combine.c.template index 1168026..935b7b5 100644 --- a/pixman/pixman-combine.c.template +++ b/pixman/pixman-combine.c.template @@ -620,10 +620,12 @@ PDF_SEPARABLE_BLEND_MODE (lighten) /* * Color dodge * B(Dca, Da, Sca, Sa) = + * if Dca == 0 + * 0 * if Sca == Sa - * (Dca != 0).Sa.Da + * Sa.Da * otherwise - * Da.Sa. min (Dca / Da / (1 - Sca/Sa)) + * Sa.Da. min (1, Dca / Da / (1 - Sca/Sa)) */ static inline comp4_t blend_color_dodge (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) @@ -634,8 +636,8 @@ blend_color_dodge (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) } else { - comp4_t rca = dca * sa * sa / (sa - sca); - return DIV_ONE_UNc (rca > sa * da ? sa * da : rca); + comp4_t rca = dca * sa / (sa - sca); + return DIV_ONE_UNc (sa * MIN (rca, da)); } } -- 2.7.4