blob: 5e246ce5c7e832062443eabb8a1bf5ecb534887a [file] [log] [blame]
Jason Sams326e0dd2009-05-22 14:03:28 -07001/*
2 * Copyright (C) 2007 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#ifndef RENDER_SCRIPT_H
18#define RENDER_SCRIPT_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27//////////////////////////////////////////////////////
Jason Samse5ffb872009-08-09 17:01:55 -070028//
Jason Sams326e0dd2009-05-22 14:03:28 -070029
30typedef void * RsAdapter1D;
31typedef void * RsAdapter2D;
32typedef void * RsAllocation;
Jason Samsc1ed5892010-03-10 17:30:41 -080033typedef void * RsAnimation;
Jason Sams326e0dd2009-05-22 14:03:28 -070034typedef void * RsContext;
35typedef void * RsDevice;
36typedef void * RsElement;
Jason Samsa5597fc2009-07-08 18:01:53 -070037typedef void * RsFile;
Jason Sams326e0dd2009-05-22 14:03:28 -070038typedef void * RsSampler;
39typedef void * RsScript;
Jason Samse5ffb872009-08-09 17:01:55 -070040typedef void * RsSimpleMesh;
Jason Sams326e0dd2009-05-22 14:03:28 -070041typedef void * RsType;
Jason Sams62bc1db2009-06-22 15:49:21 -070042typedef void * RsLight;
Jason Sams326e0dd2009-05-22 14:03:28 -070043
Jason Sams4815c0d2009-12-15 12:58:36 -080044typedef void * RsProgram;
Jason Sams326e0dd2009-05-22 14:03:28 -070045typedef void * RsProgramVertex;
46typedef void * RsProgramFragment;
Jason Samsccc010b2010-05-13 18:30:11 -070047typedef void * RsProgramStore;
Jason Sams5fd09d82009-09-23 13:57:02 -070048typedef void * RsProgramRaster;
49
Jason Samsfa84da22010-03-01 15:31:04 -080050typedef void (* RsBitmapCallback_t)(void *);
51
Jason Sams5fd09d82009-09-23 13:57:02 -070052enum RsDeviceParam {
53 RS_DEVICE_PARAM_FORCE_SOFTWARE_GL,
54 RS_DEVICE_PARAM_COUNT
55};
Jason Sams326e0dd2009-05-22 14:03:28 -070056
57RsDevice rsDeviceCreate();
58void rsDeviceDestroy(RsDevice);
Jason Sams5fd09d82009-09-23 13:57:02 -070059void rsDeviceSetConfig(RsDevice, RsDeviceParam, int32_t value);
Jason Sams326e0dd2009-05-22 14:03:28 -070060
Jason Sams4820e8b2010-02-09 16:05:07 -080061RsContext rsContextCreate(RsDevice, uint32_t version);
62RsContext rsContextCreateGL(RsDevice, uint32_t version, bool useDepth);
Jason Sams326e0dd2009-05-22 14:03:28 -070063void rsContextDestroy(RsContext);
Jason Sams50869382009-08-18 17:07:09 -070064void rsObjDestroyOOB(RsContext, void *);
Jason Sams326e0dd2009-05-22 14:03:28 -070065
Jason Sams8c401ef2009-10-06 13:58:47 -070066uint32_t rsContextGetMessage(RsContext, void *data, size_t *receiveLen, size_t bufferLen, bool wait);
67void rsContextInitToClient(RsContext);
68void rsContextDeinitToClient(RsContext);
69
Jason Samse5ffb872009-08-09 17:01:55 -070070#define RS_MAX_TEXTURE 2
Jason Sams433eca32010-01-06 11:57:52 -080071#define RS_MAX_ATTRIBS 16
Jason Samse5ffb872009-08-09 17:01:55 -070072
Jason Sams326e0dd2009-05-22 14:03:28 -070073enum RsDataType {
Jason Samsd01d9702009-12-23 14:35:29 -080074 RS_TYPE_NONE,
75 RS_TYPE_FLOAT_16,
76 RS_TYPE_FLOAT_32,
77 RS_TYPE_FLOAT_64,
78 RS_TYPE_SIGNED_8,
79 RS_TYPE_SIGNED_16,
80 RS_TYPE_SIGNED_32,
81 RS_TYPE_SIGNED_64,
82 RS_TYPE_UNSIGNED_8,
83 RS_TYPE_UNSIGNED_16,
84 RS_TYPE_UNSIGNED_32,
85 RS_TYPE_UNSIGNED_64,
86
87 RS_TYPE_UNSIGNED_5_6_5,
88 RS_TYPE_UNSIGNED_5_5_5_1,
89 RS_TYPE_UNSIGNED_4_4_4_4,
90
91 RS_TYPE_ELEMENT,
92 RS_TYPE_TYPE,
93 RS_TYPE_ALLOCATION,
94 RS_TYPE_SAMPLER,
95 RS_TYPE_SCRIPT,
96 RS_TYPE_MESH,
97 RS_TYPE_PROGRAM_FRAGMENT,
98 RS_TYPE_PROGRAM_VERTEX,
99 RS_TYPE_PROGRAM_RASTER,
100 RS_TYPE_PROGRAM_STORE
Jason Sams326e0dd2009-05-22 14:03:28 -0700101};
102
103enum RsDataKind {
104 RS_KIND_USER,
Jason Samsd01d9702009-12-23 14:35:29 -0800105 RS_KIND_COLOR,
106 RS_KIND_POSITION,
107 RS_KIND_TEXTURE,
108 RS_KIND_NORMAL,
Jason Samse0158412009-08-20 16:10:36 -0700109 RS_KIND_INDEX,
Jason Samsd01d9702009-12-23 14:35:29 -0800110 RS_KIND_POINT_SIZE,
111
112 RS_KIND_PIXEL_L,
113 RS_KIND_PIXEL_A,
114 RS_KIND_PIXEL_LA,
115 RS_KIND_PIXEL_RGB,
116 RS_KIND_PIXEL_RGBA,
117
Jason Sams326e0dd2009-05-22 14:03:28 -0700118};
119
Jason Sams326e0dd2009-05-22 14:03:28 -0700120enum RsSamplerParam {
121 RS_SAMPLER_MIN_FILTER,
122 RS_SAMPLER_MAG_FILTER,
123 RS_SAMPLER_WRAP_S,
124 RS_SAMPLER_WRAP_T,
125 RS_SAMPLER_WRAP_R
Jason Samse5ffb872009-08-09 17:01:55 -0700126};
Jason Sams326e0dd2009-05-22 14:03:28 -0700127
128enum RsSamplerValue {
129 RS_SAMPLER_NEAREST,
130 RS_SAMPLER_LINEAR,
131 RS_SAMPLER_LINEAR_MIP_LINEAR,
132 RS_SAMPLER_WRAP,
133 RS_SAMPLER_CLAMP
Jason Samse5ffb872009-08-09 17:01:55 -0700134};
Jason Sams326e0dd2009-05-22 14:03:28 -0700135
136enum RsDimension {
137 RS_DIMENSION_X,
138 RS_DIMENSION_Y,
139 RS_DIMENSION_Z,
140 RS_DIMENSION_LOD,
141 RS_DIMENSION_FACE,
142
Jason Samse5ffb872009-08-09 17:01:55 -0700143 RS_DIMENSION_ARRAY_0 = 100,
144 RS_DIMENSION_ARRAY_1,
145 RS_DIMENSION_ARRAY_2,
Jason Sams326e0dd2009-05-22 14:03:28 -0700146 RS_DIMENSION_ARRAY_3,
147 RS_DIMENSION_MAX = RS_DIMENSION_ARRAY_3
148};
149
150enum RsDepthFunc {
151 RS_DEPTH_FUNC_ALWAYS,
152 RS_DEPTH_FUNC_LESS,
153 RS_DEPTH_FUNC_LEQUAL,
154 RS_DEPTH_FUNC_GREATER,
155 RS_DEPTH_FUNC_GEQUAL,
156 RS_DEPTH_FUNC_EQUAL,
157 RS_DEPTH_FUNC_NOTEQUAL
158};
159
160enum RsBlendSrcFunc {
Jason Samsc9d43db2009-07-28 12:02:16 -0700161 RS_BLEND_SRC_ZERO, // 0
162 RS_BLEND_SRC_ONE, // 1
163 RS_BLEND_SRC_DST_COLOR, // 2
164 RS_BLEND_SRC_ONE_MINUS_DST_COLOR, // 3
165 RS_BLEND_SRC_SRC_ALPHA, // 4
166 RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA, // 5
167 RS_BLEND_SRC_DST_ALPHA, // 6
168 RS_BLEND_SRC_ONE_MINUS_DST_ALPHA, // 7
169 RS_BLEND_SRC_SRC_ALPHA_SATURATE // 8
Jason Sams326e0dd2009-05-22 14:03:28 -0700170};
171
172enum RsBlendDstFunc {
Jason Samsc9d43db2009-07-28 12:02:16 -0700173 RS_BLEND_DST_ZERO, // 0
174 RS_BLEND_DST_ONE, // 1
175 RS_BLEND_DST_SRC_COLOR, // 2
176 RS_BLEND_DST_ONE_MINUS_SRC_COLOR, // 3
177 RS_BLEND_DST_SRC_ALPHA, // 4
178 RS_BLEND_DST_ONE_MINUS_SRC_ALPHA, // 5
179 RS_BLEND_DST_DST_ALPHA, // 6
180 RS_BLEND_DST_ONE_MINUS_DST_ALPHA // 7
Jason Sams326e0dd2009-05-22 14:03:28 -0700181};
182
183enum RsTexEnvMode {
Jason Sams7dad9c32009-12-17 16:55:08 -0800184 RS_TEX_ENV_MODE_NONE,
Jason Sams326e0dd2009-05-22 14:03:28 -0700185 RS_TEX_ENV_MODE_REPLACE,
186 RS_TEX_ENV_MODE_MODULATE,
187 RS_TEX_ENV_MODE_DECAL
188};
189
Jason Sams4815c0d2009-12-15 12:58:36 -0800190enum RsProgramParam {
191 RS_PROGRAM_PARAM_INPUT,
192 RS_PROGRAM_PARAM_OUTPUT,
193 RS_PROGRAM_PARAM_CONSTANT,
Jason Samsf2e4fa22009-12-15 13:27:04 -0800194 RS_PROGRAM_PARAM_TEXTURE_COUNT,
Jason Sams4815c0d2009-12-15 12:58:36 -0800195};
196
Jason Samsa89371c2009-06-30 14:13:04 -0700197enum RsPrimitive {
198 RS_PRIMITIVE_POINT,
199 RS_PRIMITIVE_LINE,
200 RS_PRIMITIVE_LINE_STRIP,
201 RS_PRIMITIVE_TRIANGLE,
202 RS_PRIMITIVE_TRIANGLE_STRIP,
203 RS_PRIMITIVE_TRIANGLE_FAN
204};
Jason Sams326e0dd2009-05-22 14:03:28 -0700205
Jason Samsa2cf7552010-03-03 13:03:18 -0800206enum RsError {
207 RS_ERROR_NONE,
208 RS_ERROR_BAD_SHADER,
Jason Samsc1ed5892010-03-10 17:30:41 -0800209 RS_ERROR_BAD_SCRIPT,
210 RS_ERROR_BAD_VALUE,
211 RS_ERROR_OUT_OF_MEMORY
212};
213
214enum RsAnimationInterpolation {
215 RS_ANIMATION_INTERPOLATION_STEP,
216 RS_ANIMATION_INTERPOLATION_LINEAR,
217 RS_ANIMATION_INTERPOLATION_BEZIER,
218 RS_ANIMATION_INTERPOLATION_CARDINAL,
219 RS_ANIMATION_INTERPOLATION_HERMITE,
220 RS_ANIMATION_INTERPOLATION_BSPLINE
221};
222
223enum RsAnimationEdge {
224 RS_ANIMATION_EDGE_UNDEFINED,
225 RS_ANIMATION_EDGE_CONSTANT,
226 RS_ANIMATION_EDGE_GRADIENT,
227 RS_ANIMATION_EDGE_CYCLE,
228 RS_ANIMATION_EDGE_OSCILLATE,
229 RS_ANIMATION_EDGE_CYLE_RELATIVE
Jason Samsa2cf7552010-03-03 13:03:18 -0800230};
231
Jason Sams4e17e0e2010-02-23 15:27:51 -0800232#ifndef NO_RS_FUNCS
Jason Sams326e0dd2009-05-22 14:03:28 -0700233#include "rsgApiFuncDecl.h"
Jason Sams4e17e0e2010-02-23 15:27:51 -0800234#endif
Jason Sams326e0dd2009-05-22 14:03:28 -0700235
236#ifdef __cplusplus
237};
238#endif
239
240#endif // RENDER_SCRIPT_H
241
242
243