summaryrefslogtreecommitdiffstats
path: root/libpixelflinger/arch-mips/col32cb16blend.S
blob: 5d18e5533612377d67a1e541c2d1d28c7054373e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
** Copyright 2015, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/

       .macro pixel dreg src f sR sG sB shift

#if __mips==32 && __mips_isa_rev>=2
       /* extract red */
       ext $t4,\src,\shift+11,5
       mul $t4,$t4,\f

       /* extract green */
       ext $t5,\src,\shift+5,6
       mul $t5,$t5,\f

       /* extract blue */
       ext $t6,\src,\shift,5
       mul $t6,$t6,\f
#else
       /* extract red */
       srl $t4,\src,\shift+11
       andi $t4, 0x1f
       mul $t4,$t4,\f

       /* extract green */
       srl $t5,\src,\shift+5
       andi $t5, 0x3f
       mul $t5,$t5,\f

       /* extract blue */
       srl $t6,\src,\shift
       andi $t6, 0x1f
       mul $t6,$t6,\f
#endif

       srl $t4,$t4,8
       srl $t5,$t5,8
       srl $t6,$t6,8
       addu $t4,$t4,\sR
       addu $t5,$t5,\sG
       addu \dreg,$t6,\sB
       sll $t4,$t4,11
       sll $t5,$t5,5
       or \dreg,\dreg,$t4
       or \dreg,\dreg,$t5
       andi \dreg, 0xffff
       .endm

       .text
       .align

       .global scanline_col32cb16blend_mips
       .ent    scanline_col32cb16blend_mips
scanline_col32cb16blend_mips:

       /* check if count is zero */
       srl     $v0,$a1,24 /* sA */
       beqz    $a2,done
       li      $t4, 0x100
       srl     $v1,$v0,7
       addu    $v0,$v1,$v0
       subu    $v0,$t4,$v0 /* f */
#if __mips==32 && __mips_isa_rev>=2
       ext     $a3,$a1,3,5 /* sR */
       ext     $t0,$a1,10,6 /* sG */
       ext     $t1,$a1,19,5 /* sB */
#else
       srl     $a3, $a1, 3
       andi    $a3, 0x1f    /* sR */
       srl     $t0, $a1, 10
       andi    $t0, 0x3f    /* sG */
       srl     $t1, $a1, 19
       andi    $t1, 0x1f    /* sB */
#endif

       /* check if cnt is at least 4 */
       addiu   $a2,$a2,-4
       bltz    $a2,tail

loop_4pixels:
       lw      $t7,0($a0)
       lw      $t8,4($a0)
       addiu   $a0,$a0,8
       addiu   $a2,$a2,-4
       pixel   $t2 $t7 $v0 $a3 $t0 $t1 0
       pixel   $t3 $t7 $v0 $a3 $t0 $t1 16
#if __mips==32 && __mips_isa_rev>=2
       ins     $t2,$t3,16,16
#else
       sll $t3, 16
       or  $t2, $t2, $t3
#endif
       pixel   $t7 $t8 $v0 $a3 $t0 $t1 0
       pixel   $t3 $t8 $v0 $a3 $t0 $t1 16
#if __mips==32 && __mips_isa_rev>=2
       ins     $t7,$t3,16,16
#else
       sll $t3, 16
       or  $t7, $t7, $t3
#endif
       sw      $t2,-8($a0)
       sw      $t7,-4($a0)
       bgez    $a2, loop_4pixels

tail:
       /* the pixel count underran, restore it now */
       addiu   $a2,$a2,4

       /* handle the last 0..3 pixels */
       beqz    $a2,done

loop_1pixel:
       lhu     $t7,0($a0)
       addiu   $a0,$a0,2
       addiu   $a2,$a2,-1
       pixel   $t2 $t7 $v0 $a3 $t0 $t1 0
       sh      $t2, -2($a0)
       bnez    $a2,loop_1pixel

done:
       j       $ra
       .end    scanline_col32cb16blend_mips