Home | History | Annotate | Download | only in include
      1 #ifndef __RS_CORE_RSH__
      2 #define __RS_CORE_RSH__
      3 
      4 #define _RS_RUNTIME extern
      5 
      6 /**
      7  * Debug function.  Prints a string and value to the log.
      8  */
      9 extern void __attribute__((overloadable))
     10     rsDebug(const char *, float);
     11 /**
     12  * Debug function.  Prints a string and value to the log.
     13  */
     14 extern void __attribute__((overloadable))
     15     rsDebug(const char *, float, float);
     16 /**
     17  * Debug function.  Prints a string and value to the log.
     18  */
     19 extern void __attribute__((overloadable))
     20     rsDebug(const char *, float, float, float);
     21 /**
     22  * Debug function.  Prints a string and value to the log.
     23  */
     24 extern void __attribute__((overloadable))
     25     rsDebug(const char *, float, float, float, float);
     26 /**
     27  * Debug function.  Prints a string and value to the log.
     28  */
     29 extern void __attribute__((overloadable))
     30     rsDebug(const char *, double);
     31 /**
     32  * Debug function.  Prints a string and value to the log.
     33  */
     34 extern void __attribute__((overloadable))
     35     rsDebug(const char *, const rs_matrix4x4 *);
     36 /**
     37  * Debug function.  Prints a string and value to the log.
     38  */
     39 extern void __attribute__((overloadable))
     40     rsDebug(const char *, const rs_matrix3x3 *);
     41 /**
     42  * Debug function.  Prints a string and value to the log.
     43  */
     44 extern void __attribute__((overloadable))
     45     rsDebug(const char *, const rs_matrix2x2 *);
     46 /**
     47  * Debug function.  Prints a string and value to the log.
     48  */
     49 extern void __attribute__((overloadable))
     50     rsDebug(const char *, int);
     51 /**
     52  * Debug function.  Prints a string and value to the log.
     53  */
     54 extern void __attribute__((overloadable))
     55     rsDebug(const char *, uint);
     56 /**
     57  * Debug function.  Prints a string and value to the log.
     58  */
     59 extern void __attribute__((overloadable))
     60     rsDebug(const char *, long);
     61 /**
     62  * Debug function.  Prints a string and value to the log.
     63  */
     64 extern void __attribute__((overloadable))
     65     rsDebug(const char *, unsigned long);
     66 /**
     67  * Debug function.  Prints a string and value to the log.
     68  */
     69 extern void __attribute__((overloadable))
     70     rsDebug(const char *, long long);
     71 /**
     72  * Debug function.  Prints a string and value to the log.
     73  */
     74 extern void __attribute__((overloadable))
     75     rsDebug(const char *, unsigned long long);
     76 /**
     77  * Debug function.  Prints a string and value to the log.
     78  */
     79 extern void __attribute__((overloadable))
     80     rsDebug(const char *, const void *);
     81 #define RS_DEBUG(a) rsDebug(#a, a)
     82 #define RS_DEBUG_MARKER rsDebug(__FILE__, __LINE__)
     83 
     84 
     85 /**
     86  * Debug function.  Prints a string and value to the log.
     87  */
     88 _RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float2 v);
     89 /**
     90  * Debug function.  Prints a string and value to the log.
     91  */
     92 _RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float3 v);
     93 /**
     94  * Debug function.  Prints a string and value to the log.
     95  */
     96 _RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float4 v);
     97 
     98 
     99 /**
    100  * Pack floating point (0-1) RGB values into a uchar4.  The alpha component is
    101  * set to 255 (1.0).
    102  *
    103  * @param r
    104  * @param g
    105  * @param b
    106  *
    107  * @return uchar4
    108  */
    109 _RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b);
    110 
    111 /**
    112  * Pack floating point (0-1) RGBA values into a uchar4.
    113  *
    114  * @param r
    115  * @param g
    116  * @param b
    117  * @param a
    118  *
    119  * @return uchar4
    120  */
    121 _RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b, float a);
    122 
    123 /**
    124  * Pack floating point (0-1) RGB values into a uchar4.  The alpha component is
    125  * set to 255 (1.0).
    126  *
    127  * @param color
    128  *
    129  * @return uchar4
    130  */
    131 _RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float3 color);
    132 
    133 /**
    134  * Pack floating point (0-1) RGBA values into a uchar4.
    135  *
    136  * @param color
    137  *
    138  * @return uchar4
    139  */
    140 _RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float4 color);
    141 
    142 /**
    143  * Unpack a uchar4 color to float4.  The resulting float range will be (0-1).
    144  *
    145  * @param c
    146  *
    147  * @return float4
    148  */
    149 _RS_RUNTIME float4 rsUnpackColor8888(uchar4 c);
    150 
    151 
    152 /////////////////////////////////////////////////////
    153 // Matrix ops
    154 /////////////////////////////////////////////////////
    155 
    156 /**
    157  * Set one element of a matrix.
    158  *
    159  * @param m The matrix to be set
    160  * @param row
    161  * @param col
    162  * @param v
    163  *
    164  * @return void
    165  */
    166 _RS_RUNTIME void __attribute__((overloadable))
    167 rsMatrixSet(rs_matrix4x4 *m, uint32_t row, uint32_t col, float v);
    168 _RS_RUNTIME void __attribute__((overloadable))
    169 rsMatrixSet(rs_matrix3x3 *m, uint32_t row, uint32_t col, float v);
    170 _RS_RUNTIME void __attribute__((overloadable))
    171 rsMatrixSet(rs_matrix2x2 *m, uint32_t row, uint32_t col, float v);
    172 
    173 /**
    174  * Get one element of a matrix.
    175  *
    176  * @param m The matrix to read from
    177  * @param row
    178  * @param col
    179  *
    180  * @return float
    181  */
    182 _RS_RUNTIME float __attribute__((overloadable))
    183 rsMatrixGet(const rs_matrix4x4 *m, uint32_t row, uint32_t col);
    184 _RS_RUNTIME float __attribute__((overloadable))
    185 rsMatrixGet(const rs_matrix3x3 *m, uint32_t row, uint32_t col);
    186 _RS_RUNTIME float __attribute__((overloadable))
    187 rsMatrixGet(const rs_matrix2x2 *m, uint32_t row, uint32_t col);
    188 
    189 /**
    190  * Set the elements of a matrix to the identity matrix.
    191  *
    192  * @param m
    193  */
    194 extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix4x4 *m);
    195 extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix3x3 *m);
    196 extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix2x2 *m);
    197 
    198 /**
    199  * Set the elements of a matrix from an array of floats.
    200  *
    201  * @param m
    202  */
    203 extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const float *v);
    204 extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix3x3 *m, const float *v);
    205 extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix2x2 *m, const float *v);
    206 
    207 /**
    208  * Set the elements of a matrix from another matrix.
    209  *
    210  * @param m
    211  */
    212 extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix4x4 *v);
    213 extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix3x3 *v);
    214 extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix2x2 *v);
    215 extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix3x3 *m, const rs_matrix3x3 *v);
    216 extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix2x2 *m, const rs_matrix2x2 *v);
    217 
    218 /**
    219  * Load a rotation matrix.
    220  *
    221  * @param m
    222  * @param rot
    223  * @param x
    224  * @param y
    225  * @param z
    226  */
    227 extern void __attribute__((overloadable))
    228 rsMatrixLoadRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
    229 
    230 extern void __attribute__((overloadable))
    231 rsMatrixLoadScale(rs_matrix4x4 *m, float x, float y, float z);
    232 
    233 extern void __attribute__((overloadable))
    234 rsMatrixLoadTranslate(rs_matrix4x4 *m, float x, float y, float z);
    235 
    236 extern void __attribute__((overloadable))
    237 rsMatrixLoadMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *lhs, const rs_matrix4x4 *rhs);
    238 
    239 extern void __attribute__((overloadable))
    240 rsMatrixMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *rhs);
    241 
    242 extern void __attribute__((overloadable))
    243 rsMatrixLoadMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *lhs, const rs_matrix3x3 *rhs);
    244 
    245 extern void __attribute__((overloadable))
    246 rsMatrixMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *rhs);
    247 
    248 extern void __attribute__((overloadable))
    249 rsMatrixLoadMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *lhs, const rs_matrix2x2 *rhs);
    250 
    251 extern void __attribute__((overloadable))
    252 rsMatrixMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *rhs);
    253 
    254 extern void __attribute__((overloadable))
    255 rsMatrixRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
    256 
    257 extern void __attribute__((overloadable))
    258 rsMatrixScale(rs_matrix4x4 *m, float x, float y, float z);
    259 
    260 extern void __attribute__((overloadable))
    261 rsMatrixTranslate(rs_matrix4x4 *m, float x, float y, float z);
    262 
    263 extern void __attribute__((overloadable))
    264 rsMatrixLoadOrtho(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far);
    265 
    266 extern void __attribute__((overloadable))
    267 rsMatrixLoadFrustum(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far);
    268 
    269 extern void __attribute__((overloadable))
    270 rsMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far);
    271 
    272 _RS_RUNTIME float4 __attribute__((overloadable))
    273 rsMatrixMultiply(rs_matrix4x4 *m, float4 in);
    274 
    275 _RS_RUNTIME float4 __attribute__((overloadable))
    276 rsMatrixMultiply(rs_matrix4x4 *m, float3 in);
    277 
    278 _RS_RUNTIME float4 __attribute__((overloadable))
    279 rsMatrixMultiply(rs_matrix4x4 *m, float2 in);
    280 
    281 _RS_RUNTIME float3 __attribute__((overloadable))
    282 rsMatrixMultiply(rs_matrix3x3 *m, float3 in);
    283 
    284 _RS_RUNTIME float3 __attribute__((overloadable))
    285 rsMatrixMultiply(rs_matrix3x3 *m, float2 in);
    286 
    287 _RS_RUNTIME float2 __attribute__((overloadable))
    288 rsMatrixMultiply(rs_matrix2x2 *m, float2 in);
    289 
    290 // Returns true if the matrix was successfully inversed
    291 extern bool __attribute__((overloadable)) rsMatrixInverse(rs_matrix4x4 *m);
    292 extern bool __attribute__((overloadable)) rsMatrixInverseTranspose(rs_matrix4x4 *m);
    293 extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix4x4 *m);
    294 extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix3x3 *m);
    295 extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix2x2 *m);
    296 
    297 /////////////////////////////////////////////////////
    298 // int ops
    299 /////////////////////////////////////////////////////
    300 
    301 _RS_RUNTIME uint __attribute__((overloadable, always_inline)) rsClamp(uint amount, uint low, uint high);
    302 _RS_RUNTIME int __attribute__((overloadable, always_inline)) rsClamp(int amount, int low, int high);
    303 _RS_RUNTIME ushort __attribute__((overloadable, always_inline)) rsClamp(ushort amount, ushort low, ushort high);
    304 _RS_RUNTIME short __attribute__((overloadable, always_inline)) rsClamp(short amount, short low, short high);
    305 _RS_RUNTIME uchar __attribute__((overloadable, always_inline)) rsClamp(uchar amount, uchar low, uchar high);
    306 _RS_RUNTIME char __attribute__((overloadable, always_inline)) rsClamp(char amount, char low, char high);
    307 
    308 #undef _RS_RUNTIME
    309 
    310 #endif
    311