1 page.title=RenderScript Runtime API Reference 2 3 @jd:body 4 5 <div class='renderscript'> 6 <h2>Overview</h2> 7 <p> RenderScript is a high-performance runtime that provides compute operations at the native level. 8 RenderScript code is compiled on devices at runtime to allow platform-independence as well. 9 </p> 10 11 <p> This reference documentation describes the RenderScript runtime APIs, which you can utilize 12 to write RenderScript code in C99. The RenderScript compute header files are automatically 13 included for you. 14 </p> 15 16 <p> To use RenderScript, you need to utilize the RenderScript runtime APIs documented here as well 17 as the Android framework APIs for RenderScript. For documentation on the Android framework 18 APIs, see the <a target="_parent" href="http://developer.android.com/reference/android/renderscript/package-summary.html">android.renderscript</a> package reference. 19 </p> 20 21 <p> For more information on how to develop with RenderScript and how the runtime and Android 22 framework APIs interact, see the <a target="_parent" href="http://developer.android.com/guide/topics/renderscript/index.html">RenderScript developer guide</a> and the <a target="_parent" href="http://developer.android.com/resources/samples/RenderScript/index.html">RenderScript samples</a>. 23 </p> 24 <h2>Numerical Types</h2> 25 <p> <h5>Scalars:</h5> 26 </p> 27 28 <p> RenderScript supports the following scalar numerical types: 29 <table> 30 <tr><td> </td> <td>8 bits </td> <td>16 bits </td> <td>32 bits </td> <td>64 bits</td></tr> 31 <tr><td>Integer: </td> <td>char, <a href='rs_value_types.html#android_rs:int8_t'>int8_t</a> </td> <td>short, <a href='rs_value_types.html#android_rs:int16_t'>int16_t</a> </td> <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> </td> <td>long, long long, <a href='rs_value_types.html#android_rs:int64_t'>int64_t</a></td></tr> 32 <tr><td>Unsigned integer:</td> <td>uchar, <a href='rs_value_types.html#android_rs:uint8_t'>uint8_t</a></td> <td>ushort, <a href='rs_value_types.html#android_rs:uint16_t'>uint16_t</a></td> <td>uint, <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a></td> <td>ulong, <a href='rs_value_types.html#android_rs:uint64_t'>uint64_t</a></td></tr> 33 <tr><td>Floating point: </td> <td> </td> <td>half </td> <td>float </td> <td>double</td></tr> 34 </table> 35 </p> 36 37 <p> <h5>Vectors:</h5> 38 </p> 39 40 <p> RenderScript supports fixed size vectors of length 2, 3, and 4. 41 Vectors are declared using the common type name followed by a 2, 3, or 4. 42 E.g. <a href='rs_value_types.html#android_rs:float4'>float4</a>, <a href='rs_value_types.html#android_rs:int3'>int3</a>, <a href='rs_value_types.html#android_rs:double2'>double2</a>, <a href='rs_value_types.html#android_rs:ulong4'>ulong4</a>. 43 </p> 44 45 <p> To create vector literals, use the vector type followed by the values enclosed 46 between curly braces, e.g. <code>(float3){1.0f, 2.0f, 3.0f}</code>. 47 </p> 48 49 <p> Entries of a vector can be accessed using different naming styles. 50 </p> 51 52 <p> Single entries can be accessed by following the variable name with a dot and:<ul> 53 <li>The letters x, y, z, and w,</li> 54 <li>The letters r, g, b, and a,</li> 55 <li>The letter s or S, followed by a zero based index.</li></ul> 56 </p> 57 58 <p> For example, with <code>int4 myVar;</code> the following are equivalent:<code><br/> 59 myVar.x == myVar.r == myVar.s0 == myVar.S0<br/> 60 myVar.y == myVar.g == myVar.s1 == myVar.S1<br/> 61 myVar.z == myVar.b == myVar.s2 == myVar.S2<br/> 62 myVar.w == myVar.a == myVar.s3 == myVar.S3</code> 63 </p> 64 65 <p> Multiple entries of a vector can be accessed at once by using an identifier that is 66 the concatenation of multiple letters or indices. The resulting vector has a size 67 equal to the number of entries named. 68 </p> 69 70 <p> With the example above, the middle two entries can be accessed using 71 <code>myVar.yz</code>, <code>myVar.gb</code>, <code>myVar.s12</code>, and <code>myVar.S12</code>. 72 </p> 73 74 <p> The entries don't have to be contiguous or in increasing order. Entries can even be 75 repeated, as long as we're not trying to assign to it. You also can't mix the naming 76 styles. 77 </p> 78 79 <p> Here are examples of what can or can't be done:<code><br/> 80 float4 v4;<br/> 81 float3 v3;<br/> 82 float2 v2;<br/> 83 v2 = v4.xx; // Valid<br/> 84 v3 = v4.zxw; // Valid<br/> 85 v3 = v4.bba; // Valid<br/> 86 v3 = v4.s032; // Valid<br/> 87 v3.s120 = v4.S233; // Valid<br/> 88 v4.yz = v3.rg; // Valid<br/> 89 v4.yzx = v3.rg; // Invalid: mismatched sizes<br/> 90 v4.yzz = v3; // Invalid: z appears twice in an assignment<br/> 91 v3 = v3.xas0; // Invalid: can't mix xyzw with rgba nor s0...<br/> 92 v3 = v4.s034; // Invalid: the digit can only be 0, 1, 2, or 3<br/> 93 </code> 94 </p> 95 96 <p> <h5>Matrices and Quaternions:</h5> 97 </p> 98 99 <p> RenderScript supports fixed size square matrices of floats of size 2x2, 3x3, and 4x4. 100 The types are named <a href='rs_value_types.html#android_rs:rs_matrix2x2'>rs_matrix2x2</a>, <a href='rs_value_types.html#android_rs:rs_matrix3x3'>rs_matrix3x3</a>, and <a href='rs_value_types.html#android_rs:rs_matrix4x4'>rs_matrix4x4</a>. See 101 <a href='rs_matrix.html'>Matrix Functions</a> for the list of operations. 102 </p> 103 104 <p> Quaternions are also supported via <a href='rs_value_types.html#android_rs:rs_quaternion'>rs_quaternion</a>. See <a href='rs_quaternion.html'>Quaterion Functions</a> for the list 105 of operations. 106 </p> 107 <table class='jd-sumtable'><tbody> 108 <tr><th colspan='2'>Types</th></tr> 109 <tr class='alt-color api apilevel-1'> 110 <td class='jd-linkcol'> 111 <a href='rs_value_types.html#android_rs:char2'>char2</a> 112 </td> 113 <td class='jd-descrcol' width='100%'> 114 Two 8 bit signed integers 115 </td> 116 </tr> 117 <tr class='alt-color api apilevel-1'> 118 <td class='jd-linkcol'> 119 <a href='rs_value_types.html#android_rs:char3'>char3</a> 120 </td> 121 <td class='jd-descrcol' width='100%'> 122 Three 8 bit signed integers 123 </td> 124 </tr> 125 <tr class='alt-color api apilevel-1'> 126 <td class='jd-linkcol'> 127 <a href='rs_value_types.html#android_rs:char4'>char4</a> 128 </td> 129 <td class='jd-descrcol' width='100%'> 130 Four 8 bit signed integers 131 </td> 132 </tr> 133 <tr class='alt-color api apilevel-1'> 134 <td class='jd-linkcol'> 135 <a href='rs_value_types.html#android_rs:double2'>double2</a> 136 </td> 137 <td class='jd-descrcol' width='100%'> 138 Two 64 bit floats 139 </td> 140 </tr> 141 <tr class='alt-color api apilevel-1'> 142 <td class='jd-linkcol'> 143 <a href='rs_value_types.html#android_rs:double3'>double3</a> 144 </td> 145 <td class='jd-descrcol' width='100%'> 146 Three 64 bit floats 147 </td> 148 </tr> 149 <tr class='alt-color api apilevel-1'> 150 <td class='jd-linkcol'> 151 <a href='rs_value_types.html#android_rs:double4'>double4</a> 152 </td> 153 <td class='jd-descrcol' width='100%'> 154 Four 64 bit floats 155 </td> 156 </tr> 157 <tr class='alt-color api apilevel-1'> 158 <td class='jd-linkcol'> 159 <a href='rs_value_types.html#android_rs:float2'>float2</a> 160 </td> 161 <td class='jd-descrcol' width='100%'> 162 Two 32 bit floats 163 </td> 164 </tr> 165 <tr class='alt-color api apilevel-1'> 166 <td class='jd-linkcol'> 167 <a href='rs_value_types.html#android_rs:float3'>float3</a> 168 </td> 169 <td class='jd-descrcol' width='100%'> 170 Three 32 bit floats 171 </td> 172 </tr> 173 <tr class='alt-color api apilevel-1'> 174 <td class='jd-linkcol'> 175 <a href='rs_value_types.html#android_rs:float4'>float4</a> 176 </td> 177 <td class='jd-descrcol' width='100%'> 178 Four 32 bit floats 179 </td> 180 </tr> 181 <tr class='alt-color api apilevel-1'> 182 <td class='jd-linkcol'> 183 <a href='rs_value_types.html#android_rs:half'>half</a> 184 </td> 185 <td class='jd-descrcol' width='100%'> 186 16 bit floating point value 187 </td> 188 </tr> 189 <tr class='alt-color api apilevel-1'> 190 <td class='jd-linkcol'> 191 <a href='rs_value_types.html#android_rs:half2'>half2</a> 192 </td> 193 <td class='jd-descrcol' width='100%'> 194 Two 16 bit floats 195 </td> 196 </tr> 197 <tr class='alt-color api apilevel-1'> 198 <td class='jd-linkcol'> 199 <a href='rs_value_types.html#android_rs:half3'>half3</a> 200 </td> 201 <td class='jd-descrcol' width='100%'> 202 Three 16 bit floats 203 </td> 204 </tr> 205 <tr class='alt-color api apilevel-1'> 206 <td class='jd-linkcol'> 207 <a href='rs_value_types.html#android_rs:half4'>half4</a> 208 </td> 209 <td class='jd-descrcol' width='100%'> 210 Four 16 bit floats 211 </td> 212 </tr> 213 <tr class='alt-color api apilevel-1'> 214 <td class='jd-linkcol'> 215 <a href='rs_value_types.html#android_rs:int16_t'>int16_t</a> 216 </td> 217 <td class='jd-descrcol' width='100%'> 218 16 bit signed integer 219 </td> 220 </tr> 221 <tr class='alt-color api apilevel-1'> 222 <td class='jd-linkcol'> 223 <a href='rs_value_types.html#android_rs:int2'>int2</a> 224 </td> 225 <td class='jd-descrcol' width='100%'> 226 Two 32 bit signed integers 227 </td> 228 </tr> 229 <tr class='alt-color api apilevel-1'> 230 <td class='jd-linkcol'> 231 <a href='rs_value_types.html#android_rs:int3'>int3</a> 232 </td> 233 <td class='jd-descrcol' width='100%'> 234 Three 32 bit signed integers 235 </td> 236 </tr> 237 <tr class='alt-color api apilevel-1'> 238 <td class='jd-linkcol'> 239 <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> 240 </td> 241 <td class='jd-descrcol' width='100%'> 242 32 bit signed integer 243 </td> 244 </tr> 245 <tr class='alt-color api apilevel-1'> 246 <td class='jd-linkcol'> 247 <a href='rs_value_types.html#android_rs:int4'>int4</a> 248 </td> 249 <td class='jd-descrcol' width='100%'> 250 Four 32 bit signed integers 251 </td> 252 </tr> 253 <tr class='alt-color api apilevel-1'> 254 <td class='jd-linkcol'> 255 <a href='rs_value_types.html#android_rs:int64_t'>int64_t</a> 256 </td> 257 <td class='jd-descrcol' width='100%'> 258 64 bit signed integer 259 </td> 260 </tr> 261 <tr class='alt-color api apilevel-1'> 262 <td class='jd-linkcol'> 263 <a href='rs_value_types.html#android_rs:int8_t'>int8_t</a> 264 </td> 265 <td class='jd-descrcol' width='100%'> 266 8 bit signed integer 267 </td> 268 </tr> 269 <tr class='alt-color api apilevel-1'> 270 <td class='jd-linkcol'> 271 <a href='rs_value_types.html#android_rs:long2'>long2</a> 272 </td> 273 <td class='jd-descrcol' width='100%'> 274 Two 64 bit signed integers 275 </td> 276 </tr> 277 <tr class='alt-color api apilevel-1'> 278 <td class='jd-linkcol'> 279 <a href='rs_value_types.html#android_rs:long3'>long3</a> 280 </td> 281 <td class='jd-descrcol' width='100%'> 282 Three 64 bit signed integers 283 </td> 284 </tr> 285 <tr class='alt-color api apilevel-1'> 286 <td class='jd-linkcol'> 287 <a href='rs_value_types.html#android_rs:long4'>long4</a> 288 </td> 289 <td class='jd-descrcol' width='100%'> 290 Four 64 bit signed integers 291 </td> 292 </tr> 293 <tr class='alt-color api apilevel-1'> 294 <td class='jd-linkcol'> 295 <a href='rs_value_types.html#android_rs:rs_matrix2x2'>rs_matrix2x2</a> 296 </td> 297 <td class='jd-descrcol' width='100%'> 298 2x2 matrix of 32 bit floats 299 </td> 300 </tr> 301 <tr class='alt-color api apilevel-1'> 302 <td class='jd-linkcol'> 303 <a href='rs_value_types.html#android_rs:rs_matrix3x3'>rs_matrix3x3</a> 304 </td> 305 <td class='jd-descrcol' width='100%'> 306 3x3 matrix of 32 bit floats 307 </td> 308 </tr> 309 <tr class='alt-color api apilevel-1'> 310 <td class='jd-linkcol'> 311 <a href='rs_value_types.html#android_rs:rs_matrix4x4'>rs_matrix4x4</a> 312 </td> 313 <td class='jd-descrcol' width='100%'> 314 4x4 matrix of 32 bit floats 315 </td> 316 </tr> 317 <tr class='alt-color api apilevel-1'> 318 <td class='jd-linkcol'> 319 <a href='rs_value_types.html#android_rs:rs_quaternion'>rs_quaternion</a> 320 </td> 321 <td class='jd-descrcol' width='100%'> 322 Quaternion 323 </td> 324 </tr> 325 <tr class='alt-color api apilevel-1'> 326 <td class='jd-linkcol'> 327 <a href='rs_value_types.html#android_rs:short2'>short2</a> 328 </td> 329 <td class='jd-descrcol' width='100%'> 330 Two 16 bit signed integers 331 </td> 332 </tr> 333 <tr class='alt-color api apilevel-1'> 334 <td class='jd-linkcol'> 335 <a href='rs_value_types.html#android_rs:short3'>short3</a> 336 </td> 337 <td class='jd-descrcol' width='100%'> 338 Three 16 bit signed integers 339 </td> 340 </tr> 341 <tr class='alt-color api apilevel-1'> 342 <td class='jd-linkcol'> 343 <a href='rs_value_types.html#android_rs:short4'>short4</a> 344 </td> 345 <td class='jd-descrcol' width='100%'> 346 Four 16 bit signed integers 347 </td> 348 </tr> 349 <tr class='alt-color api apilevel-1'> 350 <td class='jd-linkcol'> 351 <a href='rs_value_types.html#android_rs:size_t'>size_t</a> 352 </td> 353 <td class='jd-descrcol' width='100%'> 354 Unsigned size type 355 </td> 356 </tr> 357 <tr class='alt-color api apilevel-1'> 358 <td class='jd-linkcol'> 359 <a href='rs_value_types.html#android_rs:ssize_t'>ssize_t</a> 360 </td> 361 <td class='jd-descrcol' width='100%'> 362 Signed size type 363 </td> 364 </tr> 365 <tr class='alt-color api apilevel-1'> 366 <td class='jd-linkcol'> 367 <a href='rs_value_types.html#android_rs:uchar'>uchar</a> 368 </td> 369 <td class='jd-descrcol' width='100%'> 370 8 bit unsigned integer 371 </td> 372 </tr> 373 <tr class='alt-color api apilevel-1'> 374 <td class='jd-linkcol'> 375 <a href='rs_value_types.html#android_rs:uchar2'>uchar2</a> 376 </td> 377 <td class='jd-descrcol' width='100%'> 378 Two 8 bit unsigned integers 379 </td> 380 </tr> 381 <tr class='alt-color api apilevel-1'> 382 <td class='jd-linkcol'> 383 <a href='rs_value_types.html#android_rs:uchar3'>uchar3</a> 384 </td> 385 <td class='jd-descrcol' width='100%'> 386 Three 8 bit unsigned integers 387 </td> 388 </tr> 389 <tr class='alt-color api apilevel-1'> 390 <td class='jd-linkcol'> 391 <a href='rs_value_types.html#android_rs:uchar4'>uchar4</a> 392 </td> 393 <td class='jd-descrcol' width='100%'> 394 Four 8 bit unsigned integers 395 </td> 396 </tr> 397 <tr class='alt-color api apilevel-1'> 398 <td class='jd-linkcol'> 399 <a href='rs_value_types.html#android_rs:uint'>uint</a> 400 </td> 401 <td class='jd-descrcol' width='100%'> 402 32 bit unsigned integer 403 </td> 404 </tr> 405 <tr class='alt-color api apilevel-1'> 406 <td class='jd-linkcol'> 407 <a href='rs_value_types.html#android_rs:uint16_t'>uint16_t</a> 408 </td> 409 <td class='jd-descrcol' width='100%'> 410 16 bit unsigned integer 411 </td> 412 </tr> 413 <tr class='alt-color api apilevel-1'> 414 <td class='jd-linkcol'> 415 <a href='rs_value_types.html#android_rs:uint2'>uint2</a> 416 </td> 417 <td class='jd-descrcol' width='100%'> 418 Two 32 bit unsigned integers 419 </td> 420 </tr> 421 <tr class='alt-color api apilevel-1'> 422 <td class='jd-linkcol'> 423 <a href='rs_value_types.html#android_rs:uint3'>uint3</a> 424 </td> 425 <td class='jd-descrcol' width='100%'> 426 Three 32 bit unsigned integers 427 </td> 428 </tr> 429 <tr class='alt-color api apilevel-1'> 430 <td class='jd-linkcol'> 431 <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a> 432 </td> 433 <td class='jd-descrcol' width='100%'> 434 32 bit unsigned integer 435 </td> 436 </tr> 437 <tr class='alt-color api apilevel-1'> 438 <td class='jd-linkcol'> 439 <a href='rs_value_types.html#android_rs:uint4'>uint4</a> 440 </td> 441 <td class='jd-descrcol' width='100%'> 442 Four 32 bit unsigned integers 443 </td> 444 </tr> 445 <tr class='alt-color api apilevel-1'> 446 <td class='jd-linkcol'> 447 <a href='rs_value_types.html#android_rs:uint64_t'>uint64_t</a> 448 </td> 449 <td class='jd-descrcol' width='100%'> 450 64 bit unsigned integer 451 </td> 452 </tr> 453 <tr class='alt-color api apilevel-1'> 454 <td class='jd-linkcol'> 455 <a href='rs_value_types.html#android_rs:uint8_t'>uint8_t</a> 456 </td> 457 <td class='jd-descrcol' width='100%'> 458 8 bit unsigned integer 459 </td> 460 </tr> 461 <tr class='alt-color api apilevel-1'> 462 <td class='jd-linkcol'> 463 <a href='rs_value_types.html#android_rs:ulong'>ulong</a> 464 </td> 465 <td class='jd-descrcol' width='100%'> 466 64 bit unsigned integer 467 </td> 468 </tr> 469 <tr class='alt-color api apilevel-1'> 470 <td class='jd-linkcol'> 471 <a href='rs_value_types.html#android_rs:ulong2'>ulong2</a> 472 </td> 473 <td class='jd-descrcol' width='100%'> 474 Two 64 bit unsigned integers 475 </td> 476 </tr> 477 <tr class='alt-color api apilevel-1'> 478 <td class='jd-linkcol'> 479 <a href='rs_value_types.html#android_rs:ulong3'>ulong3</a> 480 </td> 481 <td class='jd-descrcol' width='100%'> 482 Three 64 bit unsigned integers 483 </td> 484 </tr> 485 <tr class='alt-color api apilevel-1'> 486 <td class='jd-linkcol'> 487 <a href='rs_value_types.html#android_rs:ulong4'>ulong4</a> 488 </td> 489 <td class='jd-descrcol' width='100%'> 490 Four 64 bit unsigned integers 491 </td> 492 </tr> 493 <tr class='alt-color api apilevel-1'> 494 <td class='jd-linkcol'> 495 <a href='rs_value_types.html#android_rs:ushort'>ushort</a> 496 </td> 497 <td class='jd-descrcol' width='100%'> 498 16 bit unsigned integer 499 </td> 500 </tr> 501 <tr class='alt-color api apilevel-1'> 502 <td class='jd-linkcol'> 503 <a href='rs_value_types.html#android_rs:ushort2'>ushort2</a> 504 </td> 505 <td class='jd-descrcol' width='100%'> 506 Two 16 bit unsigned integers 507 </td> 508 </tr> 509 <tr class='alt-color api apilevel-1'> 510 <td class='jd-linkcol'> 511 <a href='rs_value_types.html#android_rs:ushort3'>ushort3</a> 512 </td> 513 <td class='jd-descrcol' width='100%'> 514 Three 16 bit unsigned integers 515 </td> 516 </tr> 517 <tr class='alt-color api apilevel-1'> 518 <td class='jd-linkcol'> 519 <a href='rs_value_types.html#android_rs:ushort4'>ushort4</a> 520 </td> 521 <td class='jd-descrcol' width='100%'> 522 Four 16 bit unsigned integers 523 </td> 524 </tr> 525 </tbody></table> 526 <h2>Object Types</h2> 527 <p> The types below are used to manipulate RenderScript objects like allocations, samplers, 528 elements, and scripts. Most of these object are created using the Java RenderScript APIs. 529 </p> 530 <table class='jd-sumtable'><tbody> 531 <tr><th colspan='2'>Types</th></tr> 532 <tr class='alt-color api apilevel-1'> 533 <td class='jd-linkcol'> 534 <a href='rs_object_types.html#android_rs:rs_allocation'>rs_allocation</a> 535 </td> 536 <td class='jd-descrcol' width='100%'> 537 Handle to an allocation 538 </td> 539 </tr> 540 <tr class='alt-color api apilevel-1'> 541 <td class='jd-linkcol'> 542 <a href='rs_object_types.html#android_rs:rs_allocation_cubemap_face'>rs_allocation_cubemap_face</a> 543 </td> 544 <td class='jd-descrcol' width='100%'> 545 Enum for selecting cube map faces 546 </td> 547 </tr> 548 <tr class='alt-color api apilevel-1'> 549 <td class='jd-linkcol'> 550 <a href='rs_object_types.html#android_rs:rs_allocation_usage_type'>rs_allocation_usage_type</a> 551 </td> 552 <td class='jd-descrcol' width='100%'> 553 Bitfield to specify how an allocation is used 554 </td> 555 </tr> 556 <tr class='alt-color api apilevel-1'> 557 <td class='jd-linkcol'> 558 <a href='rs_object_types.html#android_rs:rs_data_kind'>rs_data_kind</a> 559 </td> 560 <td class='jd-descrcol' width='100%'> 561 Element data kind 562 </td> 563 </tr> 564 <tr class='alt-color api apilevel-1'> 565 <td class='jd-linkcol'> 566 <a href='rs_object_types.html#android_rs:rs_data_type'>rs_data_type</a> 567 </td> 568 <td class='jd-descrcol' width='100%'> 569 Element basic data type 570 </td> 571 </tr> 572 <tr class='alt-color api apilevel-1'> 573 <td class='jd-linkcol'> 574 <a href='rs_object_types.html#android_rs:rs_element'>rs_element</a> 575 </td> 576 <td class='jd-descrcol' width='100%'> 577 Handle to an element 578 </td> 579 </tr> 580 <tr class='alt-color api apilevel-1'> 581 <td class='jd-linkcol'> 582 <a href='rs_object_types.html#android_rs:rs_sampler'>rs_sampler</a> 583 </td> 584 <td class='jd-descrcol' width='100%'> 585 Handle to a Sampler 586 </td> 587 </tr> 588 <tr class='alt-color api apilevel-1'> 589 <td class='jd-linkcol'> 590 <a href='rs_object_types.html#android_rs:rs_sampler_value'>rs_sampler_value</a> 591 </td> 592 <td class='jd-descrcol' width='100%'> 593 Sampler wrap T value 594 </td> 595 </tr> 596 <tr class='alt-color api apilevel-1'> 597 <td class='jd-linkcol'> 598 <a href='rs_object_types.html#android_rs:rs_script'>rs_script</a> 599 </td> 600 <td class='jd-descrcol' width='100%'> 601 Handle to a Script 602 </td> 603 </tr> 604 <tr class='alt-color api apilevel-1'> 605 <td class='jd-linkcol'> 606 <a href='rs_object_types.html#android_rs:rs_type'>rs_type</a> 607 </td> 608 <td class='jd-descrcol' width='100%'> 609 Handle to a Type 610 </td> 611 </tr> 612 </tbody></table> 613 <h2>Conversion Functions</h2> 614 <p> The functions below convert from a numerical vector type to another, or from one color 615 representation to another. 616 </p> 617 <table class='jd-sumtable'><tbody> 618 <tr><th colspan='2'>Functions</th></tr> 619 <tr class='alt-color api apilevel-1'> 620 <td class='jd-linkcol'> 621 <a href='rs_convert.html#android_rs:convert'>convert</a> 622 </td> 623 <td class='jd-descrcol' width='100%'> 624 Convert numerical vectors 625 </td> 626 </tr> 627 <tr class='alt-color api apilevel-1'> 628 <td class='jd-linkcol'> 629 <a href='rs_convert.html#android_rs:rsPackColorTo8888'>rsPackColorTo8888</a> 630 </td> 631 <td class='jd-descrcol' width='100%'> 632 Create a uchar4 RGBA from floats 633 </td> 634 </tr> 635 <tr class='alt-color api apilevel-1'> 636 <td class='jd-linkcol'> 637 <a href='rs_convert.html#android_rs:rsUnpackColor8888'>rsUnpackColor8888</a> 638 </td> 639 <td class='jd-descrcol' width='100%'> 640 Create a float4 RGBA from uchar4 641 </td> 642 </tr> 643 <tr class='alt-color api apilevel-1'> 644 <td class='jd-linkcol'> 645 <a href='rs_convert.html#android_rs:rsYuvToRGBA'>rsYuvToRGBA</a> 646 </td> 647 <td class='jd-descrcol' width='100%'> 648 Convert a YUV value to RGBA 649 </td> 650 </tr> 651 </tbody></table> 652 <h2>Mathematical Constants and Functions</h2> 653 <p> The mathematical functions below can be applied to scalars and vectors. When applied 654 to vectors, the returned value is a vector of the function applied to each entry of the input. 655 </p> 656 657 <p> For example:<code><br/> 658 float3 a, b;<br/> 659 // The following call sets<br/> 660 // a.x to sin(b.x),<br/> 661 // a.y to sin(b.y), and<br/> 662 // a.z to sin(b.z).<br/> 663 a = sin(b);<br/> 664 </code> 665 </p> 666 667 <p> See <a href='rs_vector_math.html'>Vector Math Functions</a> for functions like <a href='rs_vector_math.html#android_rs:distance'>distance</a>() and <a href='rs_vector_math.html#android_rs:length'>length</a>() that interpret 668 instead the input as a single vector in n-dimensional space. 669 </p> 670 671 <p> The precision of the mathematical operations on 32 bit floats is affected by the pragmas 672 rs_fp_relaxed and rs_fp_full. Under rs_fp_relaxed, subnormal values may be flushed to zero and 673 rounding may be done towards zero. In comparison, rs_fp_full requires correct handling of 674 subnormal values, i.e. smaller than 1.17549435e-38f. rs_fp_rull also requires round to nearest 675 with ties to even. 676 </p> 677 678 <p> Different precision/speed tradeoffs can be achieved by using variants of the common math 679 functions. Functions with a name starting with<ul> 680 <li>native_: May have custom hardware implementations with weaker precision. Additionally, 681 subnormal values may be flushed to zero, rounding towards zero may be used, and NaN and 682 infinity input may not be handled correctly.</li> 683 <li>half_: May perform internal computations using 16 bit floats. Additionally, subnormal 684 values may be flushed to zero, and rounding towards zero may be used.</li> 685 </ul> 686 </p> 687 <table class='jd-sumtable'><tbody> 688 <tr><th colspan='2'>Constants</th></tr> 689 <tr class='alt-color api apilevel-1'> 690 <td class='jd-linkcol'> 691 <a href='rs_math.html#android_rs:M_1_PI'>M_1_PI</a> 692 </td> 693 <td class='jd-descrcol' width='100%'> 694 1 / pi, as a 32 bit float 695 </td> 696 </tr> 697 <tr class='alt-color api apilevel-1'> 698 <td class='jd-linkcol'> 699 <a href='rs_math.html#android_rs:M_2_PI'>M_2_PI</a> 700 </td> 701 <td class='jd-descrcol' width='100%'> 702 2 / pi, as a 32 bit float 703 </td> 704 </tr> 705 <tr class='alt-color api apilevel-1'> 706 <td class='jd-linkcol'> 707 <a href='rs_math.html#android_rs:M_2_SQRTPI'>M_2_SQRTPI</a> 708 </td> 709 <td class='jd-descrcol' width='100%'> 710 2 / sqrt(pi), as a 32 bit float 711 </td> 712 </tr> 713 <tr class='alt-color api apilevel-1'> 714 <td class='jd-linkcol'> 715 <a href='rs_math.html#android_rs:M_E'>M_E</a> 716 </td> 717 <td class='jd-descrcol' width='100%'> 718 e, as a 32 bit float 719 </td> 720 </tr> 721 <tr class='alt-color api apilevel-1'> 722 <td class='jd-linkcol'> 723 <a href='rs_math.html#android_rs:M_LN10'>M_LN10</a> 724 </td> 725 <td class='jd-descrcol' width='100%'> 726 log_e(10), as a 32 bit float 727 </td> 728 </tr> 729 <tr class='alt-color api apilevel-1'> 730 <td class='jd-linkcol'> 731 <a href='rs_math.html#android_rs:M_LN2'>M_LN2</a> 732 </td> 733 <td class='jd-descrcol' width='100%'> 734 log_e(2), as a 32 bit float 735 </td> 736 </tr> 737 <tr class='alt-color api apilevel-1'> 738 <td class='jd-linkcol'> 739 <a href='rs_math.html#android_rs:M_LOG10E'>M_LOG10E</a> 740 </td> 741 <td class='jd-descrcol' width='100%'> 742 log_10(e), as a 32 bit float 743 </td> 744 </tr> 745 <tr class='alt-color api apilevel-1'> 746 <td class='jd-linkcol'> 747 <a href='rs_math.html#android_rs:M_LOG2E'>M_LOG2E</a> 748 </td> 749 <td class='jd-descrcol' width='100%'> 750 log_2(e), as a 32 bit float 751 </td> 752 </tr> 753 <tr class='alt-color api apilevel-1'> 754 <td class='jd-linkcol'> 755 <a href='rs_math.html#android_rs:M_PI'>M_PI</a> 756 </td> 757 <td class='jd-descrcol' width='100%'> 758 pi, as a 32 bit float 759 </td> 760 </tr> 761 <tr class='alt-color api apilevel-1'> 762 <td class='jd-linkcol'> 763 <a href='rs_math.html#android_rs:M_PI_2'>M_PI_2</a> 764 </td> 765 <td class='jd-descrcol' width='100%'> 766 pi / 2, as a 32 bit float 767 </td> 768 </tr> 769 <tr class='alt-color api apilevel-1'> 770 <td class='jd-linkcol'> 771 <a href='rs_math.html#android_rs:M_PI_4'>M_PI_4</a> 772 </td> 773 <td class='jd-descrcol' width='100%'> 774 pi / 4, as a 32 bit float 775 </td> 776 </tr> 777 <tr class='alt-color api apilevel-1'> 778 <td class='jd-linkcol'> 779 <a href='rs_math.html#android_rs:M_SQRT1_2'>M_SQRT1_2</a> 780 </td> 781 <td class='jd-descrcol' width='100%'> 782 1 / sqrt(2), as a 32 bit float 783 </td> 784 </tr> 785 <tr class='alt-color api apilevel-1'> 786 <td class='jd-linkcol'> 787 <a href='rs_math.html#android_rs:M_SQRT2'>M_SQRT2</a> 788 </td> 789 <td class='jd-descrcol' width='100%'> 790 sqrt(2), as a 32 bit float 791 </td> 792 </tr> 793 </tbody></table> 794 <table class='jd-sumtable'><tbody> 795 <tr><th colspan='2'>Functions</th></tr> 796 <tr class='alt-color api apilevel-1'> 797 <td class='jd-linkcol'> 798 <a href='rs_math.html#android_rs:abs'>abs</a> 799 </td> 800 <td class='jd-descrcol' width='100%'> 801 Absolute value of an integer 802 </td> 803 </tr> 804 <tr class='alt-color api apilevel-1'> 805 <td class='jd-linkcol'> 806 <a href='rs_math.html#android_rs:acos'>acos</a> 807 </td> 808 <td class='jd-descrcol' width='100%'> 809 Inverse cosine 810 </td> 811 </tr> 812 <tr class='alt-color api apilevel-1'> 813 <td class='jd-linkcol'> 814 <a href='rs_math.html#android_rs:acosh'>acosh</a> 815 </td> 816 <td class='jd-descrcol' width='100%'> 817 Inverse hyperbolic cosine 818 </td> 819 </tr> 820 <tr class='alt-color api apilevel-1'> 821 <td class='jd-linkcol'> 822 <a href='rs_math.html#android_rs:acospi'>acospi</a> 823 </td> 824 <td class='jd-descrcol' width='100%'> 825 Inverse cosine divided by pi 826 </td> 827 </tr> 828 <tr class='alt-color api apilevel-1'> 829 <td class='jd-linkcol'> 830 <a href='rs_math.html#android_rs:asin'>asin</a> 831 </td> 832 <td class='jd-descrcol' width='100%'> 833 Inverse sine 834 </td> 835 </tr> 836 <tr class='alt-color api apilevel-1'> 837 <td class='jd-linkcol'> 838 <a href='rs_math.html#android_rs:asinh'>asinh</a> 839 </td> 840 <td class='jd-descrcol' width='100%'> 841 Inverse hyperbolic sine 842 </td> 843 </tr> 844 <tr class='alt-color api apilevel-1'> 845 <td class='jd-linkcol'> 846 <a href='rs_math.html#android_rs:asinpi'>asinpi</a> 847 </td> 848 <td class='jd-descrcol' width='100%'> 849 Inverse sine divided by pi 850 </td> 851 </tr> 852 <tr class='alt-color api apilevel-1'> 853 <td class='jd-linkcol'> 854 <a href='rs_math.html#android_rs:atan'>atan</a> 855 </td> 856 <td class='jd-descrcol' width='100%'> 857 Inverse tangent 858 </td> 859 </tr> 860 <tr class='alt-color api apilevel-1'> 861 <td class='jd-linkcol'> 862 <a href='rs_math.html#android_rs:atan2'>atan2</a> 863 </td> 864 <td class='jd-descrcol' width='100%'> 865 Inverse tangent of a ratio 866 </td> 867 </tr> 868 <tr class='alt-color api apilevel-1'> 869 <td class='jd-linkcol'> 870 <a href='rs_math.html#android_rs:atan2pi'>atan2pi</a> 871 </td> 872 <td class='jd-descrcol' width='100%'> 873 Inverse tangent of a ratio, divided by pi 874 </td> 875 </tr> 876 <tr class='alt-color api apilevel-1'> 877 <td class='jd-linkcol'> 878 <a href='rs_math.html#android_rs:atanh'>atanh</a> 879 </td> 880 <td class='jd-descrcol' width='100%'> 881 Inverse hyperbolic tangent 882 </td> 883 </tr> 884 <tr class='alt-color api apilevel-1'> 885 <td class='jd-linkcol'> 886 <a href='rs_math.html#android_rs:atanpi'>atanpi</a> 887 </td> 888 <td class='jd-descrcol' width='100%'> 889 Inverse tangent divided by pi 890 </td> 891 </tr> 892 <tr class='alt-color api apilevel-1'> 893 <td class='jd-linkcol'> 894 <a href='rs_math.html#android_rs:cbrt'>cbrt</a> 895 </td> 896 <td class='jd-descrcol' width='100%'> 897 Cube root 898 </td> 899 </tr> 900 <tr class='alt-color api apilevel-1'> 901 <td class='jd-linkcol'> 902 <a href='rs_math.html#android_rs:ceil'>ceil</a> 903 </td> 904 <td class='jd-descrcol' width='100%'> 905 Smallest integer not less than a value 906 </td> 907 </tr> 908 <tr class='alt-color api apilevel-1'> 909 <td class='jd-linkcol'> 910 <a href='rs_math.html#android_rs:clamp'>clamp</a> 911 </td> 912 <td class='jd-descrcol' width='100%'> 913 Restrain a value to a range 914 </td> 915 </tr> 916 <tr class='alt-color api apilevel-1'> 917 <td class='jd-linkcol'> 918 <a href='rs_math.html#android_rs:clz'>clz</a> 919 </td> 920 <td class='jd-descrcol' width='100%'> 921 Number of leading 0 bits 922 </td> 923 </tr> 924 <tr class='alt-color api apilevel-1'> 925 <td class='jd-linkcol'> 926 <a href='rs_math.html#android_rs:copysign'>copysign</a> 927 </td> 928 <td class='jd-descrcol' width='100%'> 929 Copies the sign of a number to another 930 </td> 931 </tr> 932 <tr class='alt-color api apilevel-1'> 933 <td class='jd-linkcol'> 934 <a href='rs_math.html#android_rs:cos'>cos</a> 935 </td> 936 <td class='jd-descrcol' width='100%'> 937 Cosine 938 </td> 939 </tr> 940 <tr class='alt-color api apilevel-1'> 941 <td class='jd-linkcol'> 942 <a href='rs_math.html#android_rs:cosh'>cosh</a> 943 </td> 944 <td class='jd-descrcol' width='100%'> 945 Hypebolic cosine 946 </td> 947 </tr> 948 <tr class='alt-color api apilevel-1'> 949 <td class='jd-linkcol'> 950 <a href='rs_math.html#android_rs:cospi'>cospi</a> 951 </td> 952 <td class='jd-descrcol' width='100%'> 953 Cosine of a number multiplied by pi 954 </td> 955 </tr> 956 <tr class='alt-color api apilevel-1'> 957 <td class='jd-linkcol'> 958 <a href='rs_math.html#android_rs:degrees'>degrees</a> 959 </td> 960 <td class='jd-descrcol' width='100%'> 961 Converts radians into degrees 962 </td> 963 </tr> 964 <tr class='alt-color api apilevel-1'> 965 <td class='jd-linkcol'> 966 <a href='rs_math.html#android_rs:erf'>erf</a> 967 </td> 968 <td class='jd-descrcol' width='100%'> 969 Mathematical error function 970 </td> 971 </tr> 972 <tr class='alt-color api apilevel-1'> 973 <td class='jd-linkcol'> 974 <a href='rs_math.html#android_rs:erfc'>erfc</a> 975 </td> 976 <td class='jd-descrcol' width='100%'> 977 Mathematical complementary error function 978 </td> 979 </tr> 980 <tr class='alt-color api apilevel-1'> 981 <td class='jd-linkcol'> 982 <a href='rs_math.html#android_rs:exp'>exp</a> 983 </td> 984 <td class='jd-descrcol' width='100%'> 985 e raised to a number 986 </td> 987 </tr> 988 <tr class='alt-color api apilevel-1'> 989 <td class='jd-linkcol'> 990 <a href='rs_math.html#android_rs:exp10'>exp10</a> 991 </td> 992 <td class='jd-descrcol' width='100%'> 993 10 raised to a number 994 </td> 995 </tr> 996 <tr class='alt-color api apilevel-1'> 997 <td class='jd-linkcol'> 998 <a href='rs_math.html#android_rs:exp2'>exp2</a> 999 </td> 1000 <td class='jd-descrcol' width='100%'> 1001 2 raised to a number 1002 </td> 1003 </tr> 1004 <tr class='alt-color api apilevel-1'> 1005 <td class='jd-linkcol'> 1006 <a href='rs_math.html#android_rs:expm1'>expm1</a> 1007 </td> 1008 <td class='jd-descrcol' width='100%'> 1009 e raised to a number minus one 1010 </td> 1011 </tr> 1012 <tr class='alt-color api apilevel-1'> 1013 <td class='jd-linkcol'> 1014 <a href='rs_math.html#android_rs:fabs'>fabs</a> 1015 </td> 1016 <td class='jd-descrcol' width='100%'> 1017 Absolute value of a float 1018 </td> 1019 </tr> 1020 <tr class='alt-color api apilevel-1'> 1021 <td class='jd-linkcol'> 1022 <a href='rs_math.html#android_rs:fdim'>fdim</a> 1023 </td> 1024 <td class='jd-descrcol' width='100%'> 1025 Positive difference between two values 1026 </td> 1027 </tr> 1028 <tr class='alt-color api apilevel-1'> 1029 <td class='jd-linkcol'> 1030 <a href='rs_math.html#android_rs:floor'>floor</a> 1031 </td> 1032 <td class='jd-descrcol' width='100%'> 1033 Smallest integer not greater than a value 1034 </td> 1035 </tr> 1036 <tr class='alt-color api apilevel-1'> 1037 <td class='jd-linkcol'> 1038 <a href='rs_math.html#android_rs:fma'>fma</a> 1039 </td> 1040 <td class='jd-descrcol' width='100%'> 1041 Multiply and add 1042 </td> 1043 </tr> 1044 <tr class='alt-color api apilevel-1'> 1045 <td class='jd-linkcol'> 1046 <a href='rs_math.html#android_rs:fmax'>fmax</a> 1047 </td> 1048 <td class='jd-descrcol' width='100%'> 1049 Maximum of two floats 1050 </td> 1051 </tr> 1052 <tr class='alt-color api apilevel-1'> 1053 <td class='jd-linkcol'> 1054 <a href='rs_math.html#android_rs:fmin'>fmin</a> 1055 </td> 1056 <td class='jd-descrcol' width='100%'> 1057 Minimum of two floats 1058 </td> 1059 </tr> 1060 <tr class='alt-color api apilevel-1'> 1061 <td class='jd-linkcol'> 1062 <a href='rs_math.html#android_rs:fmod'>fmod</a> 1063 </td> 1064 <td class='jd-descrcol' width='100%'> 1065 Modulo 1066 </td> 1067 </tr> 1068 <tr class='alt-color api apilevel-1'> 1069 <td class='jd-linkcol'> 1070 <a href='rs_math.html#android_rs:fract'>fract</a> 1071 </td> 1072 <td class='jd-descrcol' width='100%'> 1073 Positive fractional part 1074 </td> 1075 </tr> 1076 <tr class='alt-color api apilevel-1'> 1077 <td class='jd-linkcol'> 1078 <a href='rs_math.html#android_rs:frexp'>frexp</a> 1079 </td> 1080 <td class='jd-descrcol' width='100%'> 1081 Binary mantissa and exponent 1082 </td> 1083 </tr> 1084 <tr class='alt-color api apilevel-1'> 1085 <td class='jd-linkcol'> 1086 <a href='rs_math.html#android_rs:half_recip'>half_recip</a> 1087 </td> 1088 <td class='jd-descrcol' width='100%'> 1089 Reciprocal computed to 16 bit precision 1090 </td> 1091 </tr> 1092 <tr class='alt-color api apilevel-1'> 1093 <td class='jd-linkcol'> 1094 <a href='rs_math.html#android_rs:half_rsqrt'>half_rsqrt</a> 1095 </td> 1096 <td class='jd-descrcol' width='100%'> 1097 Reciprocal of a square root computed to 16 bit precision 1098 </td> 1099 </tr> 1100 <tr class='alt-color api apilevel-1'> 1101 <td class='jd-linkcol'> 1102 <a href='rs_math.html#android_rs:half_sqrt'>half_sqrt</a> 1103 </td> 1104 <td class='jd-descrcol' width='100%'> 1105 Square root computed to 16 bit precision 1106 </td> 1107 </tr> 1108 <tr class='alt-color api apilevel-1'> 1109 <td class='jd-linkcol'> 1110 <a href='rs_math.html#android_rs:hypot'>hypot</a> 1111 </td> 1112 <td class='jd-descrcol' width='100%'> 1113 Hypotenuse 1114 </td> 1115 </tr> 1116 <tr class='alt-color api apilevel-1'> 1117 <td class='jd-linkcol'> 1118 <a href='rs_math.html#android_rs:ilogb'>ilogb</a> 1119 </td> 1120 <td class='jd-descrcol' width='100%'> 1121 Base two exponent 1122 </td> 1123 </tr> 1124 <tr class='alt-color api apilevel-1'> 1125 <td class='jd-linkcol'> 1126 <a href='rs_math.html#android_rs:ldexp'>ldexp</a> 1127 </td> 1128 <td class='jd-descrcol' width='100%'> 1129 Creates a floating point from mantissa and exponent 1130 </td> 1131 </tr> 1132 <tr class='alt-color api apilevel-1'> 1133 <td class='jd-linkcol'> 1134 <a href='rs_math.html#android_rs:lgamma'>lgamma</a> 1135 </td> 1136 <td class='jd-descrcol' width='100%'> 1137 Natural logarithm of the gamma function 1138 </td> 1139 </tr> 1140 <tr class='alt-color api apilevel-1'> 1141 <td class='jd-linkcol'> 1142 <a href='rs_math.html#android_rs:log'>log</a> 1143 </td> 1144 <td class='jd-descrcol' width='100%'> 1145 Natural logarithm 1146 </td> 1147 </tr> 1148 <tr class='alt-color api apilevel-1'> 1149 <td class='jd-linkcol'> 1150 <a href='rs_math.html#android_rs:log10'>log10</a> 1151 </td> 1152 <td class='jd-descrcol' width='100%'> 1153 Base 10 logarithm 1154 </td> 1155 </tr> 1156 <tr class='alt-color api apilevel-1'> 1157 <td class='jd-linkcol'> 1158 <a href='rs_math.html#android_rs:log1p'>log1p</a> 1159 </td> 1160 <td class='jd-descrcol' width='100%'> 1161 Natural logarithm of a value plus 1 1162 </td> 1163 </tr> 1164 <tr class='alt-color api apilevel-1'> 1165 <td class='jd-linkcol'> 1166 <a href='rs_math.html#android_rs:log2'>log2</a> 1167 </td> 1168 <td class='jd-descrcol' width='100%'> 1169 Base 2 logarithm 1170 </td> 1171 </tr> 1172 <tr class='alt-color api apilevel-1'> 1173 <td class='jd-linkcol'> 1174 <a href='rs_math.html#android_rs:logb'>logb</a> 1175 </td> 1176 <td class='jd-descrcol' width='100%'> 1177 Base two exponent 1178 </td> 1179 </tr> 1180 <tr class='alt-color api apilevel-1'> 1181 <td class='jd-linkcol'> 1182 <a href='rs_math.html#android_rs:mad'>mad</a> 1183 </td> 1184 <td class='jd-descrcol' width='100%'> 1185 Multiply and add 1186 </td> 1187 </tr> 1188 <tr class='alt-color api apilevel-1'> 1189 <td class='jd-linkcol'> 1190 <a href='rs_math.html#android_rs:max'>max</a> 1191 </td> 1192 <td class='jd-descrcol' width='100%'> 1193 Maximum 1194 </td> 1195 </tr> 1196 <tr class='alt-color api apilevel-1'> 1197 <td class='jd-linkcol'> 1198 <a href='rs_math.html#android_rs:min'>min</a> 1199 </td> 1200 <td class='jd-descrcol' width='100%'> 1201 Minimum 1202 </td> 1203 </tr> 1204 <tr class='alt-color api apilevel-1'> 1205 <td class='jd-linkcol'> 1206 <a href='rs_math.html#android_rs:mix'>mix</a> 1207 </td> 1208 <td class='jd-descrcol' width='100%'> 1209 Mixes two values 1210 </td> 1211 </tr> 1212 <tr class='alt-color api apilevel-1'> 1213 <td class='jd-linkcol'> 1214 <a href='rs_math.html#android_rs:modf'>modf</a> 1215 </td> 1216 <td class='jd-descrcol' width='100%'> 1217 Integral and fractional components 1218 </td> 1219 </tr> 1220 <tr class='alt-color api apilevel-1'> 1221 <td class='jd-linkcol'> 1222 <a href='rs_math.html#android_rs:nan'>nan</a> 1223 </td> 1224 <td class='jd-descrcol' width='100%'> 1225 Not a Number 1226 </td> 1227 </tr> 1228 <tr class='alt-color api apilevel-1'> 1229 <td class='jd-linkcol'> 1230 <a href='rs_math.html#android_rs:native_acos'>native_acos</a> 1231 </td> 1232 <td class='jd-descrcol' width='100%'> 1233 Approximate inverse cosine 1234 </td> 1235 </tr> 1236 <tr class='alt-color api apilevel-1'> 1237 <td class='jd-linkcol'> 1238 <a href='rs_math.html#android_rs:native_acosh'>native_acosh</a> 1239 </td> 1240 <td class='jd-descrcol' width='100%'> 1241 Approximate inverse hyperbolic cosine 1242 </td> 1243 </tr> 1244 <tr class='alt-color api apilevel-1'> 1245 <td class='jd-linkcol'> 1246 <a href='rs_math.html#android_rs:native_acospi'>native_acospi</a> 1247 </td> 1248 <td class='jd-descrcol' width='100%'> 1249 Approximate inverse cosine divided by pi 1250 </td> 1251 </tr> 1252 <tr class='alt-color api apilevel-1'> 1253 <td class='jd-linkcol'> 1254 <a href='rs_math.html#android_rs:native_asin'>native_asin</a> 1255 </td> 1256 <td class='jd-descrcol' width='100%'> 1257 Approximate inverse sine 1258 </td> 1259 </tr> 1260 <tr class='alt-color api apilevel-1'> 1261 <td class='jd-linkcol'> 1262 <a href='rs_math.html#android_rs:native_asinh'>native_asinh</a> 1263 </td> 1264 <td class='jd-descrcol' width='100%'> 1265 Approximate inverse hyperbolic sine 1266 </td> 1267 </tr> 1268 <tr class='alt-color api apilevel-1'> 1269 <td class='jd-linkcol'> 1270 <a href='rs_math.html#android_rs:native_asinpi'>native_asinpi</a> 1271 </td> 1272 <td class='jd-descrcol' width='100%'> 1273 Approximate inverse sine divided by pi 1274 </td> 1275 </tr> 1276 <tr class='alt-color api apilevel-1'> 1277 <td class='jd-linkcol'> 1278 <a href='rs_math.html#android_rs:native_atan'>native_atan</a> 1279 </td> 1280 <td class='jd-descrcol' width='100%'> 1281 Approximate inverse tangent 1282 </td> 1283 </tr> 1284 <tr class='alt-color api apilevel-1'> 1285 <td class='jd-linkcol'> 1286 <a href='rs_math.html#android_rs:native_atan2'>native_atan2</a> 1287 </td> 1288 <td class='jd-descrcol' width='100%'> 1289 Approximate inverse tangent of a ratio 1290 </td> 1291 </tr> 1292 <tr class='alt-color api apilevel-1'> 1293 <td class='jd-linkcol'> 1294 <a href='rs_math.html#android_rs:native_atan2pi'>native_atan2pi</a> 1295 </td> 1296 <td class='jd-descrcol' width='100%'> 1297 Approximate inverse tangent of a ratio, divided by pi 1298 </td> 1299 </tr> 1300 <tr class='alt-color api apilevel-1'> 1301 <td class='jd-linkcol'> 1302 <a href='rs_math.html#android_rs:native_atanh'>native_atanh</a> 1303 </td> 1304 <td class='jd-descrcol' width='100%'> 1305 Approximate inverse hyperbolic tangent 1306 </td> 1307 </tr> 1308 <tr class='alt-color api apilevel-1'> 1309 <td class='jd-linkcol'> 1310 <a href='rs_math.html#android_rs:native_atanpi'>native_atanpi</a> 1311 </td> 1312 <td class='jd-descrcol' width='100%'> 1313 Approximate inverse tangent divided by pi 1314 </td> 1315 </tr> 1316 <tr class='alt-color api apilevel-1'> 1317 <td class='jd-linkcol'> 1318 <a href='rs_math.html#android_rs:native_cbrt'>native_cbrt</a> 1319 </td> 1320 <td class='jd-descrcol' width='100%'> 1321 Approximate cube root 1322 </td> 1323 </tr> 1324 <tr class='alt-color api apilevel-1'> 1325 <td class='jd-linkcol'> 1326 <a href='rs_math.html#android_rs:native_cos'>native_cos</a> 1327 </td> 1328 <td class='jd-descrcol' width='100%'> 1329 Approximate cosine 1330 </td> 1331 </tr> 1332 <tr class='alt-color api apilevel-1'> 1333 <td class='jd-linkcol'> 1334 <a href='rs_math.html#android_rs:native_cosh'>native_cosh</a> 1335 </td> 1336 <td class='jd-descrcol' width='100%'> 1337 Approximate hypebolic cosine 1338 </td> 1339 </tr> 1340 <tr class='alt-color api apilevel-1'> 1341 <td class='jd-linkcol'> 1342 <a href='rs_math.html#android_rs:native_cospi'>native_cospi</a> 1343 </td> 1344 <td class='jd-descrcol' width='100%'> 1345 Approximate cosine of a number multiplied by pi 1346 </td> 1347 </tr> 1348 <tr class='alt-color api apilevel-1'> 1349 <td class='jd-linkcol'> 1350 <a href='rs_math.html#android_rs:native_divide'>native_divide</a> 1351 </td> 1352 <td class='jd-descrcol' width='100%'> 1353 Approximate division 1354 </td> 1355 </tr> 1356 <tr class='alt-color api apilevel-1'> 1357 <td class='jd-linkcol'> 1358 <a href='rs_math.html#android_rs:native_exp'>native_exp</a> 1359 </td> 1360 <td class='jd-descrcol' width='100%'> 1361 Approximate e raised to a number 1362 </td> 1363 </tr> 1364 <tr class='alt-color api apilevel-1'> 1365 <td class='jd-linkcol'> 1366 <a href='rs_math.html#android_rs:native_exp10'>native_exp10</a> 1367 </td> 1368 <td class='jd-descrcol' width='100%'> 1369 Approximate 10 raised to a number 1370 </td> 1371 </tr> 1372 <tr class='alt-color api apilevel-1'> 1373 <td class='jd-linkcol'> 1374 <a href='rs_math.html#android_rs:native_exp2'>native_exp2</a> 1375 </td> 1376 <td class='jd-descrcol' width='100%'> 1377 Approximate 2 raised to a number 1378 </td> 1379 </tr> 1380 <tr class='alt-color api apilevel-1'> 1381 <td class='jd-linkcol'> 1382 <a href='rs_math.html#android_rs:native_expm1'>native_expm1</a> 1383 </td> 1384 <td class='jd-descrcol' width='100%'> 1385 Approximate e raised to a number minus one 1386 </td> 1387 </tr> 1388 <tr class='alt-color api apilevel-1'> 1389 <td class='jd-linkcol'> 1390 <a href='rs_math.html#android_rs:native_hypot'>native_hypot</a> 1391 </td> 1392 <td class='jd-descrcol' width='100%'> 1393 Approximate hypotenuse 1394 </td> 1395 </tr> 1396 <tr class='alt-color api apilevel-1'> 1397 <td class='jd-linkcol'> 1398 <a href='rs_math.html#android_rs:native_log'>native_log</a> 1399 </td> 1400 <td class='jd-descrcol' width='100%'> 1401 Approximate natural logarithm 1402 </td> 1403 </tr> 1404 <tr class='alt-color api apilevel-1'> 1405 <td class='jd-linkcol'> 1406 <a href='rs_math.html#android_rs:native_log10'>native_log10</a> 1407 </td> 1408 <td class='jd-descrcol' width='100%'> 1409 Approximate base 10 logarithm 1410 </td> 1411 </tr> 1412 <tr class='alt-color api apilevel-1'> 1413 <td class='jd-linkcol'> 1414 <a href='rs_math.html#android_rs:native_log1p'>native_log1p</a> 1415 </td> 1416 <td class='jd-descrcol' width='100%'> 1417 Approximate natural logarithm of a value plus 1 1418 </td> 1419 </tr> 1420 <tr class='alt-color api apilevel-1'> 1421 <td class='jd-linkcol'> 1422 <a href='rs_math.html#android_rs:native_log2'>native_log2</a> 1423 </td> 1424 <td class='jd-descrcol' width='100%'> 1425 Approximate base 2 logarithm 1426 </td> 1427 </tr> 1428 <tr class='alt-color api apilevel-1'> 1429 <td class='jd-linkcol'> 1430 <a href='rs_math.html#android_rs:native_powr'>native_powr</a> 1431 </td> 1432 <td class='jd-descrcol' width='100%'> 1433 Approximate positive base raised to an exponent 1434 </td> 1435 </tr> 1436 <tr class='alt-color api apilevel-1'> 1437 <td class='jd-linkcol'> 1438 <a href='rs_math.html#android_rs:native_recip'>native_recip</a> 1439 </td> 1440 <td class='jd-descrcol' width='100%'> 1441 Approximate reciprocal 1442 </td> 1443 </tr> 1444 <tr class='alt-color api apilevel-1'> 1445 <td class='jd-linkcol'> 1446 <a href='rs_math.html#android_rs:native_rootn'>native_rootn</a> 1447 </td> 1448 <td class='jd-descrcol' width='100%'> 1449 Approximate nth root 1450 </td> 1451 </tr> 1452 <tr class='alt-color api apilevel-1'> 1453 <td class='jd-linkcol'> 1454 <a href='rs_math.html#android_rs:native_rsqrt'>native_rsqrt</a> 1455 </td> 1456 <td class='jd-descrcol' width='100%'> 1457 Approximate reciprocal of a square root 1458 </td> 1459 </tr> 1460 <tr class='alt-color api apilevel-1'> 1461 <td class='jd-linkcol'> 1462 <a href='rs_math.html#android_rs:native_sin'>native_sin</a> 1463 </td> 1464 <td class='jd-descrcol' width='100%'> 1465 Approximate sine 1466 </td> 1467 </tr> 1468 <tr class='alt-color api apilevel-1'> 1469 <td class='jd-linkcol'> 1470 <a href='rs_math.html#android_rs:native_sincos'>native_sincos</a> 1471 </td> 1472 <td class='jd-descrcol' width='100%'> 1473 Approximate sine and cosine 1474 </td> 1475 </tr> 1476 <tr class='alt-color api apilevel-1'> 1477 <td class='jd-linkcol'> 1478 <a href='rs_math.html#android_rs:native_sinh'>native_sinh</a> 1479 </td> 1480 <td class='jd-descrcol' width='100%'> 1481 Approximate hyperbolic sine 1482 </td> 1483 </tr> 1484 <tr class='alt-color api apilevel-1'> 1485 <td class='jd-linkcol'> 1486 <a href='rs_math.html#android_rs:native_sinpi'>native_sinpi</a> 1487 </td> 1488 <td class='jd-descrcol' width='100%'> 1489 Approximate sine of a number multiplied by pi 1490 </td> 1491 </tr> 1492 <tr class='alt-color api apilevel-1'> 1493 <td class='jd-linkcol'> 1494 <a href='rs_math.html#android_rs:native_sqrt'>native_sqrt</a> 1495 </td> 1496 <td class='jd-descrcol' width='100%'> 1497 Approximate square root 1498 </td> 1499 </tr> 1500 <tr class='alt-color api apilevel-1'> 1501 <td class='jd-linkcol'> 1502 <a href='rs_math.html#android_rs:native_tan'>native_tan</a> 1503 </td> 1504 <td class='jd-descrcol' width='100%'> 1505 Approximate tangent 1506 </td> 1507 </tr> 1508 <tr class='alt-color api apilevel-1'> 1509 <td class='jd-linkcol'> 1510 <a href='rs_math.html#android_rs:native_tanh'>native_tanh</a> 1511 </td> 1512 <td class='jd-descrcol' width='100%'> 1513 Approximate hyperbolic tangent 1514 </td> 1515 </tr> 1516 <tr class='alt-color api apilevel-1'> 1517 <td class='jd-linkcol'> 1518 <a href='rs_math.html#android_rs:native_tanpi'>native_tanpi</a> 1519 </td> 1520 <td class='jd-descrcol' width='100%'> 1521 Approximate tangent of a number multiplied by pi 1522 </td> 1523 </tr> 1524 <tr class='alt-color api apilevel-1'> 1525 <td class='jd-linkcol'> 1526 <a href='rs_math.html#android_rs:nextafter'>nextafter</a> 1527 </td> 1528 <td class='jd-descrcol' width='100%'> 1529 Next floating point number 1530 </td> 1531 </tr> 1532 <tr class='alt-color api apilevel-1'> 1533 <td class='jd-linkcol'> 1534 <a href='rs_math.html#android_rs:pow'>pow</a> 1535 </td> 1536 <td class='jd-descrcol' width='100%'> 1537 Base raised to an exponent 1538 </td> 1539 </tr> 1540 <tr class='alt-color api apilevel-1'> 1541 <td class='jd-linkcol'> 1542 <a href='rs_math.html#android_rs:pown'>pown</a> 1543 </td> 1544 <td class='jd-descrcol' width='100%'> 1545 Base raised to an integer exponent 1546 </td> 1547 </tr> 1548 <tr class='alt-color api apilevel-1'> 1549 <td class='jd-linkcol'> 1550 <a href='rs_math.html#android_rs:powr'>powr</a> 1551 </td> 1552 <td class='jd-descrcol' width='100%'> 1553 Positive base raised to an exponent 1554 </td> 1555 </tr> 1556 <tr class='alt-color api apilevel-1'> 1557 <td class='jd-linkcol'> 1558 <a href='rs_math.html#android_rs:radians'>radians</a> 1559 </td> 1560 <td class='jd-descrcol' width='100%'> 1561 Converts degrees into radians 1562 </td> 1563 </tr> 1564 <tr class='alt-color api apilevel-1'> 1565 <td class='jd-linkcol'> 1566 <a href='rs_math.html#android_rs:remainder'>remainder</a> 1567 </td> 1568 <td class='jd-descrcol' width='100%'> 1569 Remainder of a division 1570 </td> 1571 </tr> 1572 <tr class='alt-color api apilevel-1'> 1573 <td class='jd-linkcol'> 1574 <a href='rs_math.html#android_rs:remquo'>remquo</a> 1575 </td> 1576 <td class='jd-descrcol' width='100%'> 1577 Remainder and quotient of a division 1578 </td> 1579 </tr> 1580 <tr class='alt-color api apilevel-1'> 1581 <td class='jd-linkcol'> 1582 <a href='rs_math.html#android_rs:rint'>rint</a> 1583 </td> 1584 <td class='jd-descrcol' width='100%'> 1585 Round to even 1586 </td> 1587 </tr> 1588 <tr class='alt-color api apilevel-1'> 1589 <td class='jd-linkcol'> 1590 <a href='rs_math.html#android_rs:rootn'>rootn</a> 1591 </td> 1592 <td class='jd-descrcol' width='100%'> 1593 Nth root 1594 </td> 1595 </tr> 1596 <tr class='alt-color api apilevel-1'> 1597 <td class='jd-linkcol'> 1598 <a href='rs_math.html#android_rs:round'>round</a> 1599 </td> 1600 <td class='jd-descrcol' width='100%'> 1601 Round away from zero 1602 </td> 1603 </tr> 1604 <tr class='alt-color api apilevel-1'> 1605 <td class='jd-linkcol'> 1606 <a href='rs_math.html#android_rs:rsRand'>rsRand</a> 1607 </td> 1608 <td class='jd-descrcol' width='100%'> 1609 Pseudo-random number 1610 </td> 1611 </tr> 1612 <tr class='alt-color api apilevel-1'> 1613 <td class='jd-linkcol'> 1614 <a href='rs_math.html#android_rs:rsqrt'>rsqrt</a> 1615 </td> 1616 <td class='jd-descrcol' width='100%'> 1617 Reciprocal of a square root 1618 </td> 1619 </tr> 1620 <tr class='alt-color api apilevel-1'> 1621 <td class='jd-linkcol'> 1622 <a href='rs_math.html#android_rs:sign'>sign</a> 1623 </td> 1624 <td class='jd-descrcol' width='100%'> 1625 Sign of a value 1626 </td> 1627 </tr> 1628 <tr class='alt-color api apilevel-1'> 1629 <td class='jd-linkcol'> 1630 <a href='rs_math.html#android_rs:sin'>sin</a> 1631 </td> 1632 <td class='jd-descrcol' width='100%'> 1633 Sine 1634 </td> 1635 </tr> 1636 <tr class='alt-color api apilevel-1'> 1637 <td class='jd-linkcol'> 1638 <a href='rs_math.html#android_rs:sincos'>sincos</a> 1639 </td> 1640 <td class='jd-descrcol' width='100%'> 1641 Sine and cosine 1642 </td> 1643 </tr> 1644 <tr class='alt-color api apilevel-1'> 1645 <td class='jd-linkcol'> 1646 <a href='rs_math.html#android_rs:sinh'>sinh</a> 1647 </td> 1648 <td class='jd-descrcol' width='100%'> 1649 Hyperbolic sine 1650 </td> 1651 </tr> 1652 <tr class='alt-color api apilevel-1'> 1653 <td class='jd-linkcol'> 1654 <a href='rs_math.html#android_rs:sinpi'>sinpi</a> 1655 </td> 1656 <td class='jd-descrcol' width='100%'> 1657 Sine of a number multiplied by pi 1658 </td> 1659 </tr> 1660 <tr class='alt-color api apilevel-1'> 1661 <td class='jd-linkcol'> 1662 <a href='rs_math.html#android_rs:sqrt'>sqrt</a> 1663 </td> 1664 <td class='jd-descrcol' width='100%'> 1665 Square root 1666 </td> 1667 </tr> 1668 <tr class='alt-color api apilevel-1'> 1669 <td class='jd-linkcol'> 1670 <a href='rs_math.html#android_rs:step'>step</a> 1671 </td> 1672 <td class='jd-descrcol' width='100%'> 1673 0 if less than a value, 0 otherwise 1674 </td> 1675 </tr> 1676 <tr class='alt-color api apilevel-1'> 1677 <td class='jd-linkcol'> 1678 <a href='rs_math.html#android_rs:tan'>tan</a> 1679 </td> 1680 <td class='jd-descrcol' width='100%'> 1681 Tangent 1682 </td> 1683 </tr> 1684 <tr class='alt-color api apilevel-1'> 1685 <td class='jd-linkcol'> 1686 <a href='rs_math.html#android_rs:tanh'>tanh</a> 1687 </td> 1688 <td class='jd-descrcol' width='100%'> 1689 Hyperbolic tangent 1690 </td> 1691 </tr> 1692 <tr class='alt-color api apilevel-1'> 1693 <td class='jd-linkcol'> 1694 <a href='rs_math.html#android_rs:tanpi'>tanpi</a> 1695 </td> 1696 <td class='jd-descrcol' width='100%'> 1697 Tangent of a number multiplied by pi 1698 </td> 1699 </tr> 1700 <tr class='alt-color api apilevel-1'> 1701 <td class='jd-linkcol'> 1702 <a href='rs_math.html#android_rs:tgamma'>tgamma</a> 1703 </td> 1704 <td class='jd-descrcol' width='100%'> 1705 Gamma function 1706 </td> 1707 </tr> 1708 <tr class='alt-color api apilevel-1'> 1709 <td class='jd-linkcol'> 1710 <a href='rs_math.html#android_rs:trunc'>trunc</a> 1711 </td> 1712 <td class='jd-descrcol' width='100%'> 1713 Truncates a floating point 1714 </td> 1715 </tr> 1716 </tbody></table> 1717 <h2>Vector Math Functions</h2> 1718 <p> These functions interpret the input arguments as representation of vectors in 1719 n-dimensional space. 1720 </p> 1721 1722 <p> The precision of the mathematical operations on 32 bit floats is affected by the pragmas 1723 rs_fp_relaxed and rs_fp_full. See <a href='rs_math.html'>Mathematical Constants and Functions</a> for details. 1724 </p> 1725 1726 <p> Different precision/speed tradeoffs can be achieved by using variants of the common math 1727 functions. Functions with a name starting with<ul> 1728 <li>native_: May have custom hardware implementations with weaker precision. Additionally, 1729 subnormal values may be flushed to zero, rounding towards zero may be used, and NaN and 1730 infinity input may not be handled correctly.</li> 1731 <li>fast_: May perform internal computations using 16 bit floats. Additionally, subnormal 1732 values may be flushed to zero, and rounding towards zero may be used.</li> 1733 </ul> 1734 </p> 1735 <table class='jd-sumtable'><tbody> 1736 <tr><th colspan='2'>Functions</th></tr> 1737 <tr class='alt-color api apilevel-1'> 1738 <td class='jd-linkcol'> 1739 <a href='rs_vector_math.html#android_rs:cross'>cross</a> 1740 </td> 1741 <td class='jd-descrcol' width='100%'> 1742 Cross product of two vectors 1743 </td> 1744 </tr> 1745 <tr class='alt-color api apilevel-1'> 1746 <td class='jd-linkcol'> 1747 <a href='rs_vector_math.html#android_rs:distance'>distance</a> 1748 </td> 1749 <td class='jd-descrcol' width='100%'> 1750 Distance between two points 1751 </td> 1752 </tr> 1753 <tr class='alt-color api apilevel-1'> 1754 <td class='jd-linkcol'> 1755 <a href='rs_vector_math.html#android_rs:dot'>dot</a> 1756 </td> 1757 <td class='jd-descrcol' width='100%'> 1758 Dot product of two vectors 1759 </td> 1760 </tr> 1761 <tr class='alt-color api apilevel-1'> 1762 <td class='jd-linkcol'> 1763 <a href='rs_vector_math.html#android_rs:fast_distance'>fast_distance</a> 1764 </td> 1765 <td class='jd-descrcol' width='100%'> 1766 Approximate distance between two points 1767 </td> 1768 </tr> 1769 <tr class='alt-color api apilevel-1'> 1770 <td class='jd-linkcol'> 1771 <a href='rs_vector_math.html#android_rs:fast_length'>fast_length</a> 1772 </td> 1773 <td class='jd-descrcol' width='100%'> 1774 Approximate length of a vector 1775 </td> 1776 </tr> 1777 <tr class='alt-color api apilevel-1'> 1778 <td class='jd-linkcol'> 1779 <a href='rs_vector_math.html#android_rs:fast_normalize'>fast_normalize</a> 1780 </td> 1781 <td class='jd-descrcol' width='100%'> 1782 Approximate normalized vector 1783 </td> 1784 </tr> 1785 <tr class='alt-color api apilevel-1'> 1786 <td class='jd-linkcol'> 1787 <a href='rs_vector_math.html#android_rs:length'>length</a> 1788 </td> 1789 <td class='jd-descrcol' width='100%'> 1790 Length of a vector 1791 </td> 1792 </tr> 1793 <tr class='alt-color api apilevel-1'> 1794 <td class='jd-linkcol'> 1795 <a href='rs_vector_math.html#android_rs:native_distance'>native_distance</a> 1796 </td> 1797 <td class='jd-descrcol' width='100%'> 1798 Approximate distance between two points 1799 </td> 1800 </tr> 1801 <tr class='alt-color api apilevel-1'> 1802 <td class='jd-linkcol'> 1803 <a href='rs_vector_math.html#android_rs:native_length'>native_length</a> 1804 </td> 1805 <td class='jd-descrcol' width='100%'> 1806 Approximate length of a vector 1807 </td> 1808 </tr> 1809 <tr class='alt-color api apilevel-1'> 1810 <td class='jd-linkcol'> 1811 <a href='rs_vector_math.html#android_rs:native_normalize'>native_normalize</a> 1812 </td> 1813 <td class='jd-descrcol' width='100%'> 1814 Approximately normalize a vector 1815 </td> 1816 </tr> 1817 <tr class='alt-color api apilevel-1'> 1818 <td class='jd-linkcol'> 1819 <a href='rs_vector_math.html#android_rs:normalize'>normalize</a> 1820 </td> 1821 <td class='jd-descrcol' width='100%'> 1822 Normalize a vector 1823 </td> 1824 </tr> 1825 </tbody></table> 1826 <h2>Matrix Functions</h2> 1827 <p> These functions let you manipulate square matrices of rank 2x2, 3x3, and 4x4. 1828 They are particularly useful for graphical transformations and are compatible 1829 with OpenGL. 1830 </p> 1831 1832 <p> We use a zero-based index for rows and columns. E.g. the last element of a 1833 <a href='rs_value_types.html#android_rs:rs_matrix4x4'>rs_matrix4x4</a> is found at (3, 3). 1834 </p> 1835 1836 <p> RenderScript uses column-major matrices and column-based vectors. Transforming 1837 a vector is done by postmultiplying the vector, e.g. <code>(matrix * vector)</code>, 1838 as provided by <a href='rs_matrix.html#android_rs:rsMatrixMultiply'>rsMatrixMultiply</a>(). 1839 </p> 1840 1841 <p> To create a transformation matrix that performs two transformations at once, 1842 multiply the two source matrices, with the first transformation as the right 1843 argument. E.g. to create a transformation matrix that applies the 1844 transformation s1 followed by s2, call <code>rsMatrixLoadMultiply(&combined, &s2, &s1)</code>. 1845 This derives from <code>s2 * (s1 * v)</code>, which is <code>(s2 * s1) * v</code>. 1846 </p> 1847 1848 <p> We have two style of functions to create transformation matrices: 1849 rsMatrixLoad<i>Transformation</i> and rsMatrix<i>Transformation</i>. The former 1850 style simply stores the transformation matrix in the first argument. The latter 1851 modifies a pre-existing transformation matrix so that the new transformation 1852 happens first. E.g. if you call <a href='rs_matrix.html#android_rs:rsMatrixTranslate'>rsMatrixTranslate</a>() on a matrix that already 1853 does a scaling, the resulting matrix when applied to a vector will first do the 1854 translation then the scaling. 1855 </p> 1856 <table class='jd-sumtable'><tbody> 1857 <tr><th colspan='2'>Functions</th></tr> 1858 <tr class='alt-color api apilevel-1'> 1859 <td class='jd-linkcol'> 1860 <a href='rs_matrix.html#android_rs:rsExtractFrustumPlanes'>rsExtractFrustumPlanes</a> 1861 </td> 1862 <td class='jd-descrcol' width='100%'> 1863 Compute frustum planes 1864 </td> 1865 </tr> 1866 <tr class='alt-color api apilevel-1'> 1867 <td class='jd-linkcol'> 1868 <a href='rs_matrix.html#android_rs:rsIsSphereInFrustum'>rsIsSphereInFrustum</a> 1869 </td> 1870 <td class='jd-descrcol' width='100%'> 1871 Checks if a sphere is within the frustum planes 1872 </td> 1873 </tr> 1874 <tr class='alt-color api apilevel-1'> 1875 <td class='jd-linkcol'> 1876 <a href='rs_matrix.html#android_rs:rsMatrixGet'>rsMatrixGet</a> 1877 </td> 1878 <td class='jd-descrcol' width='100%'> 1879 Get one element 1880 </td> 1881 </tr> 1882 <tr class='alt-color api apilevel-1'> 1883 <td class='jd-linkcol'> 1884 <a href='rs_matrix.html#android_rs:rsMatrixInverse'>rsMatrixInverse</a> 1885 </td> 1886 <td class='jd-descrcol' width='100%'> 1887 Inverts a matrix in place 1888 </td> 1889 </tr> 1890 <tr class='alt-color api apilevel-1'> 1891 <td class='jd-linkcol'> 1892 <a href='rs_matrix.html#android_rs:rsMatrixInverseTranspose'>rsMatrixInverseTranspose</a> 1893 </td> 1894 <td class='jd-descrcol' width='100%'> 1895 Inverts and transpose a matrix in place 1896 </td> 1897 </tr> 1898 <tr class='alt-color api apilevel-1'> 1899 <td class='jd-linkcol'> 1900 <a href='rs_matrix.html#android_rs:rsMatrixLoad'>rsMatrixLoad</a> 1901 </td> 1902 <td class='jd-descrcol' width='100%'> 1903 Load or copy a matrix 1904 </td> 1905 </tr> 1906 <tr class='alt-color api apilevel-1'> 1907 <td class='jd-linkcol'> 1908 <a href='rs_matrix.html#android_rs:rsMatrixLoadFrustum'>rsMatrixLoadFrustum</a> 1909 </td> 1910 <td class='jd-descrcol' width='100%'> 1911 Load a frustum projection matrix 1912 </td> 1913 </tr> 1914 <tr class='alt-color api apilevel-1'> 1915 <td class='jd-linkcol'> 1916 <a href='rs_matrix.html#android_rs:rsMatrixLoadIdentity'>rsMatrixLoadIdentity</a> 1917 </td> 1918 <td class='jd-descrcol' width='100%'> 1919 Load identity matrix 1920 </td> 1921 </tr> 1922 <tr class='alt-color api apilevel-1'> 1923 <td class='jd-linkcol'> 1924 <a href='rs_matrix.html#android_rs:rsMatrixLoadMultiply'>rsMatrixLoadMultiply</a> 1925 </td> 1926 <td class='jd-descrcol' width='100%'> 1927 Multiply two matrices 1928 </td> 1929 </tr> 1930 <tr class='alt-color api apilevel-1'> 1931 <td class='jd-linkcol'> 1932 <a href='rs_matrix.html#android_rs:rsMatrixLoadOrtho'>rsMatrixLoadOrtho</a> 1933 </td> 1934 <td class='jd-descrcol' width='100%'> 1935 Load an orthographic projection matrix 1936 </td> 1937 </tr> 1938 <tr class='alt-color api apilevel-1'> 1939 <td class='jd-linkcol'> 1940 <a href='rs_matrix.html#android_rs:rsMatrixLoadPerspective'>rsMatrixLoadPerspective</a> 1941 </td> 1942 <td class='jd-descrcol' width='100%'> 1943 Load a perspective projection matrix 1944 </td> 1945 </tr> 1946 <tr class='alt-color api apilevel-1'> 1947 <td class='jd-linkcol'> 1948 <a href='rs_matrix.html#android_rs:rsMatrixLoadRotate'>rsMatrixLoadRotate</a> 1949 </td> 1950 <td class='jd-descrcol' width='100%'> 1951 Load a rotation matrix 1952 </td> 1953 </tr> 1954 <tr class='alt-color api apilevel-1'> 1955 <td class='jd-linkcol'> 1956 <a href='rs_matrix.html#android_rs:rsMatrixLoadScale'>rsMatrixLoadScale</a> 1957 </td> 1958 <td class='jd-descrcol' width='100%'> 1959 Load a scaling matrix 1960 </td> 1961 </tr> 1962 <tr class='alt-color api apilevel-1'> 1963 <td class='jd-linkcol'> 1964 <a href='rs_matrix.html#android_rs:rsMatrixLoadTranslate'>rsMatrixLoadTranslate</a> 1965 </td> 1966 <td class='jd-descrcol' width='100%'> 1967 Load a translation matrix 1968 </td> 1969 </tr> 1970 <tr class='alt-color api apilevel-1'> 1971 <td class='jd-linkcol'> 1972 <a href='rs_matrix.html#android_rs:rsMatrixMultiply'>rsMatrixMultiply</a> 1973 </td> 1974 <td class='jd-descrcol' width='100%'> 1975 Multiply a matrix by a vector or another matrix 1976 </td> 1977 </tr> 1978 <tr class='alt-color api apilevel-1'> 1979 <td class='jd-linkcol'> 1980 <a href='rs_matrix.html#android_rs:rsMatrixRotate'>rsMatrixRotate</a> 1981 </td> 1982 <td class='jd-descrcol' width='100%'> 1983 Apply a rotation to a transformation matrix 1984 </td> 1985 </tr> 1986 <tr class='alt-color api apilevel-1'> 1987 <td class='jd-linkcol'> 1988 <a href='rs_matrix.html#android_rs:rsMatrixScale'>rsMatrixScale</a> 1989 </td> 1990 <td class='jd-descrcol' width='100%'> 1991 Apply a scaling to a transformation matrix 1992 </td> 1993 </tr> 1994 <tr class='alt-color api apilevel-1'> 1995 <td class='jd-linkcol'> 1996 <a href='rs_matrix.html#android_rs:rsMatrixSet'>rsMatrixSet</a> 1997 </td> 1998 <td class='jd-descrcol' width='100%'> 1999 Set one element 2000 </td> 2001 </tr> 2002 <tr class='alt-color api apilevel-1'> 2003 <td class='jd-linkcol'> 2004 <a href='rs_matrix.html#android_rs:rsMatrixTranslate'>rsMatrixTranslate</a> 2005 </td> 2006 <td class='jd-descrcol' width='100%'> 2007 Apply a translation to a transformation matrix 2008 </td> 2009 </tr> 2010 <tr class='alt-color api apilevel-1'> 2011 <td class='jd-linkcol'> 2012 <a href='rs_matrix.html#android_rs:rsMatrixTranspose'>rsMatrixTranspose</a> 2013 </td> 2014 <td class='jd-descrcol' width='100%'> 2015 Transpose a matrix place 2016 </td> 2017 </tr> 2018 </tbody></table> 2019 <h2>Quaternion Functions</h2> 2020 <p> The following functions manipulate quaternions. 2021 </p> 2022 <table class='jd-sumtable'><tbody> 2023 <tr><th colspan='2'>Functions</th></tr> 2024 <tr class='alt-color api apilevel-1'> 2025 <td class='jd-linkcol'> 2026 <a href='rs_quaternion.html#android_rs:rsQuaternionAdd'>rsQuaternionAdd</a> 2027 </td> 2028 <td class='jd-descrcol' width='100%'> 2029 Add two quaternions 2030 </td> 2031 </tr> 2032 <tr class='alt-color api apilevel-1'> 2033 <td class='jd-linkcol'> 2034 <a href='rs_quaternion.html#android_rs:rsQuaternionConjugate'>rsQuaternionConjugate</a> 2035 </td> 2036 <td class='jd-descrcol' width='100%'> 2037 Conjugate a quaternion 2038 </td> 2039 </tr> 2040 <tr class='alt-color api apilevel-1'> 2041 <td class='jd-linkcol'> 2042 <a href='rs_quaternion.html#android_rs:rsQuaternionDot'>rsQuaternionDot</a> 2043 </td> 2044 <td class='jd-descrcol' width='100%'> 2045 Dot product of two quaternions 2046 </td> 2047 </tr> 2048 <tr class='alt-color api apilevel-1'> 2049 <td class='jd-linkcol'> 2050 <a href='rs_quaternion.html#android_rs:rsQuaternionGetMatrixUnit'>rsQuaternionGetMatrixUnit</a> 2051 </td> 2052 <td class='jd-descrcol' width='100%'> 2053 Get a rotation matrix from a quaternion 2054 </td> 2055 </tr> 2056 <tr class='alt-color api apilevel-1'> 2057 <td class='jd-linkcol'> 2058 <a href='rs_quaternion.html#android_rs:rsQuaternionLoadRotate'>rsQuaternionLoadRotate</a> 2059 </td> 2060 <td class='jd-descrcol' width='100%'> 2061 Create a rotation quaternion 2062 </td> 2063 </tr> 2064 <tr class='alt-color api apilevel-1'> 2065 <td class='jd-linkcol'> 2066 <a href='rs_quaternion.html#android_rs:rsQuaternionLoadRotateUnit'>rsQuaternionLoadRotateUnit</a> 2067 </td> 2068 <td class='jd-descrcol' width='100%'> 2069 Quaternion that represents a rotation about an arbitrary unit vector 2070 </td> 2071 </tr> 2072 <tr class='alt-color api apilevel-1'> 2073 <td class='jd-linkcol'> 2074 <a href='rs_quaternion.html#android_rs:rsQuaternionMultiply'>rsQuaternionMultiply</a> 2075 </td> 2076 <td class='jd-descrcol' width='100%'> 2077 Multiply a quaternion by a scalar or another quaternion 2078 </td> 2079 </tr> 2080 <tr class='alt-color api apilevel-1'> 2081 <td class='jd-linkcol'> 2082 <a href='rs_quaternion.html#android_rs:rsQuaternionNormalize'>rsQuaternionNormalize</a> 2083 </td> 2084 <td class='jd-descrcol' width='100%'> 2085 Normalize a quaternion 2086 </td> 2087 </tr> 2088 <tr class='alt-color api apilevel-1'> 2089 <td class='jd-linkcol'> 2090 <a href='rs_quaternion.html#android_rs:rsQuaternionSet'>rsQuaternionSet</a> 2091 </td> 2092 <td class='jd-descrcol' width='100%'> 2093 Create a quaternion 2094 </td> 2095 </tr> 2096 <tr class='alt-color api apilevel-1'> 2097 <td class='jd-linkcol'> 2098 <a href='rs_quaternion.html#android_rs:rsQuaternionSlerp'>rsQuaternionSlerp</a> 2099 </td> 2100 <td class='jd-descrcol' width='100%'> 2101 Spherical linear interpolation between two quaternions 2102 </td> 2103 </tr> 2104 </tbody></table> 2105 <h2>Atomic Update Functions</h2> 2106 <p> To update values shared between multiple threads, use the functions below. 2107 They ensure that the values are atomically updated, i.e. that the memory 2108 reads, the updates, and the memory writes are done in the right order. 2109 </p> 2110 2111 <p> These functions are slower than their non-atomic equivalents, so use 2112 them only when synchronization is needed. 2113 </p> 2114 2115 <p> Note that in RenderScript, your code is likely to be running in separate 2116 threads even though you did not explicitely create them. The RenderScript 2117 runtime will very often split the execution of one kernel across multiple 2118 threads. Updating globals should be done with atomic functions. If possible, 2119 modify your algorithm to avoid them altogether. 2120 </p> 2121 <table class='jd-sumtable'><tbody> 2122 <tr><th colspan='2'>Functions</th></tr> 2123 <tr class='alt-color api apilevel-1'> 2124 <td class='jd-linkcol'> 2125 <a href='rs_atomic.html#android_rs:rsAtomicAdd'>rsAtomicAdd</a> 2126 </td> 2127 <td class='jd-descrcol' width='100%'> 2128 Thread-safe addition 2129 </td> 2130 </tr> 2131 <tr class='alt-color api apilevel-1'> 2132 <td class='jd-linkcol'> 2133 <a href='rs_atomic.html#android_rs:rsAtomicAnd'>rsAtomicAnd</a> 2134 </td> 2135 <td class='jd-descrcol' width='100%'> 2136 Thread-safe bitwise and 2137 </td> 2138 </tr> 2139 <tr class='alt-color api apilevel-1'> 2140 <td class='jd-linkcol'> 2141 <a href='rs_atomic.html#android_rs:rsAtomicCas'>rsAtomicCas</a> 2142 </td> 2143 <td class='jd-descrcol' width='100%'> 2144 Thread-safe compare and set 2145 </td> 2146 </tr> 2147 <tr class='alt-color api apilevel-1'> 2148 <td class='jd-linkcol'> 2149 <a href='rs_atomic.html#android_rs:rsAtomicDec'>rsAtomicDec</a> 2150 </td> 2151 <td class='jd-descrcol' width='100%'> 2152 Thread-safe decrement 2153 </td> 2154 </tr> 2155 <tr class='alt-color api apilevel-1'> 2156 <td class='jd-linkcol'> 2157 <a href='rs_atomic.html#android_rs:rsAtomicInc'>rsAtomicInc</a> 2158 </td> 2159 <td class='jd-descrcol' width='100%'> 2160 Thread-safe increment 2161 </td> 2162 </tr> 2163 <tr class='alt-color api apilevel-1'> 2164 <td class='jd-linkcol'> 2165 <a href='rs_atomic.html#android_rs:rsAtomicMax'>rsAtomicMax</a> 2166 </td> 2167 <td class='jd-descrcol' width='100%'> 2168 Thread-safe maximum 2169 </td> 2170 </tr> 2171 <tr class='alt-color api apilevel-1'> 2172 <td class='jd-linkcol'> 2173 <a href='rs_atomic.html#android_rs:rsAtomicMin'>rsAtomicMin</a> 2174 </td> 2175 <td class='jd-descrcol' width='100%'> 2176 Thread-safe minimum 2177 </td> 2178 </tr> 2179 <tr class='alt-color api apilevel-1'> 2180 <td class='jd-linkcol'> 2181 <a href='rs_atomic.html#android_rs:rsAtomicOr'>rsAtomicOr</a> 2182 </td> 2183 <td class='jd-descrcol' width='100%'> 2184 Thread-safe bitwise or 2185 </td> 2186 </tr> 2187 <tr class='alt-color api apilevel-1'> 2188 <td class='jd-linkcol'> 2189 <a href='rs_atomic.html#android_rs:rsAtomicSub'>rsAtomicSub</a> 2190 </td> 2191 <td class='jd-descrcol' width='100%'> 2192 Thread-safe subtraction 2193 </td> 2194 </tr> 2195 <tr class='alt-color api apilevel-1'> 2196 <td class='jd-linkcol'> 2197 <a href='rs_atomic.html#android_rs:rsAtomicXor'>rsAtomicXor</a> 2198 </td> 2199 <td class='jd-descrcol' width='100%'> 2200 Thread-safe bitwise exclusive or 2201 </td> 2202 </tr> 2203 </tbody></table> 2204 <h2>Time Functions and Types</h2> 2205 <p> The functions below can be used to tell the current clock time and the current 2206 system up time. It is not recommended to call these functions inside of a kernel. 2207 </p> 2208 <table class='jd-sumtable'><tbody> 2209 <tr><th colspan='2'>Types</th></tr> 2210 <tr class='alt-color api apilevel-1'> 2211 <td class='jd-linkcol'> 2212 <a href='rs_time.html#android_rs:rs_time_t'>rs_time_t</a> 2213 </td> 2214 <td class='jd-descrcol' width='100%'> 2215 Seconds since January 1, 1970 2216 </td> 2217 </tr> 2218 <tr class='alt-color api apilevel-1'> 2219 <td class='jd-linkcol'> 2220 <a href='rs_time.html#android_rs:rs_tm'>rs_tm</a> 2221 </td> 2222 <td class='jd-descrcol' width='100%'> 2223 Date and time structure 2224 </td> 2225 </tr> 2226 </tbody></table> 2227 <table class='jd-sumtable'><tbody> 2228 <tr><th colspan='2'>Functions</th></tr> 2229 <tr class='alt-color api apilevel-1'> 2230 <td class='jd-linkcol'> 2231 <a href='rs_time.html#android_rs:rsGetDt'>rsGetDt</a> 2232 </td> 2233 <td class='jd-descrcol' width='100%'> 2234 Elapsed time since last call 2235 </td> 2236 </tr> 2237 <tr class='alt-color api apilevel-1'> 2238 <td class='jd-linkcol'> 2239 <a href='rs_time.html#android_rs:rsLocaltime'>rsLocaltime</a> 2240 </td> 2241 <td class='jd-descrcol' width='100%'> 2242 Convert to local time 2243 </td> 2244 </tr> 2245 <tr class='alt-color api apilevel-1'> 2246 <td class='jd-linkcol'> 2247 <a href='rs_time.html#android_rs:rsTime'>rsTime</a> 2248 </td> 2249 <td class='jd-descrcol' width='100%'> 2250 Seconds since January 1, 1970 2251 </td> 2252 </tr> 2253 <tr class='alt-color api apilevel-1'> 2254 <td class='jd-linkcol'> 2255 <a href='rs_time.html#android_rs:rsUptimeMillis'>rsUptimeMillis</a> 2256 </td> 2257 <td class='jd-descrcol' width='100%'> 2258 System uptime in milliseconds 2259 </td> 2260 </tr> 2261 <tr class='alt-color api apilevel-1'> 2262 <td class='jd-linkcol'> 2263 <a href='rs_time.html#android_rs:rsUptimeNanos'>rsUptimeNanos</a> 2264 </td> 2265 <td class='jd-descrcol' width='100%'> 2266 System uptime in nanoseconds 2267 </td> 2268 </tr> 2269 </tbody></table> 2270 <h2>Allocation Data Access Functions</h2> 2271 <p> The functions below can be used to get and set the cells that comprise 2272 an allocation. 2273 <ul> 2274 <li>Individual cells are accessed using the rsGetElementAt* and 2275 <a href='rs_allocation_data.html#android_rs:rsSetElementAt'>rsSetElementAt</a> functions.</li> 2276 <li>Multiple cells can be copied using the rsAllocationCopy* and 2277 rsAllocationV* functions.</li> 2278 <li>For getting values through a sampler, use <a href='rs_allocation_data.html#android_rs:rsSample'>rsSample</a>.</li> 2279 </ul> 2280 The <a href='rs_allocation_data.html#android_rs:rsGetElementAt'>rsGetElementAt</a> and rsSetElement* functions are somewhat misnamed. 2281 They don't get or set elements, which are akin to data types; they get 2282 or set cells. Think of them as rsGetCellAt and and rsSetCellAt. 2283 </p> 2284 <table class='jd-sumtable'><tbody> 2285 <tr><th colspan='2'>Functions</th></tr> 2286 <tr class='alt-color api apilevel-1'> 2287 <td class='jd-linkcol'> 2288 <a href='rs_allocation_data.html#android_rs:rsAllocationCopy1DRange'>rsAllocationCopy1DRange</a> 2289 </td> 2290 <td class='jd-descrcol' width='100%'> 2291 Copy consecutive cells between allocations 2292 </td> 2293 </tr> 2294 <tr class='alt-color api apilevel-1'> 2295 <td class='jd-linkcol'> 2296 <a href='rs_allocation_data.html#android_rs:rsAllocationCopy2DRange'>rsAllocationCopy2DRange</a> 2297 </td> 2298 <td class='jd-descrcol' width='100%'> 2299 Copy a rectangular region of cells between allocations 2300 </td> 2301 </tr> 2302 <tr class='alt-color api apilevel-1'> 2303 <td class='jd-linkcol'> 2304 <a href='rs_allocation_data.html#android_rs:rsAllocationVLoadX'>rsAllocationVLoadX</a> 2305 </td> 2306 <td class='jd-descrcol' width='100%'> 2307 Get a vector from an allocation of scalars 2308 </td> 2309 </tr> 2310 <tr class='alt-color api apilevel-1'> 2311 <td class='jd-linkcol'> 2312 <a href='rs_allocation_data.html#android_rs:rsAllocationVStoreX'>rsAllocationVStoreX</a> 2313 </td> 2314 <td class='jd-descrcol' width='100%'> 2315 Store a vector into an allocation of scalars 2316 </td> 2317 </tr> 2318 <tr class='alt-color api apilevel-1'> 2319 <td class='jd-linkcol'> 2320 <a href='rs_allocation_data.html#android_rs:rsGetElementAt'>rsGetElementAt</a> 2321 </td> 2322 <td class='jd-descrcol' width='100%'> 2323 Return a cell from an allocation 2324 </td> 2325 </tr> 2326 <tr class='alt-color api apilevel-1'> 2327 <td class='jd-linkcol'> 2328 <a href='rs_allocation_data.html#android_rs:rsGetElementAtYuv_uchar_U'>rsGetElementAtYuv_uchar_U</a> 2329 </td> 2330 <td class='jd-descrcol' width='100%'> 2331 Get the U component of an allocation of YUVs 2332 </td> 2333 </tr> 2334 <tr class='alt-color api apilevel-1'> 2335 <td class='jd-linkcol'> 2336 <a href='rs_allocation_data.html#android_rs:rsGetElementAtYuv_uchar_V'>rsGetElementAtYuv_uchar_V</a> 2337 </td> 2338 <td class='jd-descrcol' width='100%'> 2339 Get the V component of an allocation of YUVs 2340 </td> 2341 </tr> 2342 <tr class='alt-color api apilevel-1'> 2343 <td class='jd-linkcol'> 2344 <a href='rs_allocation_data.html#android_rs:rsGetElementAtYuv_uchar_Y'>rsGetElementAtYuv_uchar_Y</a> 2345 </td> 2346 <td class='jd-descrcol' width='100%'> 2347 Get the Y component of an allocation of YUVs 2348 </td> 2349 </tr> 2350 <tr class='alt-color api apilevel-1'> 2351 <td class='jd-linkcol'> 2352 <a href='rs_allocation_data.html#android_rs:rsSample'>rsSample</a> 2353 </td> 2354 <td class='jd-descrcol' width='100%'> 2355 Sample a value from a texture allocation 2356 </td> 2357 </tr> 2358 <tr class='alt-color api apilevel-1'> 2359 <td class='jd-linkcol'> 2360 <a href='rs_allocation_data.html#android_rs:rsSetElementAt'>rsSetElementAt</a> 2361 </td> 2362 <td class='jd-descrcol' width='100%'> 2363 Set a cell of an allocation 2364 </td> 2365 </tr> 2366 </tbody></table> 2367 <h2>Object Characteristics Functions</h2> 2368 <p> The functions below can be used to query the characteristics of an Allocation, Element, 2369 or Sampler object. These objects are created from Java. You can't create them from a 2370 script. 2371 </p> 2372 2373 <p> <h5>Allocations:</h5> 2374 </p> 2375 2376 <p> Allocations are the primary method used to pass data to and from RenderScript kernels. 2377 </p> 2378 2379 <p> They are a structured collection of cells that can be used to store bitmaps, textures, 2380 arbitrary data points, etc. 2381 </p> 2382 2383 <p> This collection of cells may have many dimensions (X, Y, Z, Array0, Array1, Array2, Array3), 2384 faces (for cubemaps), and level of details (for mipmapping). 2385 </p> 2386 2387 <p> See the <a href='http://developer.android.com/reference/android/renderscript/Allocation.html'>android.renderscript.Allocation</a> for details on to create Allocations. 2388 </p> 2389 2390 <p> <h5>Elements:</h5> 2391 </p> 2392 2393 <p> The term "element" is used a bit ambiguously in RenderScript, as both type information 2394 for the cells of an Allocation and the instantiation of that type. For example:<ul> 2395 <li><a href='rs_object_types.html#android_rs:rs_element'>rs_element</a> is a handle to a type specification, and</li> 2396 <li>In functions like <a href='rs_allocation_data.html#android_rs:rsGetElementAt'>rsGetElementAt</a>(), "element" means the instantiation of the type, 2397 i.e. a cell of an Allocation.</li></ul> 2398 </p> 2399 2400 <p> The functions below let you query the characteristics of the type specificiation. 2401 </p> 2402 2403 <p> An Element can specify a simple data types as found in C, e.g. an integer, float, or 2404 boolean. It can also specify a handle to a RenderScript object. See <a href='rs_object_types.html#android_rs:rs_data_type'>rs_data_type</a> for 2405 a list of basic types. 2406 </p> 2407 2408 <p> Elements can specify fixed size vector (of size 2, 3, or 4) versions of the basic types. 2409 Elements can be grouped together into complex Elements, creating the equivalent of 2410 C structure definitions. 2411 </p> 2412 2413 <p> Elements can also have a kind, which is semantic information used to interpret pixel 2414 data. See <a href='rs_object_types.html#android_rs:rs_data_kind'>rs_data_kind</a>. 2415 </p> 2416 2417 <p> When creating Allocations of common elements, you can simply use one of the many predefined 2418 Elements like <a href='http://developer.android.com/reference/android/renderscript/Element.html#F32_2(android.renderscript.RenderScript)'>F32_2</a>. 2419 </p> 2420 2421 <p> To create complex Elements, use the <a href='http://developer.android.com/reference/android/renderscript/Element.Builder.html'>Element.Builder</a> Java class. 2422 </p> 2423 2424 <p> <h5>Samplers:</h5> 2425 </p> 2426 2427 <p> Samplers objects define how Allocations can be read as structure within a kernel. 2428 See <a href='http://developer.android.com/reference/android/renderscript/Sampler.html'>android.renderscript.S</a>. 2429 </p> 2430 <table class='jd-sumtable'><tbody> 2431 <tr><th colspan='2'>Functions</th></tr> 2432 <tr class='alt-color api apilevel-1'> 2433 <td class='jd-linkcol'> 2434 <a href='rs_object_info.html#android_rs:rsAllocationGetDimFaces'>rsAllocationGetDimFaces</a> 2435 </td> 2436 <td class='jd-descrcol' width='100%'> 2437 Presence of more than one face 2438 </td> 2439 </tr> 2440 <tr class='alt-color api apilevel-1'> 2441 <td class='jd-linkcol'> 2442 <a href='rs_object_info.html#android_rs:rsAllocationGetDimLOD'>rsAllocationGetDimLOD</a> 2443 </td> 2444 <td class='jd-descrcol' width='100%'> 2445 Presence of levels of detail 2446 </td> 2447 </tr> 2448 <tr class='alt-color api apilevel-1'> 2449 <td class='jd-linkcol'> 2450 <a href='rs_object_info.html#android_rs:rsAllocationGetDimX'>rsAllocationGetDimX</a> 2451 </td> 2452 <td class='jd-descrcol' width='100%'> 2453 Size of the X dimension 2454 </td> 2455 </tr> 2456 <tr class='alt-color api apilevel-1'> 2457 <td class='jd-linkcol'> 2458 <a href='rs_object_info.html#android_rs:rsAllocationGetDimY'>rsAllocationGetDimY</a> 2459 </td> 2460 <td class='jd-descrcol' width='100%'> 2461 Size of the Y dimension 2462 </td> 2463 </tr> 2464 <tr class='alt-color api apilevel-1'> 2465 <td class='jd-linkcol'> 2466 <a href='rs_object_info.html#android_rs:rsAllocationGetDimZ'>rsAllocationGetDimZ</a> 2467 </td> 2468 <td class='jd-descrcol' width='100%'> 2469 Size of the Z dimension 2470 </td> 2471 </tr> 2472 <tr class='alt-color api apilevel-1'> 2473 <td class='jd-linkcol'> 2474 <a href='rs_object_info.html#android_rs:rsAllocationGetElement'>rsAllocationGetElement</a> 2475 </td> 2476 <td class='jd-descrcol' width='100%'> 2477 Get the object that describes the cell of an Allocation 2478 </td> 2479 </tr> 2480 <tr class='alt-color api apilevel-1'> 2481 <td class='jd-linkcol'> 2482 <a href='rs_object_info.html#android_rs:rsClearObject'>rsClearObject</a> 2483 </td> 2484 <td class='jd-descrcol' width='100%'> 2485 Release an object 2486 </td> 2487 </tr> 2488 <tr class='alt-color api apilevel-1'> 2489 <td class='jd-linkcol'> 2490 <a href='rs_object_info.html#android_rs:rsElementGetBytesSize'>rsElementGetBytesSize</a> 2491 </td> 2492 <td class='jd-descrcol' width='100%'> 2493 Size of an Element 2494 </td> 2495 </tr> 2496 <tr class='alt-color api apilevel-1'> 2497 <td class='jd-linkcol'> 2498 <a href='rs_object_info.html#android_rs:rsElementGetDataKind'>rsElementGetDataKind</a> 2499 </td> 2500 <td class='jd-descrcol' width='100%'> 2501 Kind of an Element 2502 </td> 2503 </tr> 2504 <tr class='alt-color api apilevel-1'> 2505 <td class='jd-linkcol'> 2506 <a href='rs_object_info.html#android_rs:rsElementGetDataType'>rsElementGetDataType</a> 2507 </td> 2508 <td class='jd-descrcol' width='100%'> 2509 Data type of an Element 2510 </td> 2511 </tr> 2512 <tr class='alt-color api apilevel-1'> 2513 <td class='jd-linkcol'> 2514 <a href='rs_object_info.html#android_rs:rsElementGetSubElement'>rsElementGetSubElement</a> 2515 </td> 2516 <td class='jd-descrcol' width='100%'> 2517 Sub-element of a complex Element 2518 </td> 2519 </tr> 2520 <tr class='alt-color api apilevel-1'> 2521 <td class='jd-linkcol'> 2522 <a href='rs_object_info.html#android_rs:rsElementGetSubElementArraySize'>rsElementGetSubElementArraySize</a> 2523 </td> 2524 <td class='jd-descrcol' width='100%'> 2525 Array size of a sub-element of a complex Element 2526 </td> 2527 </tr> 2528 <tr class='alt-color api apilevel-1'> 2529 <td class='jd-linkcol'> 2530 <a href='rs_object_info.html#android_rs:rsElementGetSubElementCount'>rsElementGetSubElementCount</a> 2531 </td> 2532 <td class='jd-descrcol' width='100%'> 2533 Number of sub-elements 2534 </td> 2535 </tr> 2536 <tr class='alt-color api apilevel-1'> 2537 <td class='jd-linkcol'> 2538 <a href='rs_object_info.html#android_rs:rsElementGetSubElementName'>rsElementGetSubElementName</a> 2539 </td> 2540 <td class='jd-descrcol' width='100%'> 2541 Name of a sub-element 2542 </td> 2543 </tr> 2544 <tr class='alt-color api apilevel-1'> 2545 <td class='jd-linkcol'> 2546 <a href='rs_object_info.html#android_rs:rsElementGetSubElementNameLength'>rsElementGetSubElementNameLength</a> 2547 </td> 2548 <td class='jd-descrcol' width='100%'> 2549 Length of the name of a sub-element 2550 </td> 2551 </tr> 2552 <tr class='alt-color api apilevel-1'> 2553 <td class='jd-linkcol'> 2554 <a href='rs_object_info.html#android_rs:rsElementGetSubElementOffsetBytes'>rsElementGetSubElementOffsetBytes</a> 2555 </td> 2556 <td class='jd-descrcol' width='100%'> 2557 Offset of the instantiated sub-element 2558 </td> 2559 </tr> 2560 <tr class='alt-color api apilevel-1'> 2561 <td class='jd-linkcol'> 2562 <a href='rs_object_info.html#android_rs:rsElementGetVectorSize'>rsElementGetVectorSize</a> 2563 </td> 2564 <td class='jd-descrcol' width='100%'> 2565 Vector size of the Element 2566 </td> 2567 </tr> 2568 <tr class='alt-color api apilevel-1'> 2569 <td class='jd-linkcol'> 2570 <a href='rs_object_info.html#android_rs:rsIsObject'>rsIsObject</a> 2571 </td> 2572 <td class='jd-descrcol' width='100%'> 2573 Check for an empty handle 2574 </td> 2575 </tr> 2576 <tr class='alt-color api apilevel-1'> 2577 <td class='jd-linkcol'> 2578 <a href='rs_object_info.html#android_rs:rsSamplerGetAnisotropy'>rsSamplerGetAnisotropy</a> 2579 </td> 2580 <td class='jd-descrcol' width='100%'> 2581 Anisotropy of the Sampler 2582 </td> 2583 </tr> 2584 <tr class='alt-color api apilevel-1'> 2585 <td class='jd-linkcol'> 2586 <a href='rs_object_info.html#android_rs:rsSamplerGetMagnification'>rsSamplerGetMagnification</a> 2587 </td> 2588 <td class='jd-descrcol' width='100%'> 2589 Sampler magnification value 2590 </td> 2591 </tr> 2592 <tr class='alt-color api apilevel-1'> 2593 <td class='jd-linkcol'> 2594 <a href='rs_object_info.html#android_rs:rsSamplerGetMinification'>rsSamplerGetMinification</a> 2595 </td> 2596 <td class='jd-descrcol' width='100%'> 2597 Sampler minification value 2598 </td> 2599 </tr> 2600 <tr class='alt-color api apilevel-1'> 2601 <td class='jd-linkcol'> 2602 <a href='rs_object_info.html#android_rs:rsSamplerGetWrapS'>rsSamplerGetWrapS</a> 2603 </td> 2604 <td class='jd-descrcol' width='100%'> 2605 Sampler wrap S value 2606 </td> 2607 </tr> 2608 <tr class='alt-color api apilevel-1'> 2609 <td class='jd-linkcol'> 2610 <a href='rs_object_info.html#android_rs:rsSamplerGetWrapT'>rsSamplerGetWrapT</a> 2611 </td> 2612 <td class='jd-descrcol' width='100%'> 2613 Sampler wrap T value 2614 </td> 2615 </tr> 2616 </tbody></table> 2617 <h2>Kernel Invocation Functions and Types</h2> 2618 <p> The <a href='rs_for_each.html#android_rs:rsForEach'>rsForEach</a>() function can be used to invoke the root kernel of a script. 2619 </p> 2620 2621 <p> The other functions are used to get the characteristics of the invocation of 2622 an executing kernel, like dimensions and current indices. These functions take 2623 a <a href='rs_for_each.html#android_rs:rs_kernel_context'>rs_kernel_context</a> as argument. 2624 </p> 2625 <table class='jd-sumtable'><tbody> 2626 <tr><th colspan='2'>Types</th></tr> 2627 <tr class='alt-color api apilevel-1'> 2628 <td class='jd-linkcol'> 2629 <a href='rs_for_each.html#android_rs:rs_for_each_strategy_t'>rs_for_each_strategy_t</a> 2630 </td> 2631 <td class='jd-descrcol' width='100%'> 2632 Suggested cell processing order 2633 </td> 2634 </tr> 2635 <tr class='alt-color api apilevel-1'> 2636 <td class='jd-linkcol'> 2637 <a href='rs_for_each.html#android_rs:rs_kernel_context'>rs_kernel_context</a> 2638 </td> 2639 <td class='jd-descrcol' width='100%'> 2640 Handle to a kernel invocation context 2641 </td> 2642 </tr> 2643 <tr class='alt-color api apilevel-1'> 2644 <td class='jd-linkcol'> 2645 <a href='rs_for_each.html#android_rs:rs_script_call_t'>rs_script_call_t</a> 2646 </td> 2647 <td class='jd-descrcol' width='100%'> 2648 Cell iteration information 2649 </td> 2650 </tr> 2651 </tbody></table> 2652 <table class='jd-sumtable'><tbody> 2653 <tr><th colspan='2'>Functions</th></tr> 2654 <tr class='alt-color api apilevel-1'> 2655 <td class='jd-linkcol'> 2656 <a href='rs_for_each.html#android_rs:rsForEach'>rsForEach</a> 2657 </td> 2658 <td class='jd-descrcol' width='100%'> 2659 Invoke the root kernel of a script 2660 </td> 2661 </tr> 2662 <tr class='alt-color api apilevel-1'> 2663 <td class='jd-linkcol'> 2664 <a href='rs_for_each.html#android_rs:rsGetArray0'>rsGetArray0</a> 2665 </td> 2666 <td class='jd-descrcol' width='100%'> 2667 Index in the Array0 dimension for the specified kernel context 2668 </td> 2669 </tr> 2670 <tr class='alt-color api apilevel-1'> 2671 <td class='jd-linkcol'> 2672 <a href='rs_for_each.html#android_rs:rsGetArray1'>rsGetArray1</a> 2673 </td> 2674 <td class='jd-descrcol' width='100%'> 2675 Index in the Array1 dimension for the specified kernel context 2676 </td> 2677 </tr> 2678 <tr class='alt-color api apilevel-1'> 2679 <td class='jd-linkcol'> 2680 <a href='rs_for_each.html#android_rs:rsGetArray2'>rsGetArray2</a> 2681 </td> 2682 <td class='jd-descrcol' width='100%'> 2683 Index in the Array2 dimension for the specified kernel context 2684 </td> 2685 </tr> 2686 <tr class='alt-color api apilevel-1'> 2687 <td class='jd-linkcol'> 2688 <a href='rs_for_each.html#android_rs:rsGetArray3'>rsGetArray3</a> 2689 </td> 2690 <td class='jd-descrcol' width='100%'> 2691 Index in the Array3 dimension for the specified kernel context 2692 </td> 2693 </tr> 2694 <tr class='alt-color api apilevel-1'> 2695 <td class='jd-linkcol'> 2696 <a href='rs_for_each.html#android_rs:rsGetDimArray0'>rsGetDimArray0</a> 2697 </td> 2698 <td class='jd-descrcol' width='100%'> 2699 Size of the Array0 dimension for the specified kernel context 2700 </td> 2701 </tr> 2702 <tr class='alt-color api apilevel-1'> 2703 <td class='jd-linkcol'> 2704 <a href='rs_for_each.html#android_rs:rsGetDimArray1'>rsGetDimArray1</a> 2705 </td> 2706 <td class='jd-descrcol' width='100%'> 2707 Size of the Array1 dimension for the specified kernel context 2708 </td> 2709 </tr> 2710 <tr class='alt-color api apilevel-1'> 2711 <td class='jd-linkcol'> 2712 <a href='rs_for_each.html#android_rs:rsGetDimArray2'>rsGetDimArray2</a> 2713 </td> 2714 <td class='jd-descrcol' width='100%'> 2715 Size of the Array2 dimension for the specified kernel context 2716 </td> 2717 </tr> 2718 <tr class='alt-color api apilevel-1'> 2719 <td class='jd-linkcol'> 2720 <a href='rs_for_each.html#android_rs:rsGetDimArray3'>rsGetDimArray3</a> 2721 </td> 2722 <td class='jd-descrcol' width='100%'> 2723 Size of the Array3 dimension for the specified kernel context 2724 </td> 2725 </tr> 2726 <tr class='alt-color api apilevel-1'> 2727 <td class='jd-linkcol'> 2728 <a href='rs_for_each.html#android_rs:rsGetDimHasFaces'>rsGetDimHasFaces</a> 2729 </td> 2730 <td class='jd-descrcol' width='100%'> 2731 Presence of more than one face for the specified kernel context 2732 </td> 2733 </tr> 2734 <tr class='alt-color api apilevel-1'> 2735 <td class='jd-linkcol'> 2736 <a href='rs_for_each.html#android_rs:rsGetDimLod'>rsGetDimLod</a> 2737 </td> 2738 <td class='jd-descrcol' width='100%'> 2739 Number of levels of detail for the specified kernel context 2740 </td> 2741 </tr> 2742 <tr class='alt-color api apilevel-1'> 2743 <td class='jd-linkcol'> 2744 <a href='rs_for_each.html#android_rs:rsGetDimX'>rsGetDimX</a> 2745 </td> 2746 <td class='jd-descrcol' width='100%'> 2747 Size of the X dimension for the specified kernel context 2748 </td> 2749 </tr> 2750 <tr class='alt-color api apilevel-1'> 2751 <td class='jd-linkcol'> 2752 <a href='rs_for_each.html#android_rs:rsGetDimY'>rsGetDimY</a> 2753 </td> 2754 <td class='jd-descrcol' width='100%'> 2755 Size of the Y dimension for the specified kernel context 2756 </td> 2757 </tr> 2758 <tr class='alt-color api apilevel-1'> 2759 <td class='jd-linkcol'> 2760 <a href='rs_for_each.html#android_rs:rsGetDimZ'>rsGetDimZ</a> 2761 </td> 2762 <td class='jd-descrcol' width='100%'> 2763 Size of the Z dimension for the specified kernel context 2764 </td> 2765 </tr> 2766 <tr class='alt-color api apilevel-1'> 2767 <td class='jd-linkcol'> 2768 <a href='rs_for_each.html#android_rs:rsGetFace'>rsGetFace</a> 2769 </td> 2770 <td class='jd-descrcol' width='100%'> 2771 Coordinate of the Face for the specified kernel context 2772 </td> 2773 </tr> 2774 <tr class='alt-color api apilevel-1'> 2775 <td class='jd-linkcol'> 2776 <a href='rs_for_each.html#android_rs:rsGetLod'>rsGetLod</a> 2777 </td> 2778 <td class='jd-descrcol' width='100%'> 2779 Index in the Levels of Detail dimension for the specified kernel context 2780 </td> 2781 </tr> 2782 </tbody></table> 2783 <h2>Input/Output Functions</h2> 2784 <p> These functions are used to:<ul> 2785 <li>Send information to the Java client, and</li> 2786 <li>Send the processed allocation or receive the next allocation to process.</li></ul> 2787 </p> 2788 <table class='jd-sumtable'><tbody> 2789 <tr><th colspan='2'>Functions</th></tr> 2790 <tr class='alt-color api apilevel-1'> 2791 <td class='jd-linkcol'> 2792 <a href='rs_io.html#android_rs:rsAllocationIoReceive'>rsAllocationIoReceive</a> 2793 </td> 2794 <td class='jd-descrcol' width='100%'> 2795 Receive new content from the queue 2796 </td> 2797 </tr> 2798 <tr class='alt-color api apilevel-1'> 2799 <td class='jd-linkcol'> 2800 <a href='rs_io.html#android_rs:rsAllocationIoSend'>rsAllocationIoSend</a> 2801 </td> 2802 <td class='jd-descrcol' width='100%'> 2803 Send new content to the queue 2804 </td> 2805 </tr> 2806 <tr class='alt-color api apilevel-1'> 2807 <td class='jd-linkcol'> 2808 <a href='rs_io.html#android_rs:rsSendToClient'>rsSendToClient</a> 2809 </td> 2810 <td class='jd-descrcol' width='100%'> 2811 Send a message to the client, non-blocking 2812 </td> 2813 </tr> 2814 <tr class='alt-color api apilevel-1'> 2815 <td class='jd-linkcol'> 2816 <a href='rs_io.html#android_rs:rsSendToClientBlocking'>rsSendToClientBlocking</a> 2817 </td> 2818 <td class='jd-descrcol' width='100%'> 2819 Send a message to the client, blocking 2820 </td> 2821 </tr> 2822 </tbody></table> 2823 <h2>Debugging Functions</h2> 2824 <p> The functions below are intended to be used during application developement. 2825 They should not be used in shipping applications. 2826 </p> 2827 <table class='jd-sumtable'><tbody> 2828 <tr><th colspan='2'>Functions</th></tr> 2829 <tr class='alt-color api apilevel-1'> 2830 <td class='jd-linkcol'> 2831 <a href='rs_debug.html#android_rs:rsDebug'>rsDebug</a> 2832 </td> 2833 <td class='jd-descrcol' width='100%'> 2834 Log a message and values 2835 </td> 2836 </tr> 2837 </tbody></table> 2838 <h2>Graphics Functions and Types</h2> 2839 <p> The graphics subsystem of RenderScript was removed at API level 23. 2840 </p> 2841 </div> 2842