diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-05-19 16:41:41 -0400 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2010-12-13 17:22:35 +0100 |
commit | 33843d4123f7a5c6128030b9d9e05e0e4a44232d (patch) | |
tree | d2b5b1ec4ee06944e80d8b8316f43f18ae765284 | |
parent | 206f596cf2d52f89cec740da796c07e807d3b71b (diff) |
Hook up non-separable PDF blend modes
-rw-r--r-- | pixman/pixman-combine-float.c | 92 |
1 files changed, 44 insertions, 48 deletions
diff --git a/pixman/pixman-combine-float.c b/pixman/pixman-combine-float.c index dd5aa06..abee5da 100644 --- a/pixman/pixman-combine-float.c +++ b/pixman/pixman-combine-float.c @@ -752,58 +752,56 @@ blend_hsl_luminosity (rgb_t *res, } #define MAKE_NON_SEPARABLE_PDF_COMBINERS(name) \ - static force_inline float \ - combine_ ## name ## _a (float sa, float s, float da, float d) \ - { \ - return da + sa - 2 * da * sa; \ - } \ - \ - static force_inline float \ - combine_ ## name ## _c (float sa, float s, float da, float d) \ - { \ - float f = (1 - sa) * d + (1 - da) * s; \ - \ - return f + blend_ ## name (sa, s, da, d); \ - } \ - \ static void \ - combine_ ## name ## _u (pixman_implementation_t *imp, \ - pixman_op_t op, \ - comp4_t *dest, \ - const comp4_t *src, \ - const comp4_t *mask, \ - int width) \ + combine_ ## name ## _u_float (pixman_implementation_t *imp, \ + pixman_op_t op, \ + float *dest, \ + const float *src, \ + const float *mask, \ + int n_pixels) \ { \ - int i; \ - for (i = 0; i < width; ++i) \ + int i; \ + \ + for (i = 0; i < 4 * n_pixels; i += 4) \ { \ - comp4_t s = combine_mask (src, mask, i); \ - comp4_t d = *(dest + i); \ - comp1_t sa = ALPHA_c (s); \ - comp1_t isa = ~sa; \ - comp1_t da = ALPHA_c (d); \ - comp1_t ida = ~da; \ - comp4_t result; \ - comp4_t sc[3], dc[3], c[3]; \ - \ - result = d; \ - UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (result, isa, s, ida); \ - dc[0] = RED_c (d); \ - sc[0] = RED_c (s); \ - dc[1] = GREEN_c (d); \ - sc[1] = GREEN_c (s); \ - dc[2] = BLUE_c (d); \ - sc[2] = BLUE_c (s); \ - blend_ ## name (c, dc, da, sc, sa); \ - \ - *(dest + i) = result + \ - (DIV_ONE_UNc (sa * da) << A_SHIFT) + \ - (DIV_ONE_UNc (c[0]) << R_SHIFT) + \ - (DIV_ONE_UNc (c[1]) << G_SHIFT) + \ - (DIV_ONE_UNc (c[2])); \ + float sa, da; \ + rgb_t sc, dc, rc; \ + \ + sa = src[i + 0]; \ + sc.r = src[i + 1]; \ + sc.g = src[i + 2]; \ + sc.b = src[i + 3]; \ + \ + da = dest[i + 0]; \ + dc.r = dest[i + 1]; \ + dc.g = dest[i + 2]; \ + dc.b = dest[i + 3]; \ + \ + if (mask) \ + { \ + float ma = mask[i + 0]; \ + \ + /* Component alpha is not supported for HSL modes */ \ + sa *= ma; \ + sc.r *= ma; \ + sc.g *= ma; \ + sc.g *= ma; \ + } \ + \ + blend_ ## name (&rc, &dc, da, &sc, sa); \ + \ + dest[i + 0] = sa + da - sa * da; \ + dest[i + 1] = rc.r; \ + dest[i + 2] = rc.g; \ + dest[i + 3] = rc.b; \ } \ } +MAKE_NON_SEPARABLE_PDF_COMBINERS(hsl_hue) +MAKE_NON_SEPARABLE_PDF_COMBINERS(hsl_saturation) +MAKE_NON_SEPARABLE_PDF_COMBINERS(hsl_color) +MAKE_NON_SEPARABLE_PDF_COMBINERS(hsl_luminosity) + void _pixman_setup_combiner_functions_width (pixman_implementation_t *imp) { @@ -864,12 +862,10 @@ _pixman_setup_combiner_functions_width (pixman_implementation_t *imp) imp->combine_float[PIXMAN_OP_DIFFERENCE] = combine_difference_u_float; imp->combine_float[PIXMAN_OP_EXCLUSION] = combine_exclusion_u_float; -#if 0 imp->combine_float[PIXMAN_OP_HSL_HUE] = combine_hsl_hue_u_float; imp->combine_float[PIXMAN_OP_HSL_SATURATION] = combine_hsl_saturation_u_float; imp->combine_float[PIXMAN_OP_HSL_COLOR] = combine_hsl_color_u_float; imp->combine_float[PIXMAN_OP_HSL_LUMINOSITY] = combine_hsl_luminosity_u_float; -#endif /* Component alpha combiners */ imp->combine_float_ca[PIXMAN_OP_CLEAR] = combine_clear_ca_float; |