1,7 → 1,26 |
/* WARNING: This file is generated by combine.pl from combine.inc. |
Please edit one of those files rather than this one. */ |
|
#line 1 "pixman-combine.c.template" |
/* |
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. |
* 2005 Lars Knoll & Zack Rusin, Trolltech |
* |
* Permission to use, copy, modify, distribute, and sell this software and its |
* documentation for any purpose is hereby granted without fee, provided that |
* the above copyright notice appear in all copies and that both that |
* copyright notice and this permission notice appear in supporting |
* documentation, and that the name of Keith Packard not be used in |
* advertising or publicity pertaining to distribution of the software without |
* specific, written prior permission. Keith Packard makes no |
* representations about the suitability of this software for any purpose. It |
* is provided "as is" without express or implied warranty. |
* |
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS |
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY |
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN |
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING |
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
* SOFTWARE. |
*/ |
#ifdef HAVE_CONFIG_H |
#include <config.h> |
#endif |
10,10 → 29,9 |
#include <string.h> |
|
#include "pixman-private.h" |
|
#include "pixman-combine32.h" |
|
/*** per channel helper functions ***/ |
/* component alpha helper functions */ |
|
static void |
combine_mask_ca (uint32_t *src, uint32_t *mask) |
95,15 → 113,11 |
/* |
* There are two ways of handling alpha -- either as a single unified value or |
* a separate value for each component, hence each macro must have two |
* versions. The unified alpha version has a 'U' at the end of the name, |
* the component version has a 'C'. Similarly, functions which deal with |
* versions. The unified alpha version has a 'u' at the end of the name, |
* the component version has a 'ca'. Similarly, functions which deal with |
* this difference will have two versions using the same convention. |
*/ |
|
/* |
* All of the composing functions |
*/ |
|
static force_inline uint32_t |
combine_mask (const uint32_t *src, const uint32_t *mask, int i) |
{ |
158,7 → 172,9 |
int i; |
|
if (!mask) |
{ |
memcpy (dest, src, width * sizeof (uint32_t)); |
} |
else |
{ |
for (i = 0; i < width; ++i) |
170,7 → 186,6 |
} |
} |
|
/* if the Src is opaque, call combine_src_u */ |
static void |
combine_over_u (pixman_implementation_t *imp, |
pixman_op_t op, |
181,18 → 196,61 |
{ |
int i; |
|
if (!mask) |
{ |
for (i = 0; i < width; ++i) |
{ |
uint32_t s = combine_mask (src, mask, i); |
uint32_t s = *(src + i); |
uint32_t a = ALPHA_8 (s); |
if (a == 0xFF) |
{ |
*(dest + i) = s; |
} |
else if (s) |
{ |
uint32_t d = *(dest + i); |
uint32_t ia = ALPHA_8 (~s); |
|
uint32_t ia = a ^ 0xFF; |
UN8x4_MUL_UN8_ADD_UN8x4 (d, ia, s); |
*(dest + i) = d; |
} |
} |
} |
else |
{ |
for (i = 0; i < width; ++i) |
{ |
uint32_t m = ALPHA_8 (*(mask + i)); |
if (m == 0xFF) |
{ |
uint32_t s = *(src + i); |
uint32_t a = ALPHA_8 (s); |
if (a == 0xFF) |
{ |
*(dest + i) = s; |
} |
else if (s) |
{ |
uint32_t d = *(dest + i); |
uint32_t ia = a ^ 0xFF; |
UN8x4_MUL_UN8_ADD_UN8x4 (d, ia, s); |
*(dest + i) = d; |
} |
} |
else if (m) |
{ |
uint32_t s = *(src + i); |
if (s) |
{ |
uint32_t d = *(dest + i); |
UN8x4_MUL_UN8 (s, m); |
UN8x4_MUL_UN8_ADD_UN8x4 (d, ALPHA_8 (~s), s); |
*(dest + i) = d; |
} |
} |
} |
} |
} |
|
/* if the Dst is opaque, this is a noop */ |
static void |
combine_over_reverse_u (pixman_implementation_t *imp, |
pixman_op_t op, |
213,7 → 271,6 |
} |
} |
|
/* if the Dst is opaque, call combine_src_u */ |
static void |
combine_in_u (pixman_implementation_t *imp, |
pixman_op_t op, |
233,7 → 290,6 |
} |
} |
|
/* if the Src is opaque, this is a noop */ |
static void |
combine_in_reverse_u (pixman_implementation_t *imp, |
pixman_op_t op, |
254,7 → 310,6 |
} |
} |
|
/* if the Dst is opaque, call combine_clear */ |
static void |
combine_out_u (pixman_implementation_t *imp, |
pixman_op_t op, |
274,7 → 329,6 |
} |
} |
|
/* if the Src is opaque, call combine_clear */ |
static void |
combine_out_reverse_u (pixman_implementation_t *imp, |
pixman_op_t op, |
295,9 → 349,6 |
} |
} |
|
/* if the Src is opaque, call combine_in_u */ |
/* if the Dst is opaque, call combine_over_u */ |
/* if both the Src and Dst are opaque, call combine_src_u */ |
static void |
combine_atop_u (pixman_implementation_t *imp, |
pixman_op_t op, |
320,9 → 371,6 |
} |
} |
|
/* if the Src is opaque, call combine_over_reverse_u */ |
/* if the Dst is opaque, call combine_in_reverse_u */ |
/* if both the Src and Dst are opaque, call combine_dst_u */ |
static void |
combine_atop_reverse_u (pixman_implementation_t *imp, |
pixman_op_t op, |
345,9 → 393,6 |
} |
} |
|
/* if the Src is opaque, call combine_over_u */ |
/* if the Dst is opaque, call combine_over_reverse_u */ |
/* if both the Src and Dst are opaque, call combine_clear */ |
static void |
combine_xor_u (pixman_implementation_t *imp, |
pixman_op_t op, |
389,9 → 434,6 |
} |
} |
|
/* if the Src is opaque, call combine_add_u */ |
/* if the Dst is opaque, call combine_add_u */ |
/* if both the Src and Dst are opaque, call combine_add_u */ |
static void |
combine_saturate_u (pixman_implementation_t *imp, |
pixman_op_t op, |
441,7 → 483,7 |
* PDF_NON_SEPARABLE_BLEND_MODE macros, which take the blend function as an |
* argument. Note that this implementation operates on premultiplied colors, |
* while the PDF specification does not. Therefore the code uses the formula |
* ar.Cra = (1 – as) . Dca + (1 – ad) . Sca + B(Dca, ad, Sca, as) |
* Cra = (1 – as) . Dca + (1 – ad) . Sca + B(Dca, ad, Sca, as) |
*/ |
|
/* |
448,7 → 490,6 |
* Multiply |
* B(Dca, ad, Sca, as) = Dca.Sca |
*/ |
|
static void |
combine_multiply_u (pixman_implementation_t *imp, |
pixman_op_t op, |
493,7 → 534,7 |
uint32_t r = d; |
uint32_t dest_ia = ALPHA_8 (~d); |
|
combine_mask_value_ca (&s, &m); |
combine_mask_ca (&s, &m); |
|
UN8x4_MUL_UN8x4_ADD_UN8x4_MUL_UN8 (r, ~m, s, dest_ia); |
UN8x4_MUL_UN8x4 (d, s); |
526,7 → 567,7 |
UN8x4_MUL_UN8_ADD_UN8x4_MUL_UN8 (result, isa, s, ida); \ |
\ |
*(dest + i) = result + \ |
(DIV_ONE_UN8 (sa * da) << A_SHIFT) + \ |
(DIV_ONE_UN8 (sa * (uint32_t)da) << A_SHIFT) + \ |
(blend_ ## name (RED_8 (d), da, RED_8 (s), sa) << R_SHIFT) + \ |
(blend_ ## name (GREEN_8 (d), da, GREEN_8 (s), sa) << G_SHIFT) + \ |
(blend_ ## name (BLUE_8 (d), da, BLUE_8 (s), sa)); \ |
550,13 → 591,13 |
uint8_t ida = ~da; \ |
uint32_t result; \ |
\ |
combine_mask_value_ca (&s, &m); \ |
combine_mask_ca (&s, &m); \ |
\ |
result = d; \ |
UN8x4_MUL_UN8x4_ADD_UN8x4_MUL_UN8 (result, ~m, s, ida); \ |
\ |
result += \ |
(DIV_ONE_UN8 (ALPHA_8 (m) * da) << A_SHIFT) + \ |
(DIV_ONE_UN8 (ALPHA_8 (m) * (uint32_t)da) << A_SHIFT) + \ |
(blend_ ## name (RED_8 (d), da, RED_8 (s), RED_8 (m)) << R_SHIFT) + \ |
(blend_ ## name (GREEN_8 (d), da, GREEN_8 (s), GREEN_8 (m)) << G_SHIFT) + \ |
(blend_ ## name (BLUE_8 (d), da, BLUE_8 (s), BLUE_8 (m))); \ |
853,7 → 894,7 |
* |
* r * set_sat (C, s) = set_sat (x * C, r * s) |
* |
* The above holds for all non-zero x, because they x'es in the fraction for |
* The above holds for all non-zero x, because the x'es in the fraction for |
* C_mid cancel out. Specifically, it holds for x = r: |
* |
* r * set_sat (C, s) = set_sat (r_c, rs) |
889,8 → 930,7 |
* |
* a_s * a_d * B(s, d) |
* = a_s * a_d * set_lum (set_sat (S/a_s, SAT (D/a_d)), LUM (D/a_d), 1) |
* = a_s * a_d * set_lum (set_sat (a_d * S, a_s * SAT (D)), |
* a_s * LUM (D), a_s * a_d) |
* = set_lum (set_sat (a_d * S, a_s * SAT (D)), a_s * LUM (D), a_s * a_d) |
* |
*/ |
|
931,7 → 971,7 |
blend_ ## name (c, dc, da, sc, sa); \ |
\ |
*(dest + i) = result + \ |
(DIV_ONE_UN8 (sa * da) << A_SHIFT) + \ |
(DIV_ONE_UN8 (sa * (uint32_t)da) << A_SHIFT) + \ |
(DIV_ONE_UN8 (c[0]) << R_SHIFT) + \ |
(DIV_ONE_UN8 (c[1]) << G_SHIFT) + \ |
(DIV_ONE_UN8 (c[2])); \ |
1148,10 → 1188,8 |
#undef CH_MIN |
#undef PDF_NON_SEPARABLE_BLEND_MODE |
|
/* Overlay |
/* All of the disjoint/conjoint composing functions |
* |
* All of the disjoint composing functions |
* |
* The four entries in the first column indicate what source contributions |
* come from each of the four areas of the picture -- areas covered by neither |
* A nor B, areas covered only by A, areas covered only by B and finally |
1171,6 → 1209,9 |
* (0,0,B,A) max(1-(1-b)/a,0) min(1,(1-a)/b) min(1,b/a) max(1-a/b,0) |
* (0,A,0,B) min(1,(1-b)/a) max(1-(1-a)/b,0) max(1-b/a,0) min(1,a/b) |
* (0,A,B,0) min(1,(1-b)/a) min(1,(1-a)/b) max(1-b/a,0) max(1-a/b,0) |
* |
* See http://marc.info/?l=xfree-render&m=99792000027857&w=2 for more |
* information about these operators. |
*/ |
|
#define COMBINE_A_OUT 1 |
1583,10 → 1624,9 |
combine_conjoint_general_u (dest, src, mask, width, COMBINE_XOR); |
} |
|
/************************************************************************/ |
/*********************** Per Channel functions **************************/ |
/************************************************************************/ |
|
/* Component alpha combiners */ |
|
static void |
combine_clear_ca (pixman_implementation_t *imp, |
pixman_op_t op, |
2462,4 → 2502,3 |
imp->combine_32_ca[PIXMAN_OP_HSL_COLOR] = combine_dst; |
imp->combine_32_ca[PIXMAN_OP_HSL_LUMINOSITY] = combine_dst; |
} |
|