Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 1 | /* |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 2 | * Copyright (C) 2015 The Android Open Source Project |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -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 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 17 | // Don't edit this file! It is auto-generated by frameworks/rs/api/gen_runtime. |
| 18 | |
| 19 | /* |
| 20 | * rs_matrix.rsh: Matrix functions |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 21 | * |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 22 | * These functions let you manipulate square matrices of rank 2x2, 3x3, and 4x4. |
| 23 | * They are particularly useful for graphical transformations and are |
| 24 | * compatible with OpenGL. |
| 25 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 26 | * We use a zero-based index for rows and columns. E.g. the last element of |
| 27 | * a rs_matrix4x4 is found at (3, 3). |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 28 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 29 | * RenderScript uses column-major matrices and column-based vectors. |
| 30 | * Transforming a vector is done by postmultiplying the vector, |
| 31 | * e.g. (matrix * vector), as provided by rsMatrixMultiply(). |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 32 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 33 | * To create a transformation matrix that performs two transformations at |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 34 | * once, multiply the two source matrices, with the first transformation as the |
| 35 | * right argument. E.g. to create a transformation matrix that applies the |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 36 | * transformation s1 followed by s2, call rsMatrixLoadMultiply(&combined, &s2, &s1). |
| 37 | * This derives from s2 * (s1 * v), which is (s2 * s1) * v. |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 38 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 39 | * We have two style of functions to create transformation matrices: |
| 40 | * rsMatrixLoadTransformation and rsMatrixTransformation. The |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 41 | * former style simply stores the transformation matrix in the first argument. |
| 42 | * The latter modifies a pre-existing transformation matrix so that the new |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 43 | * transformation happens first. E.g. if you call rsMatrixTranslate() |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 44 | * on a matrix that already does a scaling, the resulting matrix when applied |
| 45 | * to a vector will first do the translation then the scaling. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 46 | */ |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 47 | #ifndef RENDERSCRIPT_RS_MATRIX_RSH |
| 48 | #define RENDERSCRIPT_RS_MATRIX_RSH |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 49 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 50 | /* |
| 51 | * rsMatrixGet: Get one element |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 52 | * |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 53 | * Returns one element of a matrix. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 54 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 55 | * Warning: The order of the column and row parameters may be unexpected. |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 56 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 57 | * Parameters: |
| 58 | * m The matrix to extract the element from. |
| 59 | * col The zero-based column of the element to be extracted. |
| 60 | * row The zero-based row of the element to extracted. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 61 | */ |
Jean-Luc Brouillet | 129c147 | 2015-03-02 15:37:07 -0800 | [diff] [blame] | 62 | extern float __attribute__((overloadable)) |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 63 | rsMatrixGet(const rs_matrix4x4* m, uint32_t col, uint32_t row); |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 64 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 65 | extern float __attribute__((overloadable)) |
| 66 | rsMatrixGet(const rs_matrix3x3* m, uint32_t col, uint32_t row); |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 67 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 68 | extern float __attribute__((overloadable)) |
| 69 | rsMatrixGet(const rs_matrix2x2* m, uint32_t col, uint32_t row); |
| 70 | |
| 71 | /* |
| 72 | * rsMatrixInverse: Inverts a matrix in place |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 73 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 74 | * Returns true if the matrix was successfully inverted. |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 75 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 76 | * Parameters: |
| 77 | * m The matrix to invert. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 78 | */ |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 79 | extern bool __attribute__((overloadable)) |
| 80 | rsMatrixInverse(rs_matrix4x4* m); |
| 81 | |
| 82 | /* |
| 83 | * rsMatrixInverseTranspose: Inverts and transpose a matrix in place |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 84 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 85 | * The matrix is first inverted then transposed. |
| 86 | * Returns true if the matrix was successfully inverted. |
| 87 | * |
| 88 | * Parameters: |
| 89 | * m The matrix to modify. |
| 90 | */ |
| 91 | extern bool __attribute__((overloadable)) |
| 92 | rsMatrixInverseTranspose(rs_matrix4x4* m); |
| 93 | |
| 94 | /* |
| 95 | * rsMatrixLoad: Load or copy a matrix |
| 96 | * |
| 97 | * Set the elements of a matrix from an array of floats or from another matrix. |
| 98 | * |
| 99 | * If loading from an array, the floats should be in row-major order, i.e. the element a |
| 100 | * row 0, column 0 should be first, followed by the element at |
| 101 | * row 0, column 1, etc. |
| 102 | * |
| 103 | * If loading from a matrix and the source is smaller than the destination, the rest of the |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 104 | * destination is filled with elements of the identity matrix. E.g. |
| 105 | * loading a rs_matrix2x2 into a rs_matrix4x4 will give: |
| 106 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 107 | * m00 m01 0.0 0.0 |
| 108 | * m10 m11 0.0 0.0 |
| 109 | * 0.0 0.0 1.0 0.0 |
| 110 | * 0.0 0.0 0.0 1.0 |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 111 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 112 | * |
| 113 | * Parameters: |
| 114 | * destination The matrix to set. |
| 115 | * array The array of values to set the matrix to. These arrays should be 4, 9, or 16 floats long, depending on the matrix size. |
| 116 | * source The source matrix. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 117 | */ |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 118 | extern void __attribute__((overloadable)) |
| 119 | rsMatrixLoad(rs_matrix4x4* destination, const float* array); |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 120 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 121 | extern void __attribute__((overloadable)) |
| 122 | rsMatrixLoad(rs_matrix3x3* destination, const float* array); |
| 123 | |
| 124 | extern void __attribute__((overloadable)) |
| 125 | rsMatrixLoad(rs_matrix2x2* destination, const float* array); |
| 126 | |
| 127 | extern void __attribute__((overloadable)) |
| 128 | rsMatrixLoad(rs_matrix4x4* destination, const rs_matrix4x4* source); |
| 129 | |
| 130 | extern void __attribute__((overloadable)) |
| 131 | rsMatrixLoad(rs_matrix3x3* destination, const rs_matrix3x3* source); |
| 132 | |
| 133 | extern void __attribute__((overloadable)) |
| 134 | rsMatrixLoad(rs_matrix2x2* destination, const rs_matrix2x2* source); |
| 135 | |
| 136 | extern void __attribute__((overloadable)) |
| 137 | rsMatrixLoad(rs_matrix4x4* destination, const rs_matrix3x3* source); |
| 138 | |
| 139 | extern void __attribute__((overloadable)) |
| 140 | rsMatrixLoad(rs_matrix4x4* destination, const rs_matrix2x2* source); |
| 141 | |
| 142 | /* |
| 143 | * rsMatrixLoadFrustum: Load a frustum projection matrix |
| 144 | * |
| 145 | * Constructs a frustum projection matrix, transforming the box |
| 146 | * identified by the six clipping planes left, right, bottom, top, |
| 147 | * near, far. |
| 148 | * |
| 149 | * To apply this projection to a vector, multiply the vector by the |
| 150 | * created matrix using rsMatrixMultiply(). |
| 151 | * |
| 152 | * Parameters: |
| 153 | * m The matrix to set. |
| 154 | */ |
| 155 | extern void __attribute__((overloadable)) |
| 156 | rsMatrixLoadFrustum(rs_matrix4x4* m, float left, float right, float bottom, float top, |
| 157 | float near, float far); |
| 158 | |
| 159 | /* |
| 160 | * rsMatrixLoadIdentity: Load identity matrix |
| 161 | * |
| 162 | * Set the elements of a matrix to the identity matrix. |
| 163 | * |
| 164 | * Parameters: |
| 165 | * m The matrix to set. |
| 166 | */ |
| 167 | extern void __attribute__((overloadable)) |
| 168 | rsMatrixLoadIdentity(rs_matrix4x4* m); |
| 169 | |
| 170 | extern void __attribute__((overloadable)) |
| 171 | rsMatrixLoadIdentity(rs_matrix3x3* m); |
| 172 | |
| 173 | extern void __attribute__((overloadable)) |
| 174 | rsMatrixLoadIdentity(rs_matrix2x2* m); |
| 175 | |
| 176 | /* |
| 177 | * rsMatrixLoadMultiply: Multiply two matrices |
| 178 | * |
| 179 | * Sets m to the matrix product of lhs * rhs. |
| 180 | * |
| 181 | * To combine two 4x4 transformaton matrices, multiply the second transformation matrix |
| 182 | * by the first transformation matrix. E.g. to create a transformation matrix that applies |
| 183 | * the transformation s1 followed by s2, call |
| 184 | * rsMatrixLoadMultiply(&combined, &s2, &s1). |
| 185 | * |
| 186 | * Warning: Prior to version 21, storing the result back into right matrix is not supported and |
| 187 | * will result in undefined behavior. Use rsMatrixMulitply instead. E.g. instead of doing |
| 188 | * rsMatrixLoadMultiply (&m2r, &m2r, &m2l), use rsMatrixMultiply (&m2r, &m2l). |
| 189 | * rsMatrixLoadMultiply (&m2l, &m2r, &m2l) works as expected. |
| 190 | * |
| 191 | * Parameters: |
| 192 | * m The matrix to set. |
| 193 | * lhs The left matrix of the product. |
| 194 | * rhs The right matrix of the product. |
| 195 | */ |
| 196 | extern void __attribute__((overloadable)) |
| 197 | rsMatrixLoadMultiply(rs_matrix4x4* m, const rs_matrix4x4* lhs, const rs_matrix4x4* rhs); |
| 198 | |
| 199 | extern void __attribute__((overloadable)) |
| 200 | rsMatrixLoadMultiply(rs_matrix3x3* m, const rs_matrix3x3* lhs, const rs_matrix3x3* rhs); |
| 201 | |
| 202 | extern void __attribute__((overloadable)) |
| 203 | rsMatrixLoadMultiply(rs_matrix2x2* m, const rs_matrix2x2* lhs, const rs_matrix2x2* rhs); |
| 204 | |
| 205 | /* |
| 206 | * rsMatrixLoadOrtho: Load an orthographic projection matrix |
| 207 | * |
| 208 | * Constructs an orthographic projection matrix, transforming the box |
| 209 | * identified by the six clipping planes left, right, bottom, top, |
| 210 | * near, far into a unit cube with a corner at |
| 211 | * (-1, -1, -1) and the opposite at (1, 1, 1). |
| 212 | * |
| 213 | * To apply this projection to a vector, multiply the vector by the |
| 214 | * created matrix using rsMatrixMultiply(). |
| 215 | * |
| 216 | * See https://en.wikipedia.org/wiki/Orthographic_projection . |
| 217 | * |
| 218 | * Parameters: |
| 219 | * m The matrix to set. |
| 220 | */ |
| 221 | extern void __attribute__((overloadable)) |
| 222 | rsMatrixLoadOrtho(rs_matrix4x4* m, float left, float right, float bottom, float top, float near, |
| 223 | float far); |
| 224 | |
| 225 | /* |
| 226 | * rsMatrixLoadPerspective: Load a perspective projection matrix |
| 227 | * |
| 228 | * Constructs a perspective projection matrix, assuming a symmetrical field of view. |
| 229 | * |
| 230 | * To apply this projection to a vector, multiply the vector by the |
| 231 | * created matrix using rsMatrixMultiply(). |
| 232 | * |
| 233 | * Parameters: |
| 234 | * m The matrix to set. |
| 235 | * fovy Field of view, in degrees along the Y axis. |
| 236 | * aspect Ratio of x / y. |
| 237 | * near The near clipping plane. |
| 238 | * far The far clipping plane. |
| 239 | */ |
| 240 | extern void __attribute__((overloadable)) |
| 241 | rsMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far); |
| 242 | |
| 243 | /* |
| 244 | * rsMatrixLoadRotate: Load a rotation matrix |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 245 | * |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 246 | * This function creates a rotation matrix. The axis of rotation is the |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 247 | * (x, y, z) vector. |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 248 | * |
| 249 | * To rotate a vector, multiply the vector by the created matrix |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 250 | * using rsMatrixMultiply(). |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 251 | * |
| 252 | * See http://en.wikipedia.org/wiki/Rotation_matrix . |
| 253 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 254 | * Parameters: |
| 255 | * m The matrix to set. |
| 256 | * rot How much rotation to do, in degrees. |
| 257 | * x The x component of the vector that is the axis of rotation. |
| 258 | * y The y component of the vector that is the axis of rotation. |
| 259 | * z The z component of the vector that is the axis of rotation. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 260 | */ |
| 261 | extern void __attribute__((overloadable)) |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 262 | rsMatrixLoadRotate(rs_matrix4x4* m, float rot, float x, float y, float z); |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 263 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 264 | /* |
| 265 | * rsMatrixLoadScale: Load a scaling matrix |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 266 | * |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 267 | * This function creates a scaling matrix, where each component of a |
| 268 | * vector is multiplied by a number. This number can be negative. |
| 269 | * |
| 270 | * To scale a vector, multiply the vector by the created matrix |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 271 | * using rsMatrixMultiply(). |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 272 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 273 | * Parameters: |
| 274 | * m The matrix to set. |
| 275 | * x The multiple to scale the x components by. |
| 276 | * y The multiple to scale the y components by. |
| 277 | * z The multiple to scale the z components by. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 278 | */ |
| 279 | extern void __attribute__((overloadable)) |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 280 | rsMatrixLoadScale(rs_matrix4x4* m, float x, float y, float z); |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 281 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 282 | /* |
| 283 | * rsMatrixLoadTranslate: Load a translation matrix |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 284 | * |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 285 | * This function creates a translation matrix, where a |
| 286 | * number is added to each element of a vector. |
| 287 | * |
| 288 | * To translate a vector, multiply the vector by the created matrix |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 289 | * using rsMatrixMultiply(). |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 290 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 291 | * Parameters: |
| 292 | * m The matrix to set. |
| 293 | * x The number to add to each x component. |
| 294 | * y The number to add to each y component. |
| 295 | * z The number to add to each z component. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 296 | */ |
| 297 | extern void __attribute__((overloadable)) |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 298 | rsMatrixLoadTranslate(rs_matrix4x4* m, float x, float y, float z); |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 299 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 300 | /* |
| 301 | * rsMatrixMultiply: Multiply a matrix by a vector or another matrix |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 302 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 303 | * For the matrix by matrix variant, sets m to the matrix product m * rhs. |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 304 | * |
| 305 | * When combining two 4x4 transformation matrices using this function, the resulting |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 306 | * matrix will correspond to performing the rhs transformation first followed by |
| 307 | * the original m transformation. |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 308 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 309 | * For the matrix by vector variant, returns the post-multiplication of the vector |
| 310 | * by the matrix, ie. m * in. |
| 311 | * |
| 312 | * When multiplying a float3 to a rs_matrix4x4, the vector is expanded with (1). |
| 313 | * |
| 314 | * When multiplying a float2 to a rs_matrix4x4, the vector is expanded with (0, 1). |
| 315 | * |
| 316 | * When multiplying a float2 to a rs_matrix3x3, the vector is expanded with (0). |
| 317 | * |
| 318 | * Starting with API 14, this function takes a const matrix as the first argument. |
| 319 | * |
| 320 | * Parameters: |
| 321 | * m The left matrix of the product and the matrix to be set. |
| 322 | * rhs The right matrix of the product. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 323 | */ |
| 324 | extern void __attribute__((overloadable)) |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 325 | rsMatrixMultiply(rs_matrix4x4* m, const rs_matrix4x4* rhs); |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 326 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 327 | extern void __attribute__((overloadable)) |
| 328 | rsMatrixMultiply(rs_matrix3x3* m, const rs_matrix3x3* rhs); |
| 329 | |
| 330 | extern void __attribute__((overloadable)) |
| 331 | rsMatrixMultiply(rs_matrix2x2* m, const rs_matrix2x2* rhs); |
| 332 | |
| 333 | #if !defined(RS_VERSION) || (RS_VERSION <= 13) |
| 334 | extern float4 __attribute__((overloadable)) |
| 335 | rsMatrixMultiply(rs_matrix4x4* m, float4 in); |
| 336 | #endif |
| 337 | |
| 338 | #if !defined(RS_VERSION) || (RS_VERSION <= 13) |
| 339 | extern float4 __attribute__((overloadable)) |
| 340 | rsMatrixMultiply(rs_matrix4x4* m, float3 in); |
| 341 | #endif |
| 342 | |
| 343 | #if !defined(RS_VERSION) || (RS_VERSION <= 13) |
| 344 | extern float4 __attribute__((overloadable)) |
| 345 | rsMatrixMultiply(rs_matrix4x4* m, float2 in); |
| 346 | #endif |
| 347 | |
| 348 | #if !defined(RS_VERSION) || (RS_VERSION <= 13) |
| 349 | extern float3 __attribute__((overloadable)) |
| 350 | rsMatrixMultiply(rs_matrix3x3* m, float3 in); |
| 351 | #endif |
| 352 | |
| 353 | #if !defined(RS_VERSION) || (RS_VERSION <= 13) |
| 354 | extern float3 __attribute__((overloadable)) |
| 355 | rsMatrixMultiply(rs_matrix3x3* m, float2 in); |
| 356 | #endif |
| 357 | |
| 358 | #if !defined(RS_VERSION) || (RS_VERSION <= 13) |
| 359 | extern float2 __attribute__((overloadable)) |
| 360 | rsMatrixMultiply(rs_matrix2x2* m, float2 in); |
| 361 | #endif |
| 362 | |
| 363 | #if (defined(RS_VERSION) && (RS_VERSION >= 14)) |
| 364 | extern float4 __attribute__((overloadable)) |
| 365 | rsMatrixMultiply(const rs_matrix4x4* m, float4 in); |
| 366 | #endif |
| 367 | |
| 368 | #if (defined(RS_VERSION) && (RS_VERSION >= 14)) |
| 369 | extern float4 __attribute__((overloadable)) |
| 370 | rsMatrixMultiply(const rs_matrix4x4* m, float3 in); |
| 371 | #endif |
| 372 | |
| 373 | #if (defined(RS_VERSION) && (RS_VERSION >= 14)) |
| 374 | extern float4 __attribute__((overloadable)) |
| 375 | rsMatrixMultiply(const rs_matrix4x4* m, float2 in); |
| 376 | #endif |
| 377 | |
| 378 | #if (defined(RS_VERSION) && (RS_VERSION >= 14)) |
| 379 | extern float3 __attribute__((overloadable)) |
| 380 | rsMatrixMultiply(const rs_matrix3x3* m, float3 in); |
| 381 | #endif |
| 382 | |
| 383 | #if (defined(RS_VERSION) && (RS_VERSION >= 14)) |
| 384 | extern float3 __attribute__((overloadable)) |
| 385 | rsMatrixMultiply(const rs_matrix3x3* m, float2 in); |
| 386 | #endif |
| 387 | |
| 388 | #if (defined(RS_VERSION) && (RS_VERSION >= 14)) |
| 389 | extern float2 __attribute__((overloadable)) |
| 390 | rsMatrixMultiply(const rs_matrix2x2* m, float2 in); |
| 391 | #endif |
| 392 | |
| 393 | /* |
| 394 | * rsMatrixRotate: Apply a rotation to a transformation matrix |
| 395 | * |
| 396 | * Multiply the matrix m with a rotation matrix. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 397 | * |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 398 | * This function modifies a transformation matrix to first do a rotation. |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 399 | * The axis of rotation is the (x, y, z) vector. |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 400 | * |
| 401 | * To apply this combined transformation to a vector, multiply |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 402 | * the vector by the created matrix using rsMatrixMultiply(). |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 403 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 404 | * Parameters: |
| 405 | * m The matrix to modify. |
| 406 | * rot How much rotation to do, in degrees. |
| 407 | * x The x component of the vector that is the axis of rotation. |
| 408 | * y The y component of the vector that is the axis of rotation. |
| 409 | * z The z component of the vector that is the axis of rotation. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 410 | */ |
| 411 | extern void __attribute__((overloadable)) |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 412 | rsMatrixRotate(rs_matrix4x4* m, float rot, float x, float y, float z); |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 413 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 414 | /* |
| 415 | * rsMatrixScale: Apply a scaling to a transformation matrix |
| 416 | * |
| 417 | * Multiply the matrix m with a scaling matrix. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 418 | * |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 419 | * This function modifies a transformation matrix to first do a scaling. |
| 420 | * When scaling, each component of a vector is multiplied by a number. |
| 421 | * This number can be negative. |
| 422 | * |
| 423 | * To apply this combined transformation to a vector, multiply |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 424 | * the vector by the created matrix using rsMatrixMultiply(). |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 425 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 426 | * Parameters: |
| 427 | * m The matrix to modify. |
| 428 | * x The multiple to scale the x components by. |
| 429 | * y The multiple to scale the y components by. |
| 430 | * z The multiple to scale the z components by. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 431 | */ |
| 432 | extern void __attribute__((overloadable)) |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 433 | rsMatrixScale(rs_matrix4x4* m, float x, float y, float z); |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 434 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 435 | /* |
| 436 | * rsMatrixSet: Set one element |
| 437 | * |
| 438 | * Set an element of a matrix. |
| 439 | * |
| 440 | * Warning: The order of the column and row parameters may be unexpected. |
| 441 | * |
| 442 | * Parameters: |
| 443 | * m The matrix that will be modified. |
| 444 | * col The zero-based column of the element to be set. |
| 445 | * row The zero-based row of the element to be set. |
| 446 | * v The value to set. |
| 447 | */ |
| 448 | extern void __attribute__((overloadable)) |
| 449 | rsMatrixSet(rs_matrix4x4* m, uint32_t col, uint32_t row, float v); |
| 450 | |
| 451 | extern void __attribute__((overloadable)) |
| 452 | rsMatrixSet(rs_matrix3x3* m, uint32_t col, uint32_t row, float v); |
| 453 | |
| 454 | extern void __attribute__((overloadable)) |
| 455 | rsMatrixSet(rs_matrix2x2* m, uint32_t col, uint32_t row, float v); |
| 456 | |
| 457 | /* |
| 458 | * rsMatrixTranslate: Apply a translation to a transformation matrix |
| 459 | * |
| 460 | * Multiply the matrix m with a translation matrix. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 461 | * |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 462 | * This function modifies a transformation matrix to first |
| 463 | * do a translation. When translating, a number is added |
| 464 | * to each component of a vector. |
| 465 | * |
| 466 | * To apply this combined transformation to a vector, multiply |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 467 | * the vector by the created matrix using rsMatrixMultiply(). |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 468 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 469 | * Parameters: |
| 470 | * m The matrix to modify. |
| 471 | * x The number to add to each x component. |
| 472 | * y The number to add to each y component. |
| 473 | * z The number to add to each z component. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 474 | */ |
| 475 | extern void __attribute__((overloadable)) |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 476 | rsMatrixTranslate(rs_matrix4x4* m, float x, float y, float z); |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 477 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 478 | /* |
| 479 | * rsMatrixTranspose: Transpose a matrix place |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 480 | * |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 481 | * Transpose the matrix m in place. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 482 | * |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 483 | * Parameters: |
| 484 | * m The matrix to transpose. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 485 | */ |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 486 | extern void __attribute__((overloadable)) |
| 487 | rsMatrixTranspose(rs_matrix4x4* m); |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 488 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 489 | extern void __attribute__((overloadable)) |
| 490 | rsMatrixTranspose(rs_matrix3x3* m); |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 491 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame^] | 492 | extern void __attribute__((overloadable)) |
| 493 | rsMatrixTranspose(rs_matrix2x2* m); |
| 494 | |
| 495 | #endif // RENDERSCRIPT_RS_MATRIX_RSH |