blob: 9a8a4e66a03d23c654d07d1513cef12e66ec1bf0 [file] [log] [blame]
Jason Sams1b937f52010-06-09 14:26:16 -07001#ifndef __RS_GRAPHICS_RSH__
2#define __RS_GRAPHICS_RSH__
3
Alex Sakhartchouk7d9c5ff2011-04-01 14:19:01 -07004/**
5 * Set the color target used for all subsequent rendering calls
6 * @param colorTarget
7 * @param slot
8 */
9extern void __attribute__((overloadable))
10 rsgBindColorTarget(rs_allocation colorTarget, uint slot);
11
12/**
13 * Clear the previously set color target
14 * @param slot
15 */
16extern void __attribute__((overloadable))
17 rsgClearColorTarget(uint slot);
18
19/**
20 * Set the depth target used for all subsequent rendering calls
21 * @param depthTarget
22 */
23extern void __attribute__((overloadable))
24 rsgBindDepthTarget(rs_allocation depthTarget);
25
26/**
27 * Clear the previously set depth target
28 */
29extern void __attribute__((overloadable))
30 rsgClearDepthTarget(void);
31
32/**
33 * Clear all color and depth targets and resume rendering into
34 * the framebuffer
35 */
36extern void __attribute__((overloadable))
37 rsgClearAllRenderTargets(void);
38
39/**
40 * Force RenderScript to finish all rendering commands
41 */
42extern uint __attribute__((overloadable))
43 rsgFinish(void);
Jason Samsf2bcce72010-03-26 15:33:42 -070044
Jason Sams09aeb8a2011-01-28 15:49:07 -080045/**
46 * Bind a new ProgramFragment to the rendering context.
47 *
48 * @param pf
49 */
50extern void __attribute__((overloadable))
51 rsgBindProgramFragment(rs_program_fragment pf);
52
53/**
54 * Bind a new ProgramStore to the rendering context.
55 *
56 * @param ps
57 */
58extern void __attribute__((overloadable))
59 rsgBindProgramStore(rs_program_store ps);
60
61/**
62 * Bind a new ProgramVertex to the rendering context.
63 *
64 * @param pv
65 */
66extern void __attribute__((overloadable))
67 rsgBindProgramVertex(rs_program_vertex pv);
68
69/**
70 * Bind a new ProgramRaster to the rendering context.
71 *
72 * @param pr
73 */
74extern void __attribute__((overloadable))
75 rsgBindProgramRaster(rs_program_raster pr);
76
77/**
78 * Bind a new Sampler object to a ProgramFragment. The sampler will
79 * operate on the texture bound at the matching slot.
80 *
81 * @param slot
82 */
Jason Sams73495472010-07-29 17:31:14 -070083extern void __attribute__((overloadable))
84 rsgBindSampler(rs_program_fragment, uint slot, rs_sampler);
Jason Sams09aeb8a2011-01-28 15:49:07 -080085
86/**
87 * Bind a new Allocation object to a ProgramFragment. The
88 * Allocation must be a valid texture for the Program. The sampling
89 * of the texture will be controled by the Sampler bound at the
90 * matching slot.
91 *
92 * @param slot
93 */
Jason Sams73495472010-07-29 17:31:14 -070094extern void __attribute__((overloadable))
95 rsgBindTexture(rs_program_fragment, uint slot, rs_allocation);
Jason Sams51f36ab2010-03-18 14:36:05 -070096
Jason Sams09aeb8a2011-01-28 15:49:07 -080097
Jason Sams73495472010-07-29 17:31:14 -070098extern void __attribute__((overloadable))
99 rsgProgramVertexLoadProjectionMatrix(const rs_matrix4x4 *);
100extern void __attribute__((overloadable))
101 rsgProgramVertexLoadModelMatrix(const rs_matrix4x4 *);
102extern void __attribute__((overloadable))
103 rsgProgramVertexLoadTextureMatrix(const rs_matrix4x4 *);
Jason Sams51f36ab2010-03-18 14:36:05 -0700104
Jason Sams6445e522010-08-04 17:50:20 -0700105extern void __attribute__((overloadable))
Alex Sakhartchouk95333f92010-08-16 17:40:10 -0700106 rsgProgramVertexGetProjectionMatrix(rs_matrix4x4 *);
107
Jason Sams09aeb8a2011-01-28 15:49:07 -0800108/**
109 * Set the constant color for a fixed function emulation program.
110 *
111 * @param pf
112 * @param r
113 * @param g
114 * @param b
115 * @param a
116 */
Alex Sakhartchouk95333f92010-08-16 17:40:10 -0700117extern void __attribute__((overloadable))
Jason Sams09aeb8a2011-01-28 15:49:07 -0800118 rsgProgramFragmentConstantColor(rs_program_fragment pf, float r, float g, float b, float a);
Jason Sams6445e522010-08-04 17:50:20 -0700119
Jason Sams09aeb8a2011-01-28 15:49:07 -0800120/**
121 * Get the width of the current rendering surface.
122 *
123 * @return uint
124 */
Jason Sams73495472010-07-29 17:31:14 -0700125extern uint __attribute__((overloadable))
126 rsgGetWidth(void);
Jason Sams09aeb8a2011-01-28 15:49:07 -0800127
128/**
129 * Get the height of the current rendering surface.
130 *
131 * @return uint
132 */
Jason Sams73495472010-07-29 17:31:14 -0700133extern uint __attribute__((overloadable))
134 rsgGetHeight(void);
Jason Sams51f36ab2010-03-18 14:36:05 -0700135
Jason Samsb7e83bd2010-12-15 01:41:00 -0800136
Jason Sams09aeb8a2011-01-28 15:49:07 -0800137/**
138 * Sync the contents of an allocation from its SCRIPT memory space to its HW
139 * memory spaces.
140 *
141 * @param alloc
142 */
143extern void __attribute__((overloadable))
144 rsgAllocationSyncAll(rs_allocation alloc);
145
146/**
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700147 * Sync the contents of an allocation from memory space
148 * specified by source.
149 *
150 * @param alloc
151 * @param source
152 */
153extern void __attribute__((overloadable))
154 rsgAllocationSyncAll(rs_allocation alloc,
155 rs_allocation_usage_type source);
156
157/**
Jason Sams09aeb8a2011-01-28 15:49:07 -0800158 * Low performance utility function for drawing a simple rectangle. Not
159 * intended for drawing large quantities of geometry.
160 *
161 * @param x1
162 * @param y1
163 * @param x2
164 * @param y2
165 * @param z
166 */
Jason Samsb7e83bd2010-12-15 01:41:00 -0800167extern void __attribute__((overloadable))
Jason Sams73495472010-07-29 17:31:14 -0700168 rsgDrawRect(float x1, float y1, float x2, float y2, float z);
Jason Sams09aeb8a2011-01-28 15:49:07 -0800169
170/**
171 * Low performance utility function for drawing a simple quad. Not intended for
172 * drawing large quantities of geometry.
173 *
174 * @param x1
175 * @param y1
176 * @param z1
177 * @param x2
178 * @param y2
179 * @param z2
180 * @param x3
181 * @param y3
182 * @param z3
183 * @param x4
184 * @param y4
185 * @param z4
186 */
Jason Sams73495472010-07-29 17:31:14 -0700187extern void __attribute__((overloadable))
188 rsgDrawQuad(float x1, float y1, float z1,
189 float x2, float y2, float z2,
190 float x3, float y3, float z3,
191 float x4, float y4, float z4);
Jason Sams09aeb8a2011-01-28 15:49:07 -0800192
193
194/**
195 * Low performance utility function for drawing a textured quad. Not intended
196 * for drawing large quantities of geometry.
197 *
198 * @param x1
199 * @param y1
200 * @param z1
201 * @param u1
202 * @param v1
203 * @param x2
204 * @param y2
205 * @param z2
206 * @param u2
207 * @param v2
208 * @param x3
209 * @param y3
210 * @param z3
211 * @param u3
212 * @param v3
213 * @param x4
214 * @param y4
215 * @param z4
216 * @param u4
217 * @param v4
218 */
Jason Sams73495472010-07-29 17:31:14 -0700219extern void __attribute__((overloadable))
220 rsgDrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
221 float x2, float y2, float z2, float u2, float v2,
222 float x3, float y3, float z3, float u3, float v3,
223 float x4, float y4, float z4, float u4, float v4);
Jason Sams09aeb8a2011-01-28 15:49:07 -0800224
225
226/**
227 * Low performance function for drawing rectangles in screenspace. This
228 * function uses the default passthough ProgramVertex. Any bound ProgramVertex
229 * is ignored. This function has considerable overhead and should not be used
230 * for drawing in shipping applications.
231 *
232 * @param x
233 * @param y
234 * @param z
235 * @param w
236 * @param h
237 */
Jason Sams73495472010-07-29 17:31:14 -0700238extern void __attribute__((overloadable))
239 rsgDrawSpriteScreenspace(float x, float y, float z, float w, float h);
Jason Sams51f36ab2010-03-18 14:36:05 -0700240
Jason Sams09aeb8a2011-01-28 15:49:07 -0800241/**
242 * Draw a mesh of geometry using the current context state. The whole mesh is
243 * rendered.
244 *
245 * @param ism
246 */
Jason Sams73495472010-07-29 17:31:14 -0700247extern void __attribute__((overloadable))
248 rsgDrawMesh(rs_mesh ism);
249extern void __attribute__((overloadable))
250 rsgDrawMesh(rs_mesh ism, uint primitiveIndex);
251extern void __attribute__((overloadable))
252 rsgDrawMesh(rs_mesh ism, uint primitiveIndex, uint start, uint len);
Alex Sakhartchouk4e9a7a82010-07-01 16:14:06 -0700253
Jason Sams09aeb8a2011-01-28 15:49:07 -0800254/**
255 * Clears the rendering surface to the specified color.
256 *
257 * @param r
258 * @param g
259 * @param b
260 * @param a
261 */
Jason Sams73495472010-07-29 17:31:14 -0700262extern void __attribute__((overloadable))
Jason Sams09aeb8a2011-01-28 15:49:07 -0800263 rsgClearColor(float r, float g, float b, float a);
264
265/**
266 * Clears the depth suface to the specified value.
267 *
268 */
Jason Sams73495472010-07-29 17:31:14 -0700269extern void __attribute__((overloadable))
Jason Sams09aeb8a2011-01-28 15:49:07 -0800270 rsgClearDepth(float value);
Jason Sams51f36ab2010-03-18 14:36:05 -0700271
Jason Sams73495472010-07-29 17:31:14 -0700272extern void __attribute__((overloadable))
273 rsgDrawText(const char *, int x, int y);
274extern void __attribute__((overloadable))
275 rsgDrawText(rs_allocation, int x, int y);
276extern void __attribute__((overloadable))
277 rsgBindFont(rs_font);
Alex Sakhartchouk9fc9f032010-08-04 14:45:48 -0700278extern void __attribute__((overloadable))
279 rsgFontColor(float, float, float, float);
Alex Sakhartchouk09c67352010-10-05 11:33:27 -0700280// Returns the bounding box of the text relative to (0, 0)
281// Any of left, right, top, bottom could be NULL
282extern void __attribute__((overloadable))
283 rsgMeasureText(const char *, int *left, int *right, int *top, int *bottom);
284extern void __attribute__((overloadable))
285 rsgMeasureText(rs_allocation, int *left, int *right, int *top, int *bottom);
Alex Sakhartchoukd3e0ad42010-06-24 17:15:34 -0700286
Alex Sakhartchoukba4aa5c2010-08-13 14:32:23 -0700287extern void __attribute__((overloadable))
288 rsgMeshComputeBoundingBox(rs_mesh mesh, float *minX, float *minY, float *minZ,
289 float *maxX, float *maxY, float *maxZ);
Jason Sams399dc9e2010-10-15 17:57:07 -0700290__inline__ static void __attribute__((overloadable, always_inline))
Alex Sakhartchoukba4aa5c2010-08-13 14:32:23 -0700291rsgMeshComputeBoundingBox(rs_mesh mesh, float3 *bBoxMin, float3 *bBoxMax) {
292 float x1, y1, z1, x2, y2, z2;
293 rsgMeshComputeBoundingBox(mesh, &x1, &y1, &z1, &x2, &y2, &z2);
294 bBoxMin->x = x1;
295 bBoxMin->y = y1;
296 bBoxMin->z = z1;
297 bBoxMax->x = x2;
298 bBoxMax->y = y2;
299 bBoxMax->z = z2;
300}
301
Jason Sams1b937f52010-06-09 14:26:16 -0700302#endif
Jason Sams51f36ab2010-03-18 14:36:05 -0700303