Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1 | # |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 2 | # Copyright (C) 2015 The Android Open Source Project |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 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 | header: |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 18 | summary: Conversion Functions |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 19 | description: |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 20 | The functions below convert from a numerical vector type to another, |
| 21 | of from one color representation to another. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 22 | end: |
| 23 | |
| 24 | function: convert_#3#1 |
| 25 | version: 9 |
| 26 | attrib: const |
| 27 | w: 2, 3, 4 |
| 28 | t: u8, u16, u32, i8, i16, i32, f32 |
| 29 | t: u8, u16, u32, i8, i16, i32, f32 |
| 30 | ret: #3#1 |
| 31 | arg: #2#1 v, compatible(#3) |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 32 | summary: Convert numerical vectors |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 33 | description: |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 34 | Converts a vector from one numerical type to another. The conversion are |
| 35 | done entry per entry. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 36 | |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 37 | E.g calling <code>a = convert_short3(b)</code> is equivalent to doing |
| 38 | <code>a.x = (short)b.x; a.y = (short)b.y; a.z = (short)b.z;</code>. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 39 | |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 40 | Converting floating point values to integer types truncates. |
| 41 | |
| 42 | Converting numbers too large to fit the destination type yields undefined results. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 43 | For example, converting a float that contains 1.0e18 to a short is undefined. |
| 44 | Use @clamp() to avoid this. |
| 45 | end: |
| 46 | |
| 47 | function: convert_#3#1 |
| 48 | version: 21 |
| 49 | attrib: const |
| 50 | w: 2, 3, 4 |
| 51 | t: u64, i64, f64 |
| 52 | t: u64, i64, f64 |
| 53 | ret: #3#1 |
| 54 | arg: #2#1 v, compatible(#3) |
| 55 | end: |
| 56 | |
| 57 | function: convert_#3#1 |
| 58 | version: 21 |
| 59 | attrib: const |
| 60 | w: 2, 3, 4 |
| 61 | t: u64, i64, f64 |
| 62 | t: u8, u16, u32, i8, i16, i32, f32 |
| 63 | ret: #3#1 |
| 64 | arg: #2#1 v, compatible(#3) |
| 65 | end: |
| 66 | |
| 67 | function: convert_#3#1 |
| 68 | version: 21 |
| 69 | attrib: const |
| 70 | w: 2, 3, 4 |
| 71 | t: u8, u16, u32, i8, i16, i32, f32 |
| 72 | t: u64, i64, f64 |
| 73 | ret: #3#1 |
| 74 | arg: #2#1 v, compatible(#3) |
| 75 | end: |
| 76 | |
| 77 | function: rsPackColorTo8888 |
| 78 | attrib: const |
| 79 | ret: uchar4 |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 80 | arg: float r, "Red component." |
| 81 | arg: float g, "Green component." |
| 82 | arg: float b, "Blue component." |
| 83 | summary: Create a uchar4 RGBA from floats |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 84 | description: |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 85 | Packs three or four floating point RGBA values into a uchar4. The RGBA values should |
| 86 | be between 0.0 and 1.0 inclusive. Values outside of this range are clamped to |
| 87 | this range. However numbers greater than INT_MAX or less than INT_MIN can result |
| 88 | in undefined behavior. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 89 | |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 90 | If the alpha component is not specified, it is assumed to be 1.0, i.e. the |
| 91 | result will have an alpha set to 255. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 92 | test: none |
| 93 | end: |
| 94 | |
| 95 | function: rsPackColorTo8888 |
| 96 | attrib: const |
| 97 | ret: uchar4 |
| 98 | arg: float r |
| 99 | arg: float g |
| 100 | arg: float b |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 101 | arg: float a, "Alpha component." |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 102 | test: none |
| 103 | end: |
| 104 | |
| 105 | function: rsPackColorTo8888 |
| 106 | attrib: const |
| 107 | ret: uchar4 |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 108 | arg: float3 color, "Vector of 3 or 4 floats containing the R, G, B, and A values." |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 109 | test: none |
| 110 | end: |
| 111 | |
| 112 | function: rsPackColorTo8888 |
| 113 | attrib: const |
| 114 | ret: uchar4 |
| 115 | arg: float4 color |
| 116 | test: none |
| 117 | end: |
| 118 | |
| 119 | function: rsUnpackColor8888 |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 120 | # NOTE: The = below indicates that the generator should not add "overloadable" by default. |
| 121 | # We're doing this to stay backward compatible with the unusual declaration used when this |
| 122 | # function was introduced. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 123 | attrib: =const |
| 124 | ret: float4 |
| 125 | arg: uchar4 c |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 126 | summary: Create a float4 RGBA from uchar4 |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 127 | description: |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 128 | Unpacks a uchar4 color to float4. The resulting floats will be between 0.0 and |
| 129 | 1.0 inclusive. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 130 | test: none |
| 131 | end: |
| 132 | |
| 133 | function: rsYuvToRGBA_#2#1 |
| 134 | attrib: const |
| 135 | w: 4 |
| 136 | t: u8, f32 |
| 137 | ret: #2#1 |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 138 | arg: uchar y, "Luminance component" |
| 139 | arg: uchar u, "U chrominance component" |
| 140 | arg: uchar v, "V chrominance component" |
| 141 | summary: Convert a YUV value to RGBA |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 142 | description: |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 143 | Converts a color from a YUV representation to RGBA. |
| 144 | |
| 145 | We currently don't provide a function to do the reverse conversion. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 146 | test: none |
| 147 | end: |