1 $usage = "Usage: combine.pl { 8 | 16 } < pixman-combine.c.template";
3 $#ARGV == 0 or die $usage;
5 # Get the component size.
7 $size == 8 or $size == 16 or die $usage;
9 $pixel_size = $size * 4;
10 $half_pixel_size = $size * 2;
15 $suffix = "ULL" if $size > 8;
17 return "0x" . $str . $suffix;
20 # Generate mask strings.
22 $mask = "f" x $nibbles;
23 $zero_mask = "0" x $nibbles;
24 $one_half = "8" . "0" x ($nibbles - 1);
26 print "/* WARNING: This file is generated by combine.pl from combine.inc.\n";
27 print " Please edit one of those files rather than this one. */\n";
30 print "#line 1 \"pixman-combine.c.template\"\n";
33 $one_half_ = mask($one_half);
34 $g_mask = mask($mask . $zero_mask);
35 $b_mask = mask($mask . $zero_mask x 2);
36 $a_mask = mask($mask . $zero_mask x 3);
37 $rb_mask = mask($mask . $zero_mask . $mask);
38 $ag_mask = mask($mask . $zero_mask . $mask . $zero_mask);
39 $rb_one_half = mask($one_half . $zero_mask . $one_half);
40 $rb_mask_plus_one = mask("1" . $zero_mask x 2 . "1" . $zero_mask);
43 # Mask and 1/2 value for a single component.
44 s/#define COMPONENT_SIZE\b/$& $size/;
45 s/#define MASK\b/$& $mask_/;
46 s/#define ONE_HALF\b/$& $one_half_/;
48 # Shifts and masks for green, blue, and alpha.
49 s/#define G_SHIFT\b/$& $size/;
50 s/#define R_SHIFT\b/$& $size * 2/;
51 s/#define A_SHIFT\b/$& $size * 3/;
52 s/#define G_MASK\b/$& $g_mask/;
53 s/#define R_MASK\b/$& $b_mask/;
54 s/#define A_MASK\b/$& $a_mask/;
56 # Special values for dealing with red + blue at the same time.
57 s/#define RB_MASK\b/$& $rb_mask/;
58 s/#define AG_MASK\b/$& $ag_mask/;
59 s/#define RB_ONE_HALF\b/$& $rb_one_half/;
60 s/#define RB_MASK_PLUS_ONE\b/$& $rb_mask_plus_one/;
62 # Add 32/64 suffix to combining function types.
63 s/\bCombineFunc\b/CombineFunc$pixel_size/;
64 s/\bFbComposeFunctions\b/FbComposeFunctions$pixel_size/;
65 s/combine_width/combine_$pixel_size/;
66 s/_pixman_setup_combiner_functions_width/_pixman_setup_combiner_functions_$pixel_size/;
68 # Convert comp*_t values into the appropriate real types.
69 s/comp1_t/uint${size}_t/g;
70 s/comp2_t/uint${half_pixel_size}_t/g;
71 s/comp4_t/uint${pixel_size}_t/g;
73 # Change the function table name for the 64-bit version.
74 s/pixman_composeFunctions/pixman_composeFunctions64/ if $size == 16;
76 # Change the header for the 64-bit version
77 s/pixman-combine.h/pixman-combine64.h/ if $size == 16;
78 s/pixman-combine.h/pixman-combine32.h/ if $size == 8;