blob: 84596f90b32b90d1547a9115ecd512343d735d3e [file] [log] [blame]
bigbiff673c7ae2020-12-02 19:44:56 -05001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28 .text
29 .balign 0
30
31 .global scanline_col32cb16blend_arm64
32
33//
34// This function alpha blends a fixed color into a destination scanline, using
35// the formula:
36//
37// d = s + (((a + (a >> 7)) * d) >> 8)
38//
39// where d is the destination pixel,
40// s is the source color,
41// a is the alpha channel of the source color.
42//
43
44// x0 = destination buffer pointer
45// w1 = color value
46// w2 = count
47
48
49scanline_col32cb16blend_arm64:
50
51 lsr w5, w1, #24 // shift down alpha
52 mov w9, #0xff // create mask
53 add w5, w5, w5, lsr #7 // add in top bit
54 mov w4, #256 // create #0x100
55 sub w5, w4, w5 // invert alpha
56 and w10, w1, #0xff // extract red
57 and w12, w9, w1, lsr #8 // extract green
58 and w4, w9, w1, lsr #16 // extract blue
59 lsl w10, w10, #5 // prescale red
60 lsl w12, w12, #6 // prescale green
61 lsl w4, w4, #5 // prescale blue
62 lsr w9, w9, #2 // create dest green mask
63
641:
65 ldrh w8, [x0] // load dest pixel
66 subs w2, w2, #1 // decrement loop counter
67 lsr w6, w8, #11 // extract dest red
68 and w7, w9, w8, lsr #5 // extract dest green
69 and w8, w8, #0x1f // extract dest blue
70
71 madd w6, w6, w5, w10 // dest red * alpha + src red
72 madd w7, w7, w5, w12 // dest green * alpha + src green
73 madd w8, w8, w5, w4 // dest blue * alpha + src blue
74
75 lsr w6, w6, #8 // shift down red
76 lsr w7, w7, #8 // shift down green
77 lsl w6, w6, #11 // shift red into 565
78 orr w6, w6, w7, lsl #5 // shift green into 565
79 orr w6, w6, w8, lsr #8 // shift blue into 565
80
81 strh w6, [x0], #2 // store pixel to dest, update ptr
82 b.ne 1b // if count != 0, loop
83
84 ret
85
86
87