bigbiff | 673c7ae | 2020-12-02 19:44:56 -0500 | [diff] [blame^] | 1 | /* |
| 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 | /* extract red */ |
| 20 | .if \shift < 32 |
| 21 | dext $t0,\src,\shift+11,5 |
| 22 | .else |
| 23 | dextu $t0,\src,\shift+11,5 |
| 24 | .endif |
| 25 | mul $t0,$t0,\f |
| 26 | |
| 27 | /* extract green */ |
| 28 | .if \shift < 32 |
| 29 | dext $t1,\src,\shift+5,6 |
| 30 | .else |
| 31 | dextu $t1,\src,\shift+5,6 |
| 32 | .endif |
| 33 | mul $t1,$t1,\f |
| 34 | |
| 35 | /* extract blue */ |
| 36 | .if \shift < 32 |
| 37 | dext $t2,\src,\shift,5 |
| 38 | .else |
| 39 | dextu $t2,\src,\shift,5 |
| 40 | .endif |
| 41 | mul $t2,$t2,\f |
| 42 | |
| 43 | srl $t0,$t0,8 |
| 44 | srl $t1,$t1,8 |
| 45 | srl $t2,$t2,8 |
| 46 | addu $t0,$t0,\sR |
| 47 | addu $t1,$t1,\sG |
| 48 | addu \dreg,$t2,\sB |
| 49 | sll $t0,$t0,11 |
| 50 | sll $t1,$t1,5 |
| 51 | or \dreg,\dreg,$t0 |
| 52 | or \dreg,\dreg,$t1 |
| 53 | .endm |
| 54 | |
| 55 | .text |
| 56 | .balign 4 |
| 57 | |
| 58 | .global scanline_col32cb16blend_mips64 |
| 59 | .ent scanline_col32cb16blend_mips64 |
| 60 | scanline_col32cb16blend_mips64: |
| 61 | |
| 62 | /* check if count is zero */ |
| 63 | srl $v0,$a1,24 /* sA */ |
| 64 | beqz $a2,done |
| 65 | li $t0, 0x100 |
| 66 | srl $v1,$v0,7 |
| 67 | addu $v0,$v1,$v0 |
| 68 | subu $v0,$t0,$v0 /* f */ |
| 69 | ext $a3,$a1,3,5 /* sR */ |
| 70 | ext $a4,$a1,10,6 /* sG */ |
| 71 | ext $a5,$a1,19,5 /* sB */ |
| 72 | |
| 73 | /* check if cnt is at least 4 */ |
| 74 | addiu $a2,$a2,-4 |
| 75 | bltz $a2,tail |
| 76 | |
| 77 | loop_4pixels: |
| 78 | ld $t3,0($a0) |
| 79 | daddiu $a0,$a0,8 |
| 80 | addiu $a2,$a2,-4 |
| 81 | pixel $a6 $t3 $v0 $a3 $a4 $a5 0 |
| 82 | pixel $a7 $t3 $v0 $a3 $a4 $a5 16 |
| 83 | pixel $t8 $t3 $v0 $a3 $a4 $a5 32 |
| 84 | pixel $t9 $t3 $v0 $a3 $a4 $a5 48 |
| 85 | dins $a6,$a7,16,16 |
| 86 | dinsu $a6,$t8,32,16 |
| 87 | dinsu $a6,$t9,48,16 |
| 88 | sd $a6,-8($a0) |
| 89 | bgez $a2, loop_4pixels |
| 90 | |
| 91 | tail: |
| 92 | /* the pixel count underran, restore it now */ |
| 93 | addiu $a2,$a2,4 |
| 94 | |
| 95 | /* handle the last 0..3 pixels */ |
| 96 | beqz $a2,done |
| 97 | |
| 98 | loop_1pixel: |
| 99 | lhu $t3,0($a0) |
| 100 | daddiu $a0,$a0,2 |
| 101 | addiu $a2,$a2,-1 |
| 102 | pixel $a6 $t3 $v0 $a3 $a4 $a5 0 |
| 103 | sh $a6, -2($a0) |
| 104 | bnez $a2,loop_1pixel |
| 105 | |
| 106 | done: |
| 107 | j $ra |
| 108 | .end scanline_col32cb16blend_mips64 |