gfx/cairo/libpixman/src/make-combine.pl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/cairo/libpixman/src/make-combine.pl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,86 @@
     1.4 +$usage = "Usage: combine.pl { 8 | 16 } < pixman-combine.c.template";
     1.5 +
     1.6 +$#ARGV == 0 or die $usage;
     1.7 +
     1.8 +# Get the component size.
     1.9 +$size = int($ARGV[0]);
    1.10 +$size == 8 or $size == 16 or die $usage;
    1.11 +
    1.12 +$pixel_size = $size * 4;
    1.13 +$half_pixel_size = $size * 2;
    1.14 +
    1.15 +sub mask {
    1.16 +    my $str = shift;
    1.17 +    my $suffix;
    1.18 +    $suffix = "ULL" if $size > 8;
    1.19 +
    1.20 +    return "0x" . $str . $suffix;
    1.21 +}
    1.22 +
    1.23 +# Generate mask strings.
    1.24 +$nibbles = $size / 4;
    1.25 +$mask = "f" x $nibbles;
    1.26 +$zero_mask = "0" x $nibbles;
    1.27 +$one_half = "8" . "0" x ($nibbles - 1);
    1.28 +
    1.29 +print "/* WARNING: This file is generated by combine.pl from combine.inc.\n";
    1.30 +print "   Please edit one of those files rather than this one. */\n";
    1.31 +print "\n";
    1.32 +
    1.33 +print "#line 1 \"pixman-combine.c.template\"\n";
    1.34 +
    1.35 +$mask_ = mask($mask);
    1.36 +$one_half_ = mask($one_half);
    1.37 +$g_mask = mask($mask . $zero_mask);
    1.38 +$b_mask = mask($mask . $zero_mask x 2);
    1.39 +$a_mask = mask($mask . $zero_mask x 3);
    1.40 +$rb_mask = mask($mask . $zero_mask . $mask);
    1.41 +$ag_mask = mask($mask . $zero_mask . $mask . $zero_mask);
    1.42 +$rb_one_half = mask($one_half . $zero_mask . $one_half);
    1.43 +$rb_mask_plus_one = mask("1" . $zero_mask x 2 . "1" .  $zero_mask);
    1.44 +
    1.45 +while (<STDIN>) {
    1.46 +    # Mask and 1/2 value for a single component.
    1.47 +    s/#define COMPONENT_SIZE\b/$& $size/;
    1.48 +    s/#define MASK\b/$& $mask_/;
    1.49 +    s/#define ONE_HALF\b/$& $one_half_/;
    1.50 +
    1.51 +    # Shifts and masks for green, blue, and alpha.
    1.52 +    s/#define G_SHIFT\b/$& $size/;
    1.53 +    s/#define R_SHIFT\b/$& $size * 2/;
    1.54 +    s/#define A_SHIFT\b/$& $size * 3/;
    1.55 +    s/#define G_MASK\b/$& $g_mask/;
    1.56 +    s/#define R_MASK\b/$& $b_mask/;
    1.57 +    s/#define A_MASK\b/$& $a_mask/;
    1.58 +
    1.59 +    # Special values for dealing with red + blue at the same time.
    1.60 +    s/#define RB_MASK\b/$& $rb_mask/;
    1.61 +    s/#define AG_MASK\b/$& $ag_mask/;
    1.62 +    s/#define RB_ONE_HALF\b/$& $rb_one_half/;
    1.63 +    s/#define RB_MASK_PLUS_ONE\b/$& $rb_mask_plus_one/;
    1.64 +
    1.65 +    # Add 32/64 suffix to combining function types.
    1.66 +    s/\bCombineFunc\b/CombineFunc$pixel_size/;
    1.67 +    s/\bFbComposeFunctions\b/FbComposeFunctions$pixel_size/;
    1.68 +    s/combine_width/combine_$pixel_size/;
    1.69 +    s/_pixman_setup_combiner_functions_width/_pixman_setup_combiner_functions_$pixel_size/;
    1.70 +    s/UNc/UN$size/g;
    1.71 +    s/ALPHA_c/ALPHA_$size/g;
    1.72 +    s/RED_c/RED_$size/g;
    1.73 +    s/GREEN_c/GREEN_$size/g;
    1.74 +    s/BLUE_c/BLUE_$size/g;
    1.75 +
    1.76 +    # Convert comp*_t values into the appropriate real types.
    1.77 +    s/comp1_t/uint${size}_t/g;
    1.78 +    s/comp2_t/uint${half_pixel_size}_t/g;
    1.79 +    s/comp4_t/uint${pixel_size}_t/g;
    1.80 +
    1.81 +    # Change the function table name for the 64-bit version.
    1.82 +    s/pixman_composeFunctions/pixman_composeFunctions64/ if $size == 16;
    1.83 +
    1.84 +    # Change the header for the 64-bit version
    1.85 +    s/pixman-combine.h/pixman-combine64.h/ if $size == 16;
    1.86 +    s/pixman-combine.h/pixman-combine32.h/ if $size == 8;
    1.87 +
    1.88 +    print;
    1.89 +}

mercurial