1*e1eccf28SAndroid Build Coastguard Worker# 2*e1eccf28SAndroid Build Coastguard Worker# Copyright (C) 2015 The Android Open Source Project 3*e1eccf28SAndroid Build Coastguard Worker# 4*e1eccf28SAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 5*e1eccf28SAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 6*e1eccf28SAndroid Build Coastguard Worker# You may obtain a copy of the License at 7*e1eccf28SAndroid Build Coastguard Worker# 8*e1eccf28SAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 9*e1eccf28SAndroid Build Coastguard Worker# 10*e1eccf28SAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 11*e1eccf28SAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 12*e1eccf28SAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*e1eccf28SAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 14*e1eccf28SAndroid Build Coastguard Worker# limitations under the License. 15*e1eccf28SAndroid Build Coastguard Worker# 16*e1eccf28SAndroid Build Coastguard Worker 17*e1eccf28SAndroid Build Coastguard Workerheader: 18*e1eccf28SAndroid Build Coastguard Workersummary: Conversion Functions 19*e1eccf28SAndroid Build Coastguard Workerdescription: 20*e1eccf28SAndroid Build Coastguard Worker The functions below convert from a numerical vector type to another, or from one color 21*e1eccf28SAndroid Build Coastguard Worker representation to another. 22*e1eccf28SAndroid Build Coastguard Workerend: 23*e1eccf28SAndroid Build Coastguard Worker 24*e1eccf28SAndroid Build Coastguard Workerfunction: convert_#3#1 25*e1eccf28SAndroid Build Coastguard Workerversion: 9 26*e1eccf28SAndroid Build Coastguard Workerattrib: const 27*e1eccf28SAndroid Build Coastguard Workerw: 2, 3, 4 28*e1eccf28SAndroid Build Coastguard Workert: u8, u16, u32, i8, i16, i32, f32 29*e1eccf28SAndroid Build Coastguard Workert: u8, u16, u32, i8, i16, i32, f32 30*e1eccf28SAndroid Build Coastguard Workerret: #3#1 31*e1eccf28SAndroid Build Coastguard Workerarg: #2#1 v, compatible(#3) 32*e1eccf28SAndroid Build Coastguard Workersummary: Convert numerical vectors 33*e1eccf28SAndroid Build Coastguard Workerdescription: 34*e1eccf28SAndroid Build Coastguard Worker Converts a vector from one numerical type to another. The conversion are done entry per entry. 35*e1eccf28SAndroid Build Coastguard Worker 36*e1eccf28SAndroid Build Coastguard Worker E.g calling <code>a = convert_short3(b);</code> is equivalent to doing 37*e1eccf28SAndroid Build Coastguard Worker <code>a.x = (short)b.x; a.y = (short)b.y; a.z = (short)b.z;</code>. 38*e1eccf28SAndroid Build Coastguard Worker 39*e1eccf28SAndroid Build Coastguard Worker Converting floating point values to integer types truncates. 40*e1eccf28SAndroid Build Coastguard Worker 41*e1eccf28SAndroid Build Coastguard Worker Converting numbers too large to fit the destination type yields undefined results. 42*e1eccf28SAndroid Build Coastguard Worker For example, converting a float that contains 1.0e18 to a short is undefined. 43*e1eccf28SAndroid Build Coastguard Worker Use @clamp() to avoid this. 44*e1eccf28SAndroid Build Coastguard Workerend: 45*e1eccf28SAndroid Build Coastguard Worker 46*e1eccf28SAndroid Build Coastguard Workerfunction: convert_#3#1 47*e1eccf28SAndroid Build Coastguard Workerversion: 21 48*e1eccf28SAndroid Build Coastguard Workerattrib: const 49*e1eccf28SAndroid Build Coastguard Workerw: 2, 3, 4 50*e1eccf28SAndroid Build Coastguard Workert: u64, i64, f64 51*e1eccf28SAndroid Build Coastguard Workert: u64, i64, f64 52*e1eccf28SAndroid Build Coastguard Workerret: #3#1 53*e1eccf28SAndroid Build Coastguard Workerarg: #2#1 v, compatible(#3) 54*e1eccf28SAndroid Build Coastguard Workerend: 55*e1eccf28SAndroid Build Coastguard Worker 56*e1eccf28SAndroid Build Coastguard Workerfunction: convert_#3#1 57*e1eccf28SAndroid Build Coastguard Workerversion: 21 58*e1eccf28SAndroid Build Coastguard Workerattrib: const 59*e1eccf28SAndroid Build Coastguard Workerw: 2, 3, 4 60*e1eccf28SAndroid Build Coastguard Workert: u64, i64, f64 61*e1eccf28SAndroid Build Coastguard Workert: u8, u16, u32, i8, i16, i32, f32 62*e1eccf28SAndroid Build Coastguard Workerret: #3#1 63*e1eccf28SAndroid Build Coastguard Workerarg: #2#1 v, compatible(#3) 64*e1eccf28SAndroid Build Coastguard Workerend: 65*e1eccf28SAndroid Build Coastguard Worker 66*e1eccf28SAndroid Build Coastguard Workerfunction: convert_#3#1 67*e1eccf28SAndroid Build Coastguard Workerversion: 21 68*e1eccf28SAndroid Build Coastguard Workerattrib: const 69*e1eccf28SAndroid Build Coastguard Workerw: 2, 3, 4 70*e1eccf28SAndroid Build Coastguard Workert: u8, u16, u32, i8, i16, i32, f32 71*e1eccf28SAndroid Build Coastguard Workert: u64, i64, f64 72*e1eccf28SAndroid Build Coastguard Workerret: #3#1 73*e1eccf28SAndroid Build Coastguard Workerarg: #2#1 v, compatible(#3) 74*e1eccf28SAndroid Build Coastguard Workerend: 75*e1eccf28SAndroid Build Coastguard Worker 76*e1eccf28SAndroid Build Coastguard Workerfunction: convert_#3#1 77*e1eccf28SAndroid Build Coastguard Workerversion: 24 78*e1eccf28SAndroid Build Coastguard Workerattrib: const 79*e1eccf28SAndroid Build Coastguard Workerw: 2, 3, 4 80*e1eccf28SAndroid Build Coastguard Workert: f16 81*e1eccf28SAndroid Build Coastguard Workert: u8, u16, u32, u64, i8, i16, i32, i64, f16, f32, f64 82*e1eccf28SAndroid Build Coastguard Workerret: #3#1 83*e1eccf28SAndroid Build Coastguard Workerarg: #2#1 v, compatible(#3) 84*e1eccf28SAndroid Build Coastguard Workerend: 85*e1eccf28SAndroid Build Coastguard Worker 86*e1eccf28SAndroid Build Coastguard Workerfunction: convert_#3#1 87*e1eccf28SAndroid Build Coastguard Workerversion: 24 88*e1eccf28SAndroid Build Coastguard Workerattrib: const 89*e1eccf28SAndroid Build Coastguard Workerw: 2, 3, 4 90*e1eccf28SAndroid Build Coastguard Workert: u8, u16, u32, u64, i8, i16, i32, i64, f32, f64 91*e1eccf28SAndroid Build Coastguard Workert: f16 92*e1eccf28SAndroid Build Coastguard Workerret: #3#1 93*e1eccf28SAndroid Build Coastguard Workerarg: #2#1 v, compatible(#3) 94*e1eccf28SAndroid Build Coastguard Workerend: 95*e1eccf28SAndroid Build Coastguard Worker 96*e1eccf28SAndroid Build Coastguard Workerfunction: rsPackColorTo8888 97*e1eccf28SAndroid Build Coastguard Workerattrib: const 98*e1eccf28SAndroid Build Coastguard Workerret: uchar4 99*e1eccf28SAndroid Build Coastguard Workerarg: float r, "Red component." 100*e1eccf28SAndroid Build Coastguard Workerarg: float g, "Green component." 101*e1eccf28SAndroid Build Coastguard Workerarg: float b, "Blue component." 102*e1eccf28SAndroid Build Coastguard Workersummary: Create a uchar4 RGBA from floats 103*e1eccf28SAndroid Build Coastguard Workerdescription: 104*e1eccf28SAndroid Build Coastguard Worker Packs three or four floating point RGBA values into a uchar4. 105*e1eccf28SAndroid Build Coastguard Worker 106*e1eccf28SAndroid Build Coastguard Worker The input values are typically between 0.0f and 1.0f inclusive. For input values outside 107*e1eccf28SAndroid Build Coastguard Worker of this range, the resulting outputs will be clamped to be between 0 and 255. As this 108*e1eccf28SAndroid Build Coastguard Worker clamping may be done after the input is multiplied by 255.f and converted to an integer, 109*e1eccf28SAndroid Build Coastguard Worker input numbers greater than INT_MAX/255.f or less than INT_MIN/255.f result in 110*e1eccf28SAndroid Build Coastguard Worker undefined behavior. 111*e1eccf28SAndroid Build Coastguard Worker 112*e1eccf28SAndroid Build Coastguard Worker If the alpha component is not specified, it is assumed to be 1.0, i.e. the result will 113*e1eccf28SAndroid Build Coastguard Worker have an alpha set to 255. 114*e1eccf28SAndroid Build Coastguard Workertest: none 115*e1eccf28SAndroid Build Coastguard Workerend: 116*e1eccf28SAndroid Build Coastguard Worker 117*e1eccf28SAndroid Build Coastguard Workerfunction: rsPackColorTo8888 118*e1eccf28SAndroid Build Coastguard Workerattrib: const 119*e1eccf28SAndroid Build Coastguard Workerret: uchar4 120*e1eccf28SAndroid Build Coastguard Workerarg: float r 121*e1eccf28SAndroid Build Coastguard Workerarg: float g 122*e1eccf28SAndroid Build Coastguard Workerarg: float b 123*e1eccf28SAndroid Build Coastguard Workerarg: float a, "Alpha component." 124*e1eccf28SAndroid Build Coastguard Workertest: none 125*e1eccf28SAndroid Build Coastguard Workerend: 126*e1eccf28SAndroid Build Coastguard Worker 127*e1eccf28SAndroid Build Coastguard Workerfunction: rsPackColorTo8888 128*e1eccf28SAndroid Build Coastguard Workerattrib: const 129*e1eccf28SAndroid Build Coastguard Workerret: uchar4 130*e1eccf28SAndroid Build Coastguard Workerarg: float3 color, "Vector of 3 or 4 floats containing the R, G, B, and A values." 131*e1eccf28SAndroid Build Coastguard Workertest: none 132*e1eccf28SAndroid Build Coastguard Workerend: 133*e1eccf28SAndroid Build Coastguard Worker 134*e1eccf28SAndroid Build Coastguard Workerfunction: rsPackColorTo8888 135*e1eccf28SAndroid Build Coastguard Workerattrib: const 136*e1eccf28SAndroid Build Coastguard Workerret: uchar4 137*e1eccf28SAndroid Build Coastguard Workerarg: float4 color 138*e1eccf28SAndroid Build Coastguard Workertest: none 139*e1eccf28SAndroid Build Coastguard Workerend: 140*e1eccf28SAndroid Build Coastguard Worker 141*e1eccf28SAndroid Build Coastguard Workerfunction: rsUnpackColor8888 142*e1eccf28SAndroid Build Coastguard Worker# NOTE: The = below indicates that the generator should not add "overloadable" by default. 143*e1eccf28SAndroid Build Coastguard Worker# We're doing this to stay backward compatible with the unusual declaration used when this 144*e1eccf28SAndroid Build Coastguard Worker# function was introduced. 145*e1eccf28SAndroid Build Coastguard Workerattrib: =const 146*e1eccf28SAndroid Build Coastguard Workerret: float4 147*e1eccf28SAndroid Build Coastguard Workerarg: uchar4 c 148*e1eccf28SAndroid Build Coastguard Workersummary: Create a float4 RGBA from uchar4 149*e1eccf28SAndroid Build Coastguard Workerdescription: 150*e1eccf28SAndroid Build Coastguard Worker Unpacks a uchar4 color to float4. The resulting floats will be between 0.0 and 1.0 inclusive. 151*e1eccf28SAndroid Build Coastguard Workertest: none 152*e1eccf28SAndroid Build Coastguard Workerend: 153*e1eccf28SAndroid Build Coastguard Worker 154*e1eccf28SAndroid Build Coastguard Workerfunction: rsYuvToRGBA_#2#1 155*e1eccf28SAndroid Build Coastguard Workerattrib: const 156*e1eccf28SAndroid Build Coastguard Workerw: 4 157*e1eccf28SAndroid Build Coastguard Workert: u8, f32 158*e1eccf28SAndroid Build Coastguard Workerret: #2#1 159*e1eccf28SAndroid Build Coastguard Workerarg: uchar y, "Luminance component." 160*e1eccf28SAndroid Build Coastguard Workerarg: uchar u, "U chrominance component." 161*e1eccf28SAndroid Build Coastguard Workerarg: uchar v, "V chrominance component." 162*e1eccf28SAndroid Build Coastguard Workersummary: Convert a YUV value to RGBA 163*e1eccf28SAndroid Build Coastguard Workerdescription: 164*e1eccf28SAndroid Build Coastguard Worker Converts a color from a YUV representation to RGBA. 165*e1eccf28SAndroid Build Coastguard Worker 166*e1eccf28SAndroid Build Coastguard Worker We currently don't provide a function to do the reverse conversion. 167*e1eccf28SAndroid Build Coastguard Workertest: none 168*e1eccf28SAndroid Build Coastguard Workerend: 169