blob: 810294c3a4e27b990d7a8f2e5038e2340cb04a22 [file] [log] [blame]
bigbiff673c7ae2020-12-02 19:44:56 -05001/*
2** Copyright 2015, The Android Open Source Project
3**
4** Licensed under the Apache License, Version 2.0 (the "License");
5** you may not use this file except in compliance with the License.
6** You may obtain a copy of the License at
7**
8** http://www.apache.org/licenses/LICENSE-2.0
9**
10** Unless required by applicable law or agreed to in writing, software
11** distributed under the License is distributed on an "AS IS" BASIS,
12** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13** See the License for the specific language governing permissions and
14** limitations under the License.
15*/
16
17 .macro pixel dreg src f sR sG sB shift
18
19#if __mips==32 && __mips_isa_rev>=2
20 /* extract red */
21 ext $t4,\src,\shift+11,5
22 mul $t4,$t4,\f
23
24 /* extract green */
25 ext $t5,\src,\shift+5,6
26 mul $t5,$t5,\f
27
28 /* extract blue */
29 ext $t6,\src,\shift,5
30 mul $t6,$t6,\f
31#else
32 /* extract red */
33 srl $t4,\src,\shift+11
34 andi $t4, 0x1f
35 mul $t4,$t4,\f
36
37 /* extract green */
38 srl $t5,\src,\shift+5
39 andi $t5, 0x3f
40 mul $t5,$t5,\f
41
42 /* extract blue */
43 srl $t6,\src,\shift
44 andi $t6, 0x1f
45 mul $t6,$t6,\f
46#endif
47
48 srl $t4,$t4,8
49 srl $t5,$t5,8
50 srl $t6,$t6,8
51 addu $t4,$t4,\sR
52 addu $t5,$t5,\sG
53 addu \dreg,$t6,\sB
54 sll $t4,$t4,11
55 sll $t5,$t5,5
56 or \dreg,\dreg,$t4
57 or \dreg,\dreg,$t5
58 andi \dreg, 0xffff
59 .endm
60
61 .text
62 .balign 4
63
64 .global scanline_col32cb16blend_mips
65 .ent scanline_col32cb16blend_mips
66scanline_col32cb16blend_mips:
67
68 /* check if count is zero */
69 srl $v0,$a1,24 /* sA */
70 beqz $a2,done
71 li $t4, 0x100
72 srl $v1,$v0,7
73 addu $v0,$v1,$v0
74 subu $v0,$t4,$v0 /* f */
75#if __mips==32 && __mips_isa_rev>=2
76 ext $a3,$a1,3,5 /* sR */
77 ext $t0,$a1,10,6 /* sG */
78 ext $t1,$a1,19,5 /* sB */
79#else
80 srl $a3, $a1, 3
81 andi $a3, 0x1f /* sR */
82 srl $t0, $a1, 10
83 andi $t0, 0x3f /* sG */
84 srl $t1, $a1, 19
85 andi $t1, 0x1f /* sB */
86#endif
87
88 /* check if cnt is at least 4 */
89 addiu $a2,$a2,-4
90 bltz $a2,tail
91
92loop_4pixels:
93 lw $t7,0($a0)
94 lw $t8,4($a0)
95 addiu $a0,$a0,8
96 addiu $a2,$a2,-4
97 pixel $t2 $t7 $v0 $a3 $t0 $t1 0
98 pixel $t3 $t7 $v0 $a3 $t0 $t1 16
99#if __mips==32 && __mips_isa_rev>=2
100 ins $t2,$t3,16,16
101#else
102 sll $t3, 16
103 or $t2, $t2, $t3
104#endif
105 pixel $t7 $t8 $v0 $a3 $t0 $t1 0
106 pixel $t3 $t8 $v0 $a3 $t0 $t1 16
107#if __mips==32 && __mips_isa_rev>=2
108 ins $t7,$t3,16,16
109#else
110 sll $t3, 16
111 or $t7, $t7, $t3
112#endif
113 sw $t2,-8($a0)
114 sw $t7,-4($a0)
115 bgez $a2, loop_4pixels
116
117tail:
118 /* the pixel count underran, restore it now */
119 addiu $a2,$a2,4
120
121 /* handle the last 0..3 pixels */
122 beqz $a2,done
123
124loop_1pixel:
125 lhu $t7,0($a0)
126 addiu $a0,$a0,2
127 addiu $a2,$a2,-1
128 pixel $t2 $t7 $v0 $a3 $t0 $t1 0
129 sh $t2, -2($a0)
130 bnez $a2,loop_1pixel
131
132done:
133 j $ra
134 .end scanline_col32cb16blend_mips