~ubuntu-branches/ubuntu/saucy/pixman/saucy-security

« back to all changes in this revision

Viewing changes to pixman/combine.pl

  • Committer: Bazaar Package Importer
  • Author(s): Julien Cristau
  • Date: 2009-09-28 18:12:47 UTC
  • mfrom: (1.1.8 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090928181247-3iehog63i50htejf
Tags: 0.16.2-1
* New upstream release (closes: #546849).
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
$usage = "Usage: combine.pl { 8 | 16 } < combine.inc";
2
 
 
3
 
$#ARGV == 0 or die $usage;
4
 
 
5
 
# Get the component size.
6
 
$size = int($ARGV[0]);
7
 
$size == 8 or $size == 16 or die $usage;
8
 
 
9
 
$pixel_size = $size * 4;
10
 
$half_pixel_size = $size * 2;
11
 
 
12
 
sub mask {
13
 
    my $str = shift;
14
 
    my $suffix;
15
 
    $suffix = "ULL" if $size > 8;
16
 
 
17
 
    return "0x" . $str . $suffix;
18
 
}
19
 
 
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);
25
 
 
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";
29
 
 
30
 
print "#line 1 \"combine.inc\"\n";
31
 
 
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);
41
 
 
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_/;
47
 
 
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/;
55
 
 
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/;
61
 
 
62
 
    # Add 32/64 suffix to combining function types.
63
 
    s/\bCombineFuncC\b/CombineFuncC$pixel_size/;
64
 
    s/\bCombineFuncU\b/CombineFuncU$pixel_size/;
65
 
    s/\bCombineMaskU\b/CombineMaskU$pixel_size/;
66
 
    s/\bFbComposeFunctions\b/FbComposeFunctions$pixel_size/;
67
 
 
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;
72
 
 
73
 
    # Change the function table name for the 64-bit version.
74
 
    s/pixman_composeFunctions/pixman_composeFunctions64/ if $size == 16;
75
 
 
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;
79
 
 
80
 
    print;
81
 
}