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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 $usage = "Usage: combine.pl { 8 | 16 } < pixman-combine.c.template";
     3 $#ARGV == 0 or die $usage;
     5 # Get the component size.
     6 $size = int($ARGV[0]);
     7 $size == 8 or $size == 16 or die $usage;
     9 $pixel_size = $size * 4;
    10 $half_pixel_size = $size * 2;
    12 sub mask {
    13     my $str = shift;
    14     my $suffix;
    15     $suffix = "ULL" if $size > 8;
    17     return "0x" . $str . $suffix;
    18 }
    20 # Generate mask strings.
    21 $nibbles = $size / 4;
    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";
    28 print "\n";
    30 print "#line 1 \"pixman-combine.c.template\"\n";
    32 $mask_ = mask($mask);
    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);
    42 while (<STDIN>) {
    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/;
    67     s/UNc/UN$size/g;
    68     s/ALPHA_c/ALPHA_$size/g;
    69     s/RED_c/RED_$size/g;
    70     s/GREEN_c/GREEN_$size/g;
    71     s/BLUE_c/BLUE_$size/g;
    73     # Convert comp*_t values into the appropriate real types.
    74     s/comp1_t/uint${size}_t/g;
    75     s/comp2_t/uint${half_pixel_size}_t/g;
    76     s/comp4_t/uint${pixel_size}_t/g;
    78     # Change the function table name for the 64-bit version.
    79     s/pixman_composeFunctions/pixman_composeFunctions64/ if $size == 16;
    81     # Change the header for the 64-bit version
    82     s/pixman-combine.h/pixman-combine64.h/ if $size == 16;
    83     s/pixman-combine.h/pixman-combine32.h/ if $size == 8;
    85     print;
    86 }

mercurial