1*344a7f5eSAndroid Build Coastguard Worker/* 2*344a7f5eSAndroid Build Coastguard Worker * Copyright (C) 2016 The Android Open Source Project 3*344a7f5eSAndroid Build Coastguard Worker * 4*344a7f5eSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*344a7f5eSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*344a7f5eSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*344a7f5eSAndroid Build Coastguard Worker * 8*344a7f5eSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*344a7f5eSAndroid Build Coastguard Worker * 10*344a7f5eSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*344a7f5eSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*344a7f5eSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*344a7f5eSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*344a7f5eSAndroid Build Coastguard Worker * limitations under the License. 15*344a7f5eSAndroid Build Coastguard Worker */ 16*344a7f5eSAndroid Build Coastguard Worker 17*344a7f5eSAndroid Build Coastguard Worker// Don't edit this file! It is auto-generated by frameworks/rs/api/generate.sh. 18*344a7f5eSAndroid Build Coastguard Worker 19*344a7f5eSAndroid Build Coastguard Worker/* 20*344a7f5eSAndroid Build Coastguard Worker * rs_matrix.rsh: Matrix Functions 21*344a7f5eSAndroid Build Coastguard Worker * 22*344a7f5eSAndroid Build Coastguard Worker * These functions let you manipulate square matrices of rank 2x2, 3x3, and 4x4. 23*344a7f5eSAndroid Build Coastguard Worker * They are particularly useful for graphical transformations and are compatible 24*344a7f5eSAndroid Build Coastguard Worker * with OpenGL. 25*344a7f5eSAndroid Build Coastguard Worker * 26*344a7f5eSAndroid Build Coastguard Worker * We use a zero-based index for rows and columns. E.g. the last element of a 27*344a7f5eSAndroid Build Coastguard Worker * rs_matrix4x4 is found at (3, 3). 28*344a7f5eSAndroid Build Coastguard Worker * 29*344a7f5eSAndroid Build Coastguard Worker * RenderScript uses column-major matrices and column-based vectors. Transforming 30*344a7f5eSAndroid Build Coastguard Worker * a vector is done by postmultiplying the vector, e.g. (matrix * vector), 31*344a7f5eSAndroid Build Coastguard Worker * as provided by rsMatrixMultiply(). 32*344a7f5eSAndroid Build Coastguard Worker * 33*344a7f5eSAndroid Build Coastguard Worker * To create a transformation matrix that performs two transformations at once, 34*344a7f5eSAndroid Build Coastguard Worker * multiply the two source matrices, with the first transformation as the right 35*344a7f5eSAndroid Build Coastguard Worker * argument. E.g. to create a transformation matrix that applies the 36*344a7f5eSAndroid Build Coastguard Worker * transformation s1 followed by s2, call rsMatrixLoadMultiply(&combined, &s2, &s1). 37*344a7f5eSAndroid Build Coastguard Worker * This derives from s2 * (s1 * v), which is (s2 * s1) * v. 38*344a7f5eSAndroid Build Coastguard Worker * 39*344a7f5eSAndroid Build Coastguard Worker * We have two style of functions to create transformation matrices: 40*344a7f5eSAndroid Build Coastguard Worker * rsMatrixLoadTransformation and rsMatrixTransformation. The former 41*344a7f5eSAndroid Build Coastguard Worker * style simply stores the transformation matrix in the first argument. The latter 42*344a7f5eSAndroid Build Coastguard Worker * modifies a pre-existing transformation matrix so that the new transformation 43*344a7f5eSAndroid Build Coastguard Worker * happens first. E.g. if you call rsMatrixTranslate() on a matrix that already 44*344a7f5eSAndroid Build Coastguard Worker * does a scaling, the resulting matrix when applied to a vector will first do the 45*344a7f5eSAndroid Build Coastguard Worker * translation then the scaling. 46*344a7f5eSAndroid Build Coastguard Worker */ 47*344a7f5eSAndroid Build Coastguard Worker 48*344a7f5eSAndroid Build Coastguard Worker#ifndef RENDERSCRIPT_RS_MATRIX_RSH 49*344a7f5eSAndroid Build Coastguard Worker#define RENDERSCRIPT_RS_MATRIX_RSH 50*344a7f5eSAndroid Build Coastguard Worker 51*344a7f5eSAndroid Build Coastguard Worker#include "rs_vector_math.rsh" 52*344a7f5eSAndroid Build Coastguard Worker 53*344a7f5eSAndroid Build Coastguard Worker/* 54*344a7f5eSAndroid Build Coastguard Worker * rsExtractFrustumPlanes: Compute frustum planes 55*344a7f5eSAndroid Build Coastguard Worker * 56*344a7f5eSAndroid Build Coastguard Worker * Computes 6 frustum planes from the view projection matrix 57*344a7f5eSAndroid Build Coastguard Worker * 58*344a7f5eSAndroid Build Coastguard Worker * Parameters: 59*344a7f5eSAndroid Build Coastguard Worker * viewProj: Matrix to extract planes from. 60*344a7f5eSAndroid Build Coastguard Worker * left: Left plane. 61*344a7f5eSAndroid Build Coastguard Worker * right: Right plane. 62*344a7f5eSAndroid Build Coastguard Worker * top: Top plane. 63*344a7f5eSAndroid Build Coastguard Worker * bottom: Bottom plane. 64*344a7f5eSAndroid Build Coastguard Worker * near: Near plane. 65*344a7f5eSAndroid Build Coastguard Worker * far: Far plane. 66*344a7f5eSAndroid Build Coastguard Worker */ 67*344a7f5eSAndroid Build Coastguard Worker#if !defined(RS_VERSION) || (RS_VERSION <= 23) 68*344a7f5eSAndroid Build Coastguard Workerstatic inline void __attribute__((overloadable)) 69*344a7f5eSAndroid Build Coastguard Worker rsExtractFrustumPlanes(const rs_matrix4x4* viewProj, float4* left, float4* right, float4* top, 70*344a7f5eSAndroid Build Coastguard Worker float4* bottom, float4* near, float4* far) { 71*344a7f5eSAndroid Build Coastguard Worker // x y z w = a b c d in the plane equation 72*344a7f5eSAndroid Build Coastguard Worker left->x = viewProj->m[3] + viewProj->m[0]; 73*344a7f5eSAndroid Build Coastguard Worker left->y = viewProj->m[7] + viewProj->m[4]; 74*344a7f5eSAndroid Build Coastguard Worker left->z = viewProj->m[11] + viewProj->m[8]; 75*344a7f5eSAndroid Build Coastguard Worker left->w = viewProj->m[15] + viewProj->m[12]; 76*344a7f5eSAndroid Build Coastguard Worker 77*344a7f5eSAndroid Build Coastguard Worker right->x = viewProj->m[3] - viewProj->m[0]; 78*344a7f5eSAndroid Build Coastguard Worker right->y = viewProj->m[7] - viewProj->m[4]; 79*344a7f5eSAndroid Build Coastguard Worker right->z = viewProj->m[11] - viewProj->m[8]; 80*344a7f5eSAndroid Build Coastguard Worker right->w = viewProj->m[15] - viewProj->m[12]; 81*344a7f5eSAndroid Build Coastguard Worker 82*344a7f5eSAndroid Build Coastguard Worker top->x = viewProj->m[3] - viewProj->m[1]; 83*344a7f5eSAndroid Build Coastguard Worker top->y = viewProj->m[7] - viewProj->m[5]; 84*344a7f5eSAndroid Build Coastguard Worker top->z = viewProj->m[11] - viewProj->m[9]; 85*344a7f5eSAndroid Build Coastguard Worker top->w = viewProj->m[15] - viewProj->m[13]; 86*344a7f5eSAndroid Build Coastguard Worker 87*344a7f5eSAndroid Build Coastguard Worker bottom->x = viewProj->m[3] + viewProj->m[1]; 88*344a7f5eSAndroid Build Coastguard Worker bottom->y = viewProj->m[7] + viewProj->m[5]; 89*344a7f5eSAndroid Build Coastguard Worker bottom->z = viewProj->m[11] + viewProj->m[9]; 90*344a7f5eSAndroid Build Coastguard Worker bottom->w = viewProj->m[15] + viewProj->m[13]; 91*344a7f5eSAndroid Build Coastguard Worker 92*344a7f5eSAndroid Build Coastguard Worker near->x = viewProj->m[3] + viewProj->m[2]; 93*344a7f5eSAndroid Build Coastguard Worker near->y = viewProj->m[7] + viewProj->m[6]; 94*344a7f5eSAndroid Build Coastguard Worker near->z = viewProj->m[11] + viewProj->m[10]; 95*344a7f5eSAndroid Build Coastguard Worker near->w = viewProj->m[15] + viewProj->m[14]; 96*344a7f5eSAndroid Build Coastguard Worker 97*344a7f5eSAndroid Build Coastguard Worker far->x = viewProj->m[3] - viewProj->m[2]; 98*344a7f5eSAndroid Build Coastguard Worker far->y = viewProj->m[7] - viewProj->m[6]; 99*344a7f5eSAndroid Build Coastguard Worker far->z = viewProj->m[11] - viewProj->m[10]; 100*344a7f5eSAndroid Build Coastguard Worker far->w = viewProj->m[15] - viewProj->m[14]; 101*344a7f5eSAndroid Build Coastguard Worker 102*344a7f5eSAndroid Build Coastguard Worker float len = length(left->xyz); 103*344a7f5eSAndroid Build Coastguard Worker *left /= len; 104*344a7f5eSAndroid Build Coastguard Worker len = length(right->xyz); 105*344a7f5eSAndroid Build Coastguard Worker *right /= len; 106*344a7f5eSAndroid Build Coastguard Worker len = length(top->xyz); 107*344a7f5eSAndroid Build Coastguard Worker *top /= len; 108*344a7f5eSAndroid Build Coastguard Worker len = length(bottom->xyz); 109*344a7f5eSAndroid Build Coastguard Worker *bottom /= len; 110*344a7f5eSAndroid Build Coastguard Worker len = length(near->xyz); 111*344a7f5eSAndroid Build Coastguard Worker *near /= len; 112*344a7f5eSAndroid Build Coastguard Worker len = length(far->xyz); 113*344a7f5eSAndroid Build Coastguard Worker *far /= len; 114*344a7f5eSAndroid Build Coastguard Worker} 115*344a7f5eSAndroid Build Coastguard Worker#endif 116*344a7f5eSAndroid Build Coastguard Worker 117*344a7f5eSAndroid Build Coastguard Worker#if (defined(RS_VERSION) && (RS_VERSION >= 24)) 118*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 119*344a7f5eSAndroid Build Coastguard Worker rsExtractFrustumPlanes(const rs_matrix4x4* viewProj, float4* left, float4* righ, float4* top, 120*344a7f5eSAndroid Build Coastguard Worker float4* bottom, float4* near, float4* far); 121*344a7f5eSAndroid Build Coastguard Worker#endif 122*344a7f5eSAndroid Build Coastguard Worker 123*344a7f5eSAndroid Build Coastguard Worker/* 124*344a7f5eSAndroid Build Coastguard Worker * rsIsSphereInFrustum: Checks if a sphere is within the frustum planes 125*344a7f5eSAndroid Build Coastguard Worker * 126*344a7f5eSAndroid Build Coastguard Worker * Returns true if the sphere is within the 6 frustum planes. 127*344a7f5eSAndroid Build Coastguard Worker * 128*344a7f5eSAndroid Build Coastguard Worker * Parameters: 129*344a7f5eSAndroid Build Coastguard Worker * sphere: float4 representing the sphere. 130*344a7f5eSAndroid Build Coastguard Worker * left: Left plane. 131*344a7f5eSAndroid Build Coastguard Worker * right: Right plane. 132*344a7f5eSAndroid Build Coastguard Worker * top: Top plane. 133*344a7f5eSAndroid Build Coastguard Worker * bottom: Bottom plane. 134*344a7f5eSAndroid Build Coastguard Worker * near: Near plane. 135*344a7f5eSAndroid Build Coastguard Worker * far: Far plane. 136*344a7f5eSAndroid Build Coastguard Worker */ 137*344a7f5eSAndroid Build Coastguard Worker#if !defined(RS_VERSION) || (RS_VERSION <= 23) 138*344a7f5eSAndroid Build Coastguard Workerstatic inline bool __attribute__((always_inline, overloadable)) 139*344a7f5eSAndroid Build Coastguard Worker rsIsSphereInFrustum(float4* sphere, float4* left, float4* right, float4* top, float4* bottom, 140*344a7f5eSAndroid Build Coastguard Worker float4* near, float4* far) { 141*344a7f5eSAndroid Build Coastguard Worker float distToCenter = dot(left->xyz, sphere->xyz) + left->w; 142*344a7f5eSAndroid Build Coastguard Worker if (distToCenter < -sphere->w) { 143*344a7f5eSAndroid Build Coastguard Worker return false; 144*344a7f5eSAndroid Build Coastguard Worker } 145*344a7f5eSAndroid Build Coastguard Worker distToCenter = dot(right->xyz, sphere->xyz) + right->w; 146*344a7f5eSAndroid Build Coastguard Worker if (distToCenter < -sphere->w) { 147*344a7f5eSAndroid Build Coastguard Worker return false; 148*344a7f5eSAndroid Build Coastguard Worker } 149*344a7f5eSAndroid Build Coastguard Worker distToCenter = dot(top->xyz, sphere->xyz) + top->w; 150*344a7f5eSAndroid Build Coastguard Worker if (distToCenter < -sphere->w) { 151*344a7f5eSAndroid Build Coastguard Worker return false; 152*344a7f5eSAndroid Build Coastguard Worker } 153*344a7f5eSAndroid Build Coastguard Worker distToCenter = dot(bottom->xyz, sphere->xyz) + bottom->w; 154*344a7f5eSAndroid Build Coastguard Worker if (distToCenter < -sphere->w) { 155*344a7f5eSAndroid Build Coastguard Worker return false; 156*344a7f5eSAndroid Build Coastguard Worker } 157*344a7f5eSAndroid Build Coastguard Worker distToCenter = dot(near->xyz, sphere->xyz) + near->w; 158*344a7f5eSAndroid Build Coastguard Worker if (distToCenter < -sphere->w) { 159*344a7f5eSAndroid Build Coastguard Worker return false; 160*344a7f5eSAndroid Build Coastguard Worker } 161*344a7f5eSAndroid Build Coastguard Worker distToCenter = dot(far->xyz, sphere->xyz) + far->w; 162*344a7f5eSAndroid Build Coastguard Worker if (distToCenter < -sphere->w) { 163*344a7f5eSAndroid Build Coastguard Worker return false; 164*344a7f5eSAndroid Build Coastguard Worker } 165*344a7f5eSAndroid Build Coastguard Worker return true; 166*344a7f5eSAndroid Build Coastguard Worker} 167*344a7f5eSAndroid Build Coastguard Worker#endif 168*344a7f5eSAndroid Build Coastguard Worker 169*344a7f5eSAndroid Build Coastguard Worker#if (defined(RS_VERSION) && (RS_VERSION >= 24)) 170*344a7f5eSAndroid Build Coastguard Workerextern bool __attribute__((overloadable)) 171*344a7f5eSAndroid Build Coastguard Worker rsIsSphereInFrustum(float4* sphere, float4* left, float4* right, float4* top, float4* bottom, 172*344a7f5eSAndroid Build Coastguard Worker float4* near, float4* far); 173*344a7f5eSAndroid Build Coastguard Worker#endif 174*344a7f5eSAndroid Build Coastguard Worker 175*344a7f5eSAndroid Build Coastguard Worker/* 176*344a7f5eSAndroid Build Coastguard Worker * rsMatrixGet: Get one element 177*344a7f5eSAndroid Build Coastguard Worker * 178*344a7f5eSAndroid Build Coastguard Worker * Returns one element of a matrix. 179*344a7f5eSAndroid Build Coastguard Worker * 180*344a7f5eSAndroid Build Coastguard Worker * Warning: The order of the column and row parameters may be unexpected. 181*344a7f5eSAndroid Build Coastguard Worker * 182*344a7f5eSAndroid Build Coastguard Worker * Parameters: 183*344a7f5eSAndroid Build Coastguard Worker * m: Matrix to extract the element from. 184*344a7f5eSAndroid Build Coastguard Worker * col: Zero-based column of the element to be extracted. 185*344a7f5eSAndroid Build Coastguard Worker * row: Zero-based row of the element to extracted. 186*344a7f5eSAndroid Build Coastguard Worker */ 187*344a7f5eSAndroid Build Coastguard Workerextern float __attribute__((overloadable)) 188*344a7f5eSAndroid Build Coastguard Worker rsMatrixGet(const rs_matrix4x4* m, uint32_t col, uint32_t row); 189*344a7f5eSAndroid Build Coastguard Worker 190*344a7f5eSAndroid Build Coastguard Workerextern float __attribute__((overloadable)) 191*344a7f5eSAndroid Build Coastguard Worker rsMatrixGet(const rs_matrix3x3* m, uint32_t col, uint32_t row); 192*344a7f5eSAndroid Build Coastguard Worker 193*344a7f5eSAndroid Build Coastguard Workerextern float __attribute__((overloadable)) 194*344a7f5eSAndroid Build Coastguard Worker rsMatrixGet(const rs_matrix2x2* m, uint32_t col, uint32_t row); 195*344a7f5eSAndroid Build Coastguard Worker 196*344a7f5eSAndroid Build Coastguard Worker/* 197*344a7f5eSAndroid Build Coastguard Worker * rsMatrixInverse: Inverts a matrix in place 198*344a7f5eSAndroid Build Coastguard Worker * 199*344a7f5eSAndroid Build Coastguard Worker * Returns true if the matrix was successfully inverted. 200*344a7f5eSAndroid Build Coastguard Worker * 201*344a7f5eSAndroid Build Coastguard Worker * Parameters: 202*344a7f5eSAndroid Build Coastguard Worker * m: Matrix to invert. 203*344a7f5eSAndroid Build Coastguard Worker */ 204*344a7f5eSAndroid Build Coastguard Workerextern bool __attribute__((overloadable)) 205*344a7f5eSAndroid Build Coastguard Worker rsMatrixInverse(rs_matrix4x4* m); 206*344a7f5eSAndroid Build Coastguard Worker 207*344a7f5eSAndroid Build Coastguard Worker/* 208*344a7f5eSAndroid Build Coastguard Worker * rsMatrixInverseTranspose: Inverts and transpose a matrix in place 209*344a7f5eSAndroid Build Coastguard Worker * 210*344a7f5eSAndroid Build Coastguard Worker * The matrix is first inverted then transposed. Returns true if the matrix was 211*344a7f5eSAndroid Build Coastguard Worker * successfully inverted. 212*344a7f5eSAndroid Build Coastguard Worker * 213*344a7f5eSAndroid Build Coastguard Worker * Parameters: 214*344a7f5eSAndroid Build Coastguard Worker * m: Matrix to modify. 215*344a7f5eSAndroid Build Coastguard Worker */ 216*344a7f5eSAndroid Build Coastguard Workerextern bool __attribute__((overloadable)) 217*344a7f5eSAndroid Build Coastguard Worker rsMatrixInverseTranspose(rs_matrix4x4* m); 218*344a7f5eSAndroid Build Coastguard Worker 219*344a7f5eSAndroid Build Coastguard Worker/* 220*344a7f5eSAndroid Build Coastguard Worker * rsMatrixLoad: Load or copy a matrix 221*344a7f5eSAndroid Build Coastguard Worker * 222*344a7f5eSAndroid Build Coastguard Worker * Set the elements of a matrix from an array of floats or from another matrix. 223*344a7f5eSAndroid Build Coastguard Worker * 224*344a7f5eSAndroid Build Coastguard Worker * If loading from an array, the floats should be in row-major order, i.e. the element a 225*344a7f5eSAndroid Build Coastguard Worker * row 0, column 0 should be first, followed by the element at 226*344a7f5eSAndroid Build Coastguard Worker * row 0, column 1, etc. 227*344a7f5eSAndroid Build Coastguard Worker * 228*344a7f5eSAndroid Build Coastguard Worker * If loading from a matrix and the source is smaller than the destination, the rest 229*344a7f5eSAndroid Build Coastguard Worker * of the destination is filled with elements of the identity matrix. E.g. 230*344a7f5eSAndroid Build Coastguard Worker * loading a rs_matrix2x2 into a rs_matrix4x4 will give: 231*344a7f5eSAndroid Build Coastguard Worker * 232*344a7f5eSAndroid Build Coastguard Worker * m00 m01 0.0 0.0 233*344a7f5eSAndroid Build Coastguard Worker * m10 m11 0.0 0.0 234*344a7f5eSAndroid Build Coastguard Worker * 0.0 0.0 1.0 0.0 235*344a7f5eSAndroid Build Coastguard Worker * 0.0 0.0 0.0 1.0 236*344a7f5eSAndroid Build Coastguard Worker * 237*344a7f5eSAndroid Build Coastguard Worker * 238*344a7f5eSAndroid Build Coastguard Worker * Parameters: 239*344a7f5eSAndroid Build Coastguard Worker * destination: Matrix to set. 240*344a7f5eSAndroid Build Coastguard Worker * array: Array of values to set the matrix to. These arrays should be 4, 9, or 16 floats long, depending on the matrix size. 241*344a7f5eSAndroid Build Coastguard Worker * source: Source matrix. 242*344a7f5eSAndroid Build Coastguard Worker */ 243*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 244*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoad(rs_matrix4x4* destination, const float* array); 245*344a7f5eSAndroid Build Coastguard Worker 246*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 247*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoad(rs_matrix3x3* destination, const float* array); 248*344a7f5eSAndroid Build Coastguard Worker 249*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 250*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoad(rs_matrix2x2* destination, const float* array); 251*344a7f5eSAndroid Build Coastguard Worker 252*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 253*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoad(rs_matrix4x4* destination, const rs_matrix4x4* source); 254*344a7f5eSAndroid Build Coastguard Worker 255*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 256*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoad(rs_matrix3x3* destination, const rs_matrix3x3* source); 257*344a7f5eSAndroid Build Coastguard Worker 258*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 259*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoad(rs_matrix2x2* destination, const rs_matrix2x2* source); 260*344a7f5eSAndroid Build Coastguard Worker 261*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 262*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoad(rs_matrix4x4* destination, const rs_matrix3x3* source); 263*344a7f5eSAndroid Build Coastguard Worker 264*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 265*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoad(rs_matrix4x4* destination, const rs_matrix2x2* source); 266*344a7f5eSAndroid Build Coastguard Worker 267*344a7f5eSAndroid Build Coastguard Worker/* 268*344a7f5eSAndroid Build Coastguard Worker * rsMatrixLoadFrustum: Load a frustum projection matrix 269*344a7f5eSAndroid Build Coastguard Worker * 270*344a7f5eSAndroid Build Coastguard Worker * Constructs a frustum projection matrix, transforming the box identified by 271*344a7f5eSAndroid Build Coastguard Worker * the six clipping planes left, right, bottom, top, near, far. 272*344a7f5eSAndroid Build Coastguard Worker * 273*344a7f5eSAndroid Build Coastguard Worker * To apply this projection to a vector, multiply the vector by the created 274*344a7f5eSAndroid Build Coastguard Worker * matrix using rsMatrixMultiply(). 275*344a7f5eSAndroid Build Coastguard Worker * 276*344a7f5eSAndroid Build Coastguard Worker * Parameters: 277*344a7f5eSAndroid Build Coastguard Worker * m: Matrix to set. 278*344a7f5eSAndroid Build Coastguard Worker */ 279*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 280*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoadFrustum(rs_matrix4x4* m, float left, float right, float bottom, float top, 281*344a7f5eSAndroid Build Coastguard Worker float near, float far); 282*344a7f5eSAndroid Build Coastguard Worker 283*344a7f5eSAndroid Build Coastguard Worker/* 284*344a7f5eSAndroid Build Coastguard Worker * rsMatrixLoadIdentity: Load identity matrix 285*344a7f5eSAndroid Build Coastguard Worker * 286*344a7f5eSAndroid Build Coastguard Worker * Set the elements of a matrix to the identity matrix. 287*344a7f5eSAndroid Build Coastguard Worker * 288*344a7f5eSAndroid Build Coastguard Worker * Parameters: 289*344a7f5eSAndroid Build Coastguard Worker * m: Matrix to set. 290*344a7f5eSAndroid Build Coastguard Worker */ 291*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 292*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoadIdentity(rs_matrix4x4* m); 293*344a7f5eSAndroid Build Coastguard Worker 294*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 295*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoadIdentity(rs_matrix3x3* m); 296*344a7f5eSAndroid Build Coastguard Worker 297*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 298*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoadIdentity(rs_matrix2x2* m); 299*344a7f5eSAndroid Build Coastguard Worker 300*344a7f5eSAndroid Build Coastguard Worker/* 301*344a7f5eSAndroid Build Coastguard Worker * rsMatrixLoadMultiply: Multiply two matrices 302*344a7f5eSAndroid Build Coastguard Worker * 303*344a7f5eSAndroid Build Coastguard Worker * Sets m to the matrix product of lhs * rhs. 304*344a7f5eSAndroid Build Coastguard Worker * 305*344a7f5eSAndroid Build Coastguard Worker * To combine two 4x4 transformaton matrices, multiply the second transformation matrix 306*344a7f5eSAndroid Build Coastguard Worker * by the first transformation matrix. E.g. to create a transformation matrix that applies 307*344a7f5eSAndroid Build Coastguard Worker * the transformation s1 followed by s2, call rsMatrixLoadMultiply(&combined, &s2, &s1). 308*344a7f5eSAndroid Build Coastguard Worker * 309*344a7f5eSAndroid Build Coastguard Worker * Warning: Prior to version 21, storing the result back into right matrix is not supported and 310*344a7f5eSAndroid Build Coastguard Worker * will result in undefined behavior. Use rsMatrixMulitply instead. E.g. instead of doing 311*344a7f5eSAndroid Build Coastguard Worker * rsMatrixLoadMultiply (&m2r, &m2r, &m2l), use rsMatrixMultiply (&m2r, &m2l). 312*344a7f5eSAndroid Build Coastguard Worker * rsMatrixLoadMultiply (&m2l, &m2r, &m2l) works as expected. 313*344a7f5eSAndroid Build Coastguard Worker * 314*344a7f5eSAndroid Build Coastguard Worker * Parameters: 315*344a7f5eSAndroid Build Coastguard Worker * m: Matrix to set. 316*344a7f5eSAndroid Build Coastguard Worker * lhs: Left matrix of the product. 317*344a7f5eSAndroid Build Coastguard Worker * rhs: Right matrix of the product. 318*344a7f5eSAndroid Build Coastguard Worker */ 319*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 320*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoadMultiply(rs_matrix4x4* m, const rs_matrix4x4* lhs, const rs_matrix4x4* rhs); 321*344a7f5eSAndroid Build Coastguard Worker 322*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 323*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoadMultiply(rs_matrix3x3* m, const rs_matrix3x3* lhs, const rs_matrix3x3* rhs); 324*344a7f5eSAndroid Build Coastguard Worker 325*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 326*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoadMultiply(rs_matrix2x2* m, const rs_matrix2x2* lhs, const rs_matrix2x2* rhs); 327*344a7f5eSAndroid Build Coastguard Worker 328*344a7f5eSAndroid Build Coastguard Worker/* 329*344a7f5eSAndroid Build Coastguard Worker * rsMatrixLoadOrtho: Load an orthographic projection matrix 330*344a7f5eSAndroid Build Coastguard Worker * 331*344a7f5eSAndroid Build Coastguard Worker * Constructs an orthographic projection matrix, transforming the box identified by the 332*344a7f5eSAndroid Build Coastguard Worker * six clipping planes left, right, bottom, top, near, far into a unit cube 333*344a7f5eSAndroid Build Coastguard Worker * with a corner at (-1, -1, -1) and the opposite at (1, 1, 1). 334*344a7f5eSAndroid Build Coastguard Worker * 335*344a7f5eSAndroid Build Coastguard Worker * To apply this projection to a vector, multiply the vector by the created matrix 336*344a7f5eSAndroid Build Coastguard Worker * using rsMatrixMultiply(). 337*344a7f5eSAndroid Build Coastguard Worker * 338*344a7f5eSAndroid Build Coastguard Worker * See https://en.wikipedia.org/wiki/Orthographic_projection . 339*344a7f5eSAndroid Build Coastguard Worker * 340*344a7f5eSAndroid Build Coastguard Worker * Parameters: 341*344a7f5eSAndroid Build Coastguard Worker * m: Matrix to set. 342*344a7f5eSAndroid Build Coastguard Worker */ 343*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 344*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoadOrtho(rs_matrix4x4* m, float left, float right, float bottom, float top, float near, 345*344a7f5eSAndroid Build Coastguard Worker float far); 346*344a7f5eSAndroid Build Coastguard Worker 347*344a7f5eSAndroid Build Coastguard Worker/* 348*344a7f5eSAndroid Build Coastguard Worker * rsMatrixLoadPerspective: Load a perspective projection matrix 349*344a7f5eSAndroid Build Coastguard Worker * 350*344a7f5eSAndroid Build Coastguard Worker * Constructs a perspective projection matrix, assuming a symmetrical field of view. 351*344a7f5eSAndroid Build Coastguard Worker * 352*344a7f5eSAndroid Build Coastguard Worker * To apply this projection to a vector, multiply the vector by the created matrix 353*344a7f5eSAndroid Build Coastguard Worker * using rsMatrixMultiply(). 354*344a7f5eSAndroid Build Coastguard Worker * 355*344a7f5eSAndroid Build Coastguard Worker * Parameters: 356*344a7f5eSAndroid Build Coastguard Worker * m: Matrix to set. 357*344a7f5eSAndroid Build Coastguard Worker * fovy: Field of view, in degrees along the Y axis. 358*344a7f5eSAndroid Build Coastguard Worker * aspect: Ratio of x / y. 359*344a7f5eSAndroid Build Coastguard Worker * near: Near clipping plane. 360*344a7f5eSAndroid Build Coastguard Worker * far: Far clipping plane. 361*344a7f5eSAndroid Build Coastguard Worker */ 362*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 363*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far); 364*344a7f5eSAndroid Build Coastguard Worker 365*344a7f5eSAndroid Build Coastguard Worker/* 366*344a7f5eSAndroid Build Coastguard Worker * rsMatrixLoadRotate: Load a rotation matrix 367*344a7f5eSAndroid Build Coastguard Worker * 368*344a7f5eSAndroid Build Coastguard Worker * This function creates a rotation matrix. The axis of rotation is the (x, y, z) vector. 369*344a7f5eSAndroid Build Coastguard Worker * 370*344a7f5eSAndroid Build Coastguard Worker * To rotate a vector, multiply the vector by the created matrix using rsMatrixMultiply(). 371*344a7f5eSAndroid Build Coastguard Worker * 372*344a7f5eSAndroid Build Coastguard Worker * See http://en.wikipedia.org/wiki/Rotation_matrix . 373*344a7f5eSAndroid Build Coastguard Worker * 374*344a7f5eSAndroid Build Coastguard Worker * Parameters: 375*344a7f5eSAndroid Build Coastguard Worker * m: Matrix to set. 376*344a7f5eSAndroid Build Coastguard Worker * rot: How much rotation to do, in degrees. 377*344a7f5eSAndroid Build Coastguard Worker * x: X component of the vector that is the axis of rotation. 378*344a7f5eSAndroid Build Coastguard Worker * y: Y component of the vector that is the axis of rotation. 379*344a7f5eSAndroid Build Coastguard Worker * z: Z component of the vector that is the axis of rotation. 380*344a7f5eSAndroid Build Coastguard Worker */ 381*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 382*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoadRotate(rs_matrix4x4* m, float rot, float x, float y, float z); 383*344a7f5eSAndroid Build Coastguard Worker 384*344a7f5eSAndroid Build Coastguard Worker/* 385*344a7f5eSAndroid Build Coastguard Worker * rsMatrixLoadScale: Load a scaling matrix 386*344a7f5eSAndroid Build Coastguard Worker * 387*344a7f5eSAndroid Build Coastguard Worker * This function creates a scaling matrix, where each component of a vector is multiplied 388*344a7f5eSAndroid Build Coastguard Worker * by a number. This number can be negative. 389*344a7f5eSAndroid Build Coastguard Worker * 390*344a7f5eSAndroid Build Coastguard Worker * To scale a vector, multiply the vector by the created matrix using rsMatrixMultiply(). 391*344a7f5eSAndroid Build Coastguard Worker * 392*344a7f5eSAndroid Build Coastguard Worker * Parameters: 393*344a7f5eSAndroid Build Coastguard Worker * m: Matrix to set. 394*344a7f5eSAndroid Build Coastguard Worker * x: Multiple to scale the x components by. 395*344a7f5eSAndroid Build Coastguard Worker * y: Multiple to scale the y components by. 396*344a7f5eSAndroid Build Coastguard Worker * z: Multiple to scale the z components by. 397*344a7f5eSAndroid Build Coastguard Worker */ 398*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 399*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoadScale(rs_matrix4x4* m, float x, float y, float z); 400*344a7f5eSAndroid Build Coastguard Worker 401*344a7f5eSAndroid Build Coastguard Worker/* 402*344a7f5eSAndroid Build Coastguard Worker * rsMatrixLoadTranslate: Load a translation matrix 403*344a7f5eSAndroid Build Coastguard Worker * 404*344a7f5eSAndroid Build Coastguard Worker * This function creates a translation matrix, where a number is added to each element of 405*344a7f5eSAndroid Build Coastguard Worker * a vector. 406*344a7f5eSAndroid Build Coastguard Worker * 407*344a7f5eSAndroid Build Coastguard Worker * To translate a vector, multiply the vector by the created matrix using 408*344a7f5eSAndroid Build Coastguard Worker * rsMatrixMultiply(). 409*344a7f5eSAndroid Build Coastguard Worker * 410*344a7f5eSAndroid Build Coastguard Worker * Parameters: 411*344a7f5eSAndroid Build Coastguard Worker * m: Matrix to set. 412*344a7f5eSAndroid Build Coastguard Worker * x: Number to add to each x component. 413*344a7f5eSAndroid Build Coastguard Worker * y: Number to add to each y component. 414*344a7f5eSAndroid Build Coastguard Worker * z: Number to add to each z component. 415*344a7f5eSAndroid Build Coastguard Worker */ 416*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 417*344a7f5eSAndroid Build Coastguard Worker rsMatrixLoadTranslate(rs_matrix4x4* m, float x, float y, float z); 418*344a7f5eSAndroid Build Coastguard Worker 419*344a7f5eSAndroid Build Coastguard Worker/* 420*344a7f5eSAndroid Build Coastguard Worker * rsMatrixMultiply: Multiply a matrix by a vector or another matrix 421*344a7f5eSAndroid Build Coastguard Worker * 422*344a7f5eSAndroid Build Coastguard Worker * For the matrix by matrix variant, sets m to the matrix product m * rhs. 423*344a7f5eSAndroid Build Coastguard Worker * 424*344a7f5eSAndroid Build Coastguard Worker * When combining two 4x4 transformation matrices using this function, the resulting 425*344a7f5eSAndroid Build Coastguard Worker * matrix will correspond to performing the rhs transformation first followed by 426*344a7f5eSAndroid Build Coastguard Worker * the original m transformation. 427*344a7f5eSAndroid Build Coastguard Worker * 428*344a7f5eSAndroid Build Coastguard Worker * For the matrix by vector variant, returns the post-multiplication of the vector 429*344a7f5eSAndroid Build Coastguard Worker * by the matrix, ie. m * in. 430*344a7f5eSAndroid Build Coastguard Worker * 431*344a7f5eSAndroid Build Coastguard Worker * When multiplying a float3 to a rs_matrix4x4, the vector is expanded with (1). 432*344a7f5eSAndroid Build Coastguard Worker * 433*344a7f5eSAndroid Build Coastguard Worker * When multiplying a float2 to a rs_matrix4x4, the vector is expanded with (0, 1). 434*344a7f5eSAndroid Build Coastguard Worker * 435*344a7f5eSAndroid Build Coastguard Worker * When multiplying a float2 to a rs_matrix3x3, the vector is expanded with (0). 436*344a7f5eSAndroid Build Coastguard Worker * 437*344a7f5eSAndroid Build Coastguard Worker * Starting with API 14, this function takes a const matrix as the first argument. 438*344a7f5eSAndroid Build Coastguard Worker * 439*344a7f5eSAndroid Build Coastguard Worker * Parameters: 440*344a7f5eSAndroid Build Coastguard Worker * m: Left matrix of the product and the matrix to be set. 441*344a7f5eSAndroid Build Coastguard Worker * rhs: Right matrix of the product. 442*344a7f5eSAndroid Build Coastguard Worker */ 443*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 444*344a7f5eSAndroid Build Coastguard Worker rsMatrixMultiply(rs_matrix4x4* m, const rs_matrix4x4* rhs); 445*344a7f5eSAndroid Build Coastguard Worker 446*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 447*344a7f5eSAndroid Build Coastguard Worker rsMatrixMultiply(rs_matrix3x3* m, const rs_matrix3x3* rhs); 448*344a7f5eSAndroid Build Coastguard Worker 449*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 450*344a7f5eSAndroid Build Coastguard Worker rsMatrixMultiply(rs_matrix2x2* m, const rs_matrix2x2* rhs); 451*344a7f5eSAndroid Build Coastguard Worker 452*344a7f5eSAndroid Build Coastguard Worker#if !defined(RS_VERSION) || (RS_VERSION <= 13) 453*344a7f5eSAndroid Build Coastguard Workerextern float4 __attribute__((overloadable)) 454*344a7f5eSAndroid Build Coastguard Worker rsMatrixMultiply(rs_matrix4x4* m, float4 in); 455*344a7f5eSAndroid Build Coastguard Worker#endif 456*344a7f5eSAndroid Build Coastguard Worker 457*344a7f5eSAndroid Build Coastguard Worker#if !defined(RS_VERSION) || (RS_VERSION <= 13) 458*344a7f5eSAndroid Build Coastguard Workerextern float4 __attribute__((overloadable)) 459*344a7f5eSAndroid Build Coastguard Worker rsMatrixMultiply(rs_matrix4x4* m, float3 in); 460*344a7f5eSAndroid Build Coastguard Worker#endif 461*344a7f5eSAndroid Build Coastguard Worker 462*344a7f5eSAndroid Build Coastguard Worker#if !defined(RS_VERSION) || (RS_VERSION <= 13) 463*344a7f5eSAndroid Build Coastguard Workerextern float4 __attribute__((overloadable)) 464*344a7f5eSAndroid Build Coastguard Worker rsMatrixMultiply(rs_matrix4x4* m, float2 in); 465*344a7f5eSAndroid Build Coastguard Worker#endif 466*344a7f5eSAndroid Build Coastguard Worker 467*344a7f5eSAndroid Build Coastguard Worker#if !defined(RS_VERSION) || (RS_VERSION <= 13) 468*344a7f5eSAndroid Build Coastguard Workerextern float3 __attribute__((overloadable)) 469*344a7f5eSAndroid Build Coastguard Worker rsMatrixMultiply(rs_matrix3x3* m, float3 in); 470*344a7f5eSAndroid Build Coastguard Worker#endif 471*344a7f5eSAndroid Build Coastguard Worker 472*344a7f5eSAndroid Build Coastguard Worker#if !defined(RS_VERSION) || (RS_VERSION <= 13) 473*344a7f5eSAndroid Build Coastguard Workerextern float3 __attribute__((overloadable)) 474*344a7f5eSAndroid Build Coastguard Worker rsMatrixMultiply(rs_matrix3x3* m, float2 in); 475*344a7f5eSAndroid Build Coastguard Worker#endif 476*344a7f5eSAndroid Build Coastguard Worker 477*344a7f5eSAndroid Build Coastguard Worker#if !defined(RS_VERSION) || (RS_VERSION <= 13) 478*344a7f5eSAndroid Build Coastguard Workerextern float2 __attribute__((overloadable)) 479*344a7f5eSAndroid Build Coastguard Worker rsMatrixMultiply(rs_matrix2x2* m, float2 in); 480*344a7f5eSAndroid Build Coastguard Worker#endif 481*344a7f5eSAndroid Build Coastguard Worker 482*344a7f5eSAndroid Build Coastguard Worker#if (defined(RS_VERSION) && (RS_VERSION >= 14)) 483*344a7f5eSAndroid Build Coastguard Workerextern float4 __attribute__((overloadable)) 484*344a7f5eSAndroid Build Coastguard Worker rsMatrixMultiply(const rs_matrix4x4* m, float4 in); 485*344a7f5eSAndroid Build Coastguard Worker#endif 486*344a7f5eSAndroid Build Coastguard Worker 487*344a7f5eSAndroid Build Coastguard Worker#if (defined(RS_VERSION) && (RS_VERSION >= 14)) 488*344a7f5eSAndroid Build Coastguard Workerextern float4 __attribute__((overloadable)) 489*344a7f5eSAndroid Build Coastguard Worker rsMatrixMultiply(const rs_matrix4x4* m, float3 in); 490*344a7f5eSAndroid Build Coastguard Worker#endif 491*344a7f5eSAndroid Build Coastguard Worker 492*344a7f5eSAndroid Build Coastguard Worker#if (defined(RS_VERSION) && (RS_VERSION >= 14)) 493*344a7f5eSAndroid Build Coastguard Workerextern float4 __attribute__((overloadable)) 494*344a7f5eSAndroid Build Coastguard Worker rsMatrixMultiply(const rs_matrix4x4* m, float2 in); 495*344a7f5eSAndroid Build Coastguard Worker#endif 496*344a7f5eSAndroid Build Coastguard Worker 497*344a7f5eSAndroid Build Coastguard Worker#if (defined(RS_VERSION) && (RS_VERSION >= 14)) 498*344a7f5eSAndroid Build Coastguard Workerextern float3 __attribute__((overloadable)) 499*344a7f5eSAndroid Build Coastguard Worker rsMatrixMultiply(const rs_matrix3x3* m, float3 in); 500*344a7f5eSAndroid Build Coastguard Worker#endif 501*344a7f5eSAndroid Build Coastguard Worker 502*344a7f5eSAndroid Build Coastguard Worker#if (defined(RS_VERSION) && (RS_VERSION >= 14)) 503*344a7f5eSAndroid Build Coastguard Workerextern float3 __attribute__((overloadable)) 504*344a7f5eSAndroid Build Coastguard Worker rsMatrixMultiply(const rs_matrix3x3* m, float2 in); 505*344a7f5eSAndroid Build Coastguard Worker#endif 506*344a7f5eSAndroid Build Coastguard Worker 507*344a7f5eSAndroid Build Coastguard Worker#if (defined(RS_VERSION) && (RS_VERSION >= 14)) 508*344a7f5eSAndroid Build Coastguard Workerextern float2 __attribute__((overloadable)) 509*344a7f5eSAndroid Build Coastguard Worker rsMatrixMultiply(const rs_matrix2x2* m, float2 in); 510*344a7f5eSAndroid Build Coastguard Worker#endif 511*344a7f5eSAndroid Build Coastguard Worker 512*344a7f5eSAndroid Build Coastguard Worker/* 513*344a7f5eSAndroid Build Coastguard Worker * rsMatrixRotate: Apply a rotation to a transformation matrix 514*344a7f5eSAndroid Build Coastguard Worker * 515*344a7f5eSAndroid Build Coastguard Worker * Multiply the matrix m with a rotation matrix. 516*344a7f5eSAndroid Build Coastguard Worker * 517*344a7f5eSAndroid Build Coastguard Worker * This function modifies a transformation matrix to first do a rotation. The axis of 518*344a7f5eSAndroid Build Coastguard Worker * rotation is the (x, y, z) vector. 519*344a7f5eSAndroid Build Coastguard Worker * 520*344a7f5eSAndroid Build Coastguard Worker * To apply this combined transformation to a vector, multiply the vector by the created 521*344a7f5eSAndroid Build Coastguard Worker * matrix using rsMatrixMultiply(). 522*344a7f5eSAndroid Build Coastguard Worker * 523*344a7f5eSAndroid Build Coastguard Worker * Parameters: 524*344a7f5eSAndroid Build Coastguard Worker * m: Matrix to modify. 525*344a7f5eSAndroid Build Coastguard Worker * rot: How much rotation to do, in degrees. 526*344a7f5eSAndroid Build Coastguard Worker * x: X component of the vector that is the axis of rotation. 527*344a7f5eSAndroid Build Coastguard Worker * y: Y component of the vector that is the axis of rotation. 528*344a7f5eSAndroid Build Coastguard Worker * z: Z component of the vector that is the axis of rotation. 529*344a7f5eSAndroid Build Coastguard Worker */ 530*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 531*344a7f5eSAndroid Build Coastguard Worker rsMatrixRotate(rs_matrix4x4* m, float rot, float x, float y, float z); 532*344a7f5eSAndroid Build Coastguard Worker 533*344a7f5eSAndroid Build Coastguard Worker/* 534*344a7f5eSAndroid Build Coastguard Worker * rsMatrixScale: Apply a scaling to a transformation matrix 535*344a7f5eSAndroid Build Coastguard Worker * 536*344a7f5eSAndroid Build Coastguard Worker * Multiply the matrix m with a scaling matrix. 537*344a7f5eSAndroid Build Coastguard Worker * 538*344a7f5eSAndroid Build Coastguard Worker * This function modifies a transformation matrix to first do a scaling. When scaling, 539*344a7f5eSAndroid Build Coastguard Worker * each component of a vector is multiplied by a number. This number can be negative. 540*344a7f5eSAndroid Build Coastguard Worker * 541*344a7f5eSAndroid Build Coastguard Worker * To apply this combined transformation to a vector, multiply the vector by the created 542*344a7f5eSAndroid Build Coastguard Worker * matrix using rsMatrixMultiply(). 543*344a7f5eSAndroid Build Coastguard Worker * 544*344a7f5eSAndroid Build Coastguard Worker * Parameters: 545*344a7f5eSAndroid Build Coastguard Worker * m: Matrix to modify. 546*344a7f5eSAndroid Build Coastguard Worker * x: Multiple to scale the x components by. 547*344a7f5eSAndroid Build Coastguard Worker * y: Multiple to scale the y components by. 548*344a7f5eSAndroid Build Coastguard Worker * z: Multiple to scale the z components by. 549*344a7f5eSAndroid Build Coastguard Worker */ 550*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 551*344a7f5eSAndroid Build Coastguard Worker rsMatrixScale(rs_matrix4x4* m, float x, float y, float z); 552*344a7f5eSAndroid Build Coastguard Worker 553*344a7f5eSAndroid Build Coastguard Worker/* 554*344a7f5eSAndroid Build Coastguard Worker * rsMatrixSet: Set one element 555*344a7f5eSAndroid Build Coastguard Worker * 556*344a7f5eSAndroid Build Coastguard Worker * Set an element of a matrix. 557*344a7f5eSAndroid Build Coastguard Worker * 558*344a7f5eSAndroid Build Coastguard Worker * Warning: The order of the column and row parameters may be unexpected. 559*344a7f5eSAndroid Build Coastguard Worker * 560*344a7f5eSAndroid Build Coastguard Worker * Parameters: 561*344a7f5eSAndroid Build Coastguard Worker * m: Matrix that will be modified. 562*344a7f5eSAndroid Build Coastguard Worker * col: Zero-based column of the element to be set. 563*344a7f5eSAndroid Build Coastguard Worker * row: Zero-based row of the element to be set. 564*344a7f5eSAndroid Build Coastguard Worker * v: Value to set. 565*344a7f5eSAndroid Build Coastguard Worker */ 566*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 567*344a7f5eSAndroid Build Coastguard Worker rsMatrixSet(rs_matrix4x4* m, uint32_t col, uint32_t row, float v); 568*344a7f5eSAndroid Build Coastguard Worker 569*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 570*344a7f5eSAndroid Build Coastguard Worker rsMatrixSet(rs_matrix3x3* m, uint32_t col, uint32_t row, float v); 571*344a7f5eSAndroid Build Coastguard Worker 572*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 573*344a7f5eSAndroid Build Coastguard Worker rsMatrixSet(rs_matrix2x2* m, uint32_t col, uint32_t row, float v); 574*344a7f5eSAndroid Build Coastguard Worker 575*344a7f5eSAndroid Build Coastguard Worker/* 576*344a7f5eSAndroid Build Coastguard Worker * rsMatrixTranslate: Apply a translation to a transformation matrix 577*344a7f5eSAndroid Build Coastguard Worker * 578*344a7f5eSAndroid Build Coastguard Worker * Multiply the matrix m with a translation matrix. 579*344a7f5eSAndroid Build Coastguard Worker * 580*344a7f5eSAndroid Build Coastguard Worker * This function modifies a transformation matrix to first do a translation. When 581*344a7f5eSAndroid Build Coastguard Worker * translating, a number is added to each component of a vector. 582*344a7f5eSAndroid Build Coastguard Worker * 583*344a7f5eSAndroid Build Coastguard Worker * To apply this combined transformation to a vector, multiply the vector by the 584*344a7f5eSAndroid Build Coastguard Worker * created matrix using rsMatrixMultiply(). 585*344a7f5eSAndroid Build Coastguard Worker * 586*344a7f5eSAndroid Build Coastguard Worker * Parameters: 587*344a7f5eSAndroid Build Coastguard Worker * m: Matrix to modify. 588*344a7f5eSAndroid Build Coastguard Worker * x: Number to add to each x component. 589*344a7f5eSAndroid Build Coastguard Worker * y: Number to add to each y component. 590*344a7f5eSAndroid Build Coastguard Worker * z: Number to add to each z component. 591*344a7f5eSAndroid Build Coastguard Worker */ 592*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 593*344a7f5eSAndroid Build Coastguard Worker rsMatrixTranslate(rs_matrix4x4* m, float x, float y, float z); 594*344a7f5eSAndroid Build Coastguard Worker 595*344a7f5eSAndroid Build Coastguard Worker/* 596*344a7f5eSAndroid Build Coastguard Worker * rsMatrixTranspose: Transpose a matrix place 597*344a7f5eSAndroid Build Coastguard Worker * 598*344a7f5eSAndroid Build Coastguard Worker * Transpose the matrix m in place. 599*344a7f5eSAndroid Build Coastguard Worker * 600*344a7f5eSAndroid Build Coastguard Worker * Parameters: 601*344a7f5eSAndroid Build Coastguard Worker * m: Matrix to transpose. 602*344a7f5eSAndroid Build Coastguard Worker */ 603*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 604*344a7f5eSAndroid Build Coastguard Worker rsMatrixTranspose(rs_matrix4x4* m); 605*344a7f5eSAndroid Build Coastguard Worker 606*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 607*344a7f5eSAndroid Build Coastguard Worker rsMatrixTranspose(rs_matrix3x3* m); 608*344a7f5eSAndroid Build Coastguard Worker 609*344a7f5eSAndroid Build Coastguard Workerextern void __attribute__((overloadable)) 610*344a7f5eSAndroid Build Coastguard Worker rsMatrixTranspose(rs_matrix2x2* m); 611*344a7f5eSAndroid Build Coastguard Worker 612*344a7f5eSAndroid Build Coastguard Worker#endif // RENDERSCRIPT_RS_MATRIX_RSH 613