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