rs_graphics.rsh revision c5184e202ced435258adb2cfe2013570e7190954
1/* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17// Don't edit this file! It is auto-generated by frameworks/rs/api/gen_runtime. 18 19/* 20 * rs_graphics.rsh: RenderScript graphics API 21 * 22 * A set of graphics functions used by RenderScript. 23 */ 24#ifndef RENDERSCRIPT_RS_GRAPHICS_RSH 25#define RENDERSCRIPT_RS_GRAPHICS_RSH 26 27#ifdef __LP64__ 28// TODO We need to fix some of the builds before enabling this error: 29// #error "RenderScript graphics is deprecated and not supported in 64bit mode." 30#else 31#include "rs_mesh.rsh" 32#include "rs_program.rsh" 33#endif 34 35/* 36 * Sync the contents of an allocation. 37 * 38 * If the source is specified, sync from memory space specified by source. 39 * 40 * If the source is not specified, sync from its SCRIPT memory space to its HW 41 * memory spaces. 42 */ 43#ifndef __LP64__ 44extern void __attribute__((overloadable)) 45 rsgAllocationSyncAll(rs_allocation alloc); 46#endif 47 48#ifndef __LP64__ 49#if (defined(RS_VERSION) && (RS_VERSION >= 14)) 50extern void __attribute__((overloadable)) 51 rsgAllocationSyncAll(rs_allocation alloc, rs_allocation_usage_type source); 52#endif 53#endif 54 55/* 56 * Set the color target used for all subsequent rendering calls 57 */ 58#ifndef __LP64__ 59#if (defined(RS_VERSION) && (RS_VERSION >= 14)) 60extern void __attribute__((overloadable)) 61 rsgBindColorTarget(rs_allocation colorTarget, uint slot); 62#endif 63#endif 64 65/* 66 * Bind a new Allocation object to a ProgramFragment or ProgramVertex. 67 * The Allocation must be a valid constant input for the Program. 68 * 69 * Parameters: 70 * ps program fragment object 71 * slot index of the constant buffer on the program 72 * c constants to bind 73 * pv program vertex object 74 */ 75#ifndef __LP64__ 76extern void __attribute__((overloadable)) 77 rsgBindConstant(rs_program_fragment ps, uint slot, rs_allocation c); 78#endif 79 80#ifndef __LP64__ 81extern void __attribute__((overloadable)) 82 rsgBindConstant(rs_program_vertex pv, uint slot, rs_allocation c); 83#endif 84 85/* 86 * Set the depth target used for all subsequent rendering calls 87 */ 88#ifndef __LP64__ 89#if (defined(RS_VERSION) && (RS_VERSION >= 14)) 90extern void __attribute__((overloadable)) 91 rsgBindDepthTarget(rs_allocation depthTarget); 92#endif 93#endif 94 95/* 96 * Binds the font object to be used for all subsequent font rendering calls 97 * 98 * Parameters: 99 * font object to bind 100 */ 101#ifndef __LP64__ 102extern void __attribute__((overloadable)) 103 rsgBindFont(rs_font font); 104#endif 105 106/* 107 * Bind a new ProgramFragment to the rendering context. 108 */ 109#ifndef __LP64__ 110extern void __attribute__((overloadable)) 111 rsgBindProgramFragment(rs_program_fragment pf); 112#endif 113 114/* 115 * Bind a new ProgramRaster to the rendering context. 116 */ 117#ifndef __LP64__ 118extern void __attribute__((overloadable)) 119 rsgBindProgramRaster(rs_program_raster pr); 120#endif 121 122/* 123 * Bind a new ProgramStore to the rendering context. 124 */ 125#ifndef __LP64__ 126extern void __attribute__((overloadable)) 127 rsgBindProgramStore(rs_program_store ps); 128#endif 129 130/* 131 * Bind a new ProgramVertex to the rendering context. 132 */ 133#ifndef __LP64__ 134extern void __attribute__((overloadable)) 135 rsgBindProgramVertex(rs_program_vertex pv); 136#endif 137 138/* 139 * Bind a new Sampler object to a ProgramFragment. The sampler will 140 * operate on the texture bound at the matching slot. 141 */ 142#ifndef __LP64__ 143extern void __attribute__((overloadable)) 144 rsgBindSampler(rs_program_fragment fragment, uint slot, rs_sampler sampler); 145#endif 146 147/* 148 * Bind a new Allocation object to a ProgramFragment. The 149 * Allocation must be a valid texture for the Program. The sampling 150 * of the texture will be controled by the Sampler bound at the 151 * matching slot. 152 */ 153#ifndef __LP64__ 154extern void __attribute__((overloadable)) 155 rsgBindTexture(rs_program_fragment v, uint slot, rs_allocation alloc); 156#endif 157 158/* 159 * Clear all color and depth targets and resume rendering into 160 * the framebuffer 161 */ 162#ifndef __LP64__ 163#if (defined(RS_VERSION) && (RS_VERSION >= 14)) 164extern void __attribute__((overloadable)) 165 rsgClearAllRenderTargets(void); 166#endif 167#endif 168 169/* 170 * Clears the rendering surface to the specified color. 171 */ 172#ifndef __LP64__ 173extern void __attribute__((overloadable)) 174 rsgClearColor(float r, float g, float b, float a); 175#endif 176 177/* 178 * Clear the previously set color target 179 */ 180#ifndef __LP64__ 181#if (defined(RS_VERSION) && (RS_VERSION >= 14)) 182extern void __attribute__((overloadable)) 183 rsgClearColorTarget(uint slot); 184#endif 185#endif 186 187/* 188 * Clears the depth suface to the specified value. 189 */ 190#ifndef __LP64__ 191extern void __attribute__((overloadable)) 192 rsgClearDepth(float value); 193#endif 194 195/* 196 * Clear the previously set depth target 197 */ 198#ifndef __LP64__ 199#if (defined(RS_VERSION) && (RS_VERSION >= 14)) 200extern void __attribute__((overloadable)) 201 rsgClearDepthTarget(void); 202#endif 203#endif 204 205/* 206 * Draw a mesh using the current context state. 207 * 208 * If primitiveIndex is specified, draw part of a mesh using the current context state. 209 * 210 * If start and len are also specified, draw specified index range of part of a mesh using the current context state. 211 * 212 * Otherwise the whole mesh is rendered. 213 * 214 * Parameters: 215 * ism mesh object to render 216 * primitiveIndex for meshes that contain multiple primitive groups this parameter specifies the index of the group to draw. 217 * start starting index in the range 218 * len number of indices to draw 219 */ 220#ifndef __LP64__ 221extern void __attribute__((overloadable)) 222 rsgDrawMesh(rs_mesh ism); 223#endif 224 225#ifndef __LP64__ 226extern void __attribute__((overloadable)) 227 rsgDrawMesh(rs_mesh ism, uint primitiveIndex); 228#endif 229 230#ifndef __LP64__ 231extern void __attribute__((overloadable)) 232 rsgDrawMesh(rs_mesh ism, uint primitiveIndex, uint start, uint len); 233#endif 234 235/* 236 * Low performance utility function for drawing a simple quad. Not intended for 237 * drawing large quantities of geometry. 238 */ 239#ifndef __LP64__ 240extern void __attribute__((overloadable)) 241 rsgDrawQuad(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, 242 float z3, float x4, float y4, float z4); 243#endif 244 245/* 246 * Low performance utility function for drawing a textured quad. Not intended 247 * for drawing large quantities of geometry. 248 */ 249#ifndef __LP64__ 250extern void __attribute__((overloadable)) 251 rsgDrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1, float x2, float y2, 252 float z2, float u2, float v2, float x3, float y3, float z3, float u3, 253 float v3, float x4, float y4, float z4, float u4, float v4); 254#endif 255 256/* 257 * Low performance utility function for drawing a simple rectangle. Not 258 * intended for drawing large quantities of geometry. 259 */ 260#ifndef __LP64__ 261extern void __attribute__((overloadable)) 262 rsgDrawRect(float x1, float y1, float x2, float y2, float z); 263#endif 264 265/* 266 * Low performance function for drawing rectangles in screenspace. This 267 * function uses the default passthough ProgramVertex. Any bound ProgramVertex 268 * is ignored. This function has considerable overhead and should not be used 269 * for drawing in shipping applications. 270 */ 271#ifndef __LP64__ 272extern void __attribute__((overloadable)) 273 rsgDrawSpriteScreenspace(float x, float y, float z, float w, float h); 274#endif 275 276/* 277 * Draws text given a string and location 278 */ 279#ifndef __LP64__ 280extern void __attribute__((overloadable)) 281 rsgDrawText(const char* text, int x, int y); 282#endif 283 284#ifndef __LP64__ 285extern void __attribute__((overloadable)) 286 rsgDrawText(rs_allocation alloc, int x, int y); 287#endif 288 289/* 290 * Force RenderScript to finish all rendering commands 291 */ 292#ifndef __LP64__ 293#if (defined(RS_VERSION) && (RS_VERSION >= 14)) 294extern uint __attribute__((overloadable)) 295 rsgFinish(void); 296#endif 297#endif 298 299/* 300 * Sets the font color for all subsequent rendering calls 301 * 302 * Parameters: 303 * r red component 304 * g green component 305 * b blue component 306 * a alpha component 307 */ 308#ifndef __LP64__ 309extern void __attribute__((overloadable)) 310 rsgFontColor(float r, float g, float b, float a); 311#endif 312 313/* 314 * Get the height of the current rendering surface. 315 */ 316#ifndef __LP64__ 317extern uint __attribute__((overloadable)) 318 rsgGetHeight(void); 319#endif 320 321/* 322 * Get the width of the current rendering surface. 323 */ 324#ifndef __LP64__ 325extern uint __attribute__((overloadable)) 326 rsgGetWidth(void); 327#endif 328 329/* 330 * Returns the bounding box of the text relative to (0, 0) 331 * Any of left, right, top, bottom could be NULL 332 */ 333#ifndef __LP64__ 334extern void __attribute__((overloadable)) 335 rsgMeasureText(const char* text, int* left, int* right, int* top, int* bottom); 336#endif 337 338#ifndef __LP64__ 339extern void __attribute__((overloadable)) 340 rsgMeasureText(rs_allocation alloc, int* left, int* right, int* top, int* bottom); 341#endif 342 343/* 344 * Computes an axis aligned bounding box of a mesh object 345 */ 346#ifndef __LP64__ 347extern void __attribute__((overloadable)) 348 rsgMeshComputeBoundingBox(rs_mesh mesh, float* minX, float* minY, float* min, float* maxX, 349 float* maxY, float* maxZ); 350#endif 351 352#ifndef __LP64__ 353static inline void __attribute__((always_inline, overloadable)) 354 rsgMeshComputeBoundingBox(rs_mesh mesh, float3* bBoxMin, float3* bBoxMax) { 355 float x1, y1, z1, x2, y2, z2; 356 rsgMeshComputeBoundingBox(mesh, &x1, &y1, &z1, &x2, &y2, &z2); 357 bBoxMin->x = x1; 358 bBoxMin->y = y1; 359 bBoxMin->z = z1; 360 bBoxMax->x = x2; 361 bBoxMax->y = y2; 362 bBoxMax->z = z2; 363} 364#endif 365 366/* 367 * Set the constant color for a fixed function emulation program. 368 */ 369#ifndef __LP64__ 370extern void __attribute__((overloadable)) 371 rsgProgramFragmentConstantColor(rs_program_fragment pf, float r, float g, float b, float a); 372#endif 373 374/* 375 * Get the projection matrix for a currently bound fixed function 376 * vertex program. Calling this function with a custom vertex shader 377 * would result in an error. 378 * 379 * Parameters: 380 * proj matrix to store the current projection matrix into 381 */ 382#ifndef __LP64__ 383extern void __attribute__((overloadable)) 384 rsgProgramVertexGetProjectionMatrix(rs_matrix4x4* proj); 385#endif 386 387/* 388 * Load the model matrix for a currently bound fixed function 389 * vertex program. Calling this function with a custom vertex shader 390 * would result in an error. 391 * 392 * Parameters: 393 * model model matrix 394 */ 395#ifndef __LP64__ 396extern void __attribute__((overloadable)) 397 rsgProgramVertexLoadModelMatrix(const rs_matrix4x4* model); 398#endif 399 400/* 401 * Load the projection matrix for a currently bound fixed function 402 * vertex program. Calling this function with a custom vertex shader 403 * would result in an error. 404 * 405 * Parameters: 406 * proj projection matrix 407 */ 408#ifndef __LP64__ 409extern void __attribute__((overloadable)) 410 rsgProgramVertexLoadProjectionMatrix(const rs_matrix4x4* proj); 411#endif 412 413/* 414 * Load the texture matrix for a currently bound fixed function 415 * vertex program. Calling this function with a custom vertex shader 416 * would result in an error. 417 * 418 * Parameters: 419 * tex texture matrix 420 */ 421#ifndef __LP64__ 422extern void __attribute__((overloadable)) 423 rsgProgramVertexLoadTextureMatrix(const rs_matrix4x4* tex); 424#endif 425 426#endif // RENDERSCRIPT_RS_GRAPHICS_RSH 427