blob: 596e66f013559b3db4f96930a228741e0f2e2cef [file] [log] [blame]
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001#
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -07002# Copyright (C) 2015 The Android Open Source Project
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07003#
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:
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -070018summary: Conversion Functions
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -070019description:
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -070020 The functions below convert from a numerical vector type to another,
21 of from one color representation to another.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -070022end:
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)
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -070032summary: Convert numerical vectors
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -070033description:
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -070034 Converts a vector from one numerical type to another. The conversion are
35 done entry per entry.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -070036
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -070037 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 Brouilletbe216382015-03-22 12:44:27 -070039
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -070040 Converting floating point values to integer types truncates.
41
42 Converting numbers too large to fit the destination type yields undefined results.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -070043 For example, converting a float that contains 1.0e18 to a short is undefined.
44 Use @clamp() to avoid this.
45end:
46
47function: convert_#3#1
48version: 21
49attrib: const
50w: 2, 3, 4
51t: u64, i64, f64
52t: u64, i64, f64
53ret: #3#1
54arg: #2#1 v, compatible(#3)
55end:
56
57function: convert_#3#1
58version: 21
59attrib: const
60w: 2, 3, 4
61t: u64, i64, f64
62t: u8, u16, u32, i8, i16, i32, f32
63ret: #3#1
64arg: #2#1 v, compatible(#3)
65end:
66
67function: convert_#3#1
68version: 21
69attrib: const
70w: 2, 3, 4
71t: u8, u16, u32, i8, i16, i32, f32
72t: u64, i64, f64
73ret: #3#1
74arg: #2#1 v, compatible(#3)
75end:
76
77function: rsPackColorTo8888
78attrib: const
79ret: uchar4
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -070080arg: float r, "Red component."
81arg: float g, "Green component."
82arg: float b, "Blue component."
83summary: Create a uchar4 RGBA from floats
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -070084description:
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -070085 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 Brouilletbe216382015-03-22 12:44:27 -070089
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -070090 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 Brouilletbe216382015-03-22 12:44:27 -070092test: none
93end:
94
95function: rsPackColorTo8888
96attrib: const
97ret: uchar4
98arg: float r
99arg: float g
100arg: float b
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -0700101arg: float a, "Alpha component."
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -0700102test: none
103end:
104
105function: rsPackColorTo8888
106attrib: const
107ret: uchar4
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -0700108arg: float3 color, "Vector of 3 or 4 floats containing the R, G, B, and A values."
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -0700109test: none
110end:
111
112function: rsPackColorTo8888
113attrib: const
114ret: uchar4
115arg: float4 color
116test: none
117end:
118
119function: rsUnpackColor8888
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -0700120# 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 Brouilletbe216382015-03-22 12:44:27 -0700123attrib: =const
124ret: float4
125arg: uchar4 c
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -0700126summary: Create a float4 RGBA from uchar4
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -0700127description:
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -0700128 Unpacks a uchar4 color to float4. The resulting floats will be between 0.0 and
129 1.0 inclusive.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -0700130test: none
131end:
132
133function: rsYuvToRGBA_#2#1
134attrib: const
135w: 4
136t: u8, f32
137ret: #2#1
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -0700138arg: uchar y, "Luminance component"
139arg: uchar u, "U chrominance component"
140arg: uchar v, "V chrominance component"
141summary: Convert a YUV value to RGBA
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -0700142description:
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -0700143 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 Brouilletbe216382015-03-22 12:44:27 -0700146test: none
147end: