1 /* 2 * Copyright (C) 2007-2012 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_DEFINES_H 18 #define RENDER_SCRIPT_DEFINES_H 19 20 #include <stdint.h> 21 #include <sys/types.h> 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 ////////////////////////////////////////////////////// 28 // 29 30 typedef void * RsAsyncVoidPtr; 31 32 typedef void * RsAdapter1D; 33 typedef void * RsAdapter2D; 34 typedef void * RsAllocation; 35 typedef void * RsAnimation; 36 typedef void * RsContext; 37 typedef void * RsDevice; 38 typedef void * RsElement; 39 typedef void * RsFile; 40 typedef void * RsFont; 41 typedef void * RsSampler; 42 typedef void * RsScript; 43 typedef void * RsMesh; 44 typedef void * RsPath; 45 typedef void * RsType; 46 typedef void * RsObjectBase; 47 48 typedef void * RsProgram; 49 typedef void * RsProgramVertex; 50 typedef void * RsProgramFragment; 51 typedef void * RsProgramStore; 52 typedef void * RsProgramRaster; 53 54 typedef void * RsNativeWindow; 55 56 typedef void (* RsBitmapCallback_t)(void *); 57 58 typedef struct { 59 float m[16]; 60 } rs_matrix4x4; 61 62 typedef struct { 63 float m[9]; 64 } rs_matrix3x3; 65 66 typedef struct { 67 float m[4]; 68 } rs_matrix2x2; 69 70 enum RsDeviceParam { 71 RS_DEVICE_PARAM_FORCE_SOFTWARE_GL, 72 RS_DEVICE_PARAM_COUNT 73 }; 74 75 typedef struct { 76 uint32_t colorMin; 77 uint32_t colorPref; 78 uint32_t alphaMin; 79 uint32_t alphaPref; 80 uint32_t depthMin; 81 uint32_t depthPref; 82 uint32_t stencilMin; 83 uint32_t stencilPref; 84 uint32_t samplesMin; 85 uint32_t samplesPref; 86 float samplesQ; 87 } RsSurfaceConfig; 88 89 enum RsMessageToClientType { 90 RS_MESSAGE_TO_CLIENT_NONE = 0, 91 RS_MESSAGE_TO_CLIENT_EXCEPTION = 1, 92 RS_MESSAGE_TO_CLIENT_RESIZE = 2, 93 RS_MESSAGE_TO_CLIENT_ERROR = 3, 94 RS_MESSAGE_TO_CLIENT_USER = 4 95 }; 96 97 enum RsAllocationUsageType { 98 RS_ALLOCATION_USAGE_SCRIPT = 0x0001, 99 RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002, 100 RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004, 101 RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008, 102 RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010, 103 RS_ALLOCATION_USAGE_IO_INPUT = 0x0020, 104 RS_ALLOCATION_USAGE_IO_OUTPUT = 0x0040, 105 106 RS_ALLOCATION_USAGE_ALL = 0x00FF 107 }; 108 109 enum RsAllocationMipmapControl { 110 RS_ALLOCATION_MIPMAP_NONE = 0, 111 RS_ALLOCATION_MIPMAP_FULL = 1, 112 RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE = 2 113 }; 114 115 enum RsAllocationCubemapFace { 116 RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0, 117 RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1, 118 RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2, 119 RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3, 120 RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4, 121 RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5 122 }; 123 124 enum RsDataType { 125 RS_TYPE_NONE, 126 RS_TYPE_FLOAT_16, 127 RS_TYPE_FLOAT_32, 128 RS_TYPE_FLOAT_64, 129 RS_TYPE_SIGNED_8, 130 RS_TYPE_SIGNED_16, 131 RS_TYPE_SIGNED_32, 132 RS_TYPE_SIGNED_64, 133 RS_TYPE_UNSIGNED_8, 134 RS_TYPE_UNSIGNED_16, 135 RS_TYPE_UNSIGNED_32, 136 RS_TYPE_UNSIGNED_64, 137 138 RS_TYPE_BOOLEAN, 139 140 RS_TYPE_UNSIGNED_5_6_5, 141 RS_TYPE_UNSIGNED_5_5_5_1, 142 RS_TYPE_UNSIGNED_4_4_4_4, 143 144 RS_TYPE_MATRIX_4X4, 145 RS_TYPE_MATRIX_3X3, 146 RS_TYPE_MATRIX_2X2, 147 148 RS_TYPE_ELEMENT = 1000, 149 RS_TYPE_TYPE, 150 RS_TYPE_ALLOCATION, 151 RS_TYPE_SAMPLER, 152 RS_TYPE_SCRIPT, 153 RS_TYPE_MESH, 154 RS_TYPE_PROGRAM_FRAGMENT, 155 RS_TYPE_PROGRAM_VERTEX, 156 RS_TYPE_PROGRAM_RASTER, 157 RS_TYPE_PROGRAM_STORE, 158 RS_TYPE_FONT, 159 160 RS_TYPE_INVALID = 10000, 161 }; 162 163 enum RsDataKind { 164 RS_KIND_USER, 165 166 RS_KIND_PIXEL_L = 7, 167 RS_KIND_PIXEL_A, 168 RS_KIND_PIXEL_LA, 169 RS_KIND_PIXEL_RGB, 170 RS_KIND_PIXEL_RGBA, 171 RS_KIND_PIXEL_DEPTH, 172 173 RS_KIND_INVALID = 100, 174 }; 175 176 enum RsSamplerParam { 177 RS_SAMPLER_MIN_FILTER, 178 RS_SAMPLER_MAG_FILTER, 179 RS_SAMPLER_WRAP_S, 180 RS_SAMPLER_WRAP_T, 181 RS_SAMPLER_WRAP_R, 182 RS_SAMPLER_ANISO 183 }; 184 185 enum RsSamplerValue { 186 RS_SAMPLER_NEAREST, 187 RS_SAMPLER_LINEAR, 188 RS_SAMPLER_LINEAR_MIP_LINEAR, 189 RS_SAMPLER_WRAP, 190 RS_SAMPLER_CLAMP, 191 RS_SAMPLER_LINEAR_MIP_NEAREST, 192 193 RS_SAMPLER_INVALID = 100, 194 }; 195 196 enum RsTextureTarget { 197 RS_TEXTURE_2D, 198 RS_TEXTURE_CUBE 199 }; 200 201 enum RsDimension { 202 RS_DIMENSION_X, 203 RS_DIMENSION_Y, 204 RS_DIMENSION_Z, 205 RS_DIMENSION_LOD, 206 RS_DIMENSION_FACE, 207 208 RS_DIMENSION_ARRAY_0 = 100, 209 RS_DIMENSION_ARRAY_1, 210 RS_DIMENSION_ARRAY_2, 211 RS_DIMENSION_ARRAY_3, 212 RS_DIMENSION_MAX = RS_DIMENSION_ARRAY_3 213 }; 214 215 enum RsDepthFunc { 216 RS_DEPTH_FUNC_ALWAYS, 217 RS_DEPTH_FUNC_LESS, 218 RS_DEPTH_FUNC_LEQUAL, 219 RS_DEPTH_FUNC_GREATER, 220 RS_DEPTH_FUNC_GEQUAL, 221 RS_DEPTH_FUNC_EQUAL, 222 RS_DEPTH_FUNC_NOTEQUAL 223 }; 224 225 enum RsBlendSrcFunc { 226 RS_BLEND_SRC_ZERO, // 0 227 RS_BLEND_SRC_ONE, // 1 228 RS_BLEND_SRC_DST_COLOR, // 2 229 RS_BLEND_SRC_ONE_MINUS_DST_COLOR, // 3 230 RS_BLEND_SRC_SRC_ALPHA, // 4 231 RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA, // 5 232 RS_BLEND_SRC_DST_ALPHA, // 6 233 RS_BLEND_SRC_ONE_MINUS_DST_ALPHA, // 7 234 RS_BLEND_SRC_SRC_ALPHA_SATURATE, // 8 235 RS_BLEND_SRC_INVALID = 100, 236 }; 237 238 enum RsBlendDstFunc { 239 RS_BLEND_DST_ZERO, // 0 240 RS_BLEND_DST_ONE, // 1 241 RS_BLEND_DST_SRC_COLOR, // 2 242 RS_BLEND_DST_ONE_MINUS_SRC_COLOR, // 3 243 RS_BLEND_DST_SRC_ALPHA, // 4 244 RS_BLEND_DST_ONE_MINUS_SRC_ALPHA, // 5 245 RS_BLEND_DST_DST_ALPHA, // 6 246 RS_BLEND_DST_ONE_MINUS_DST_ALPHA, // 7 247 248 RS_BLEND_DST_INVALID = 100, 249 }; 250 251 enum RsTexEnvMode { 252 RS_TEX_ENV_MODE_NONE, 253 RS_TEX_ENV_MODE_REPLACE, 254 RS_TEX_ENV_MODE_MODULATE, 255 RS_TEX_ENV_MODE_DECAL 256 }; 257 258 enum RsProgramParam { 259 RS_PROGRAM_PARAM_INPUT, 260 RS_PROGRAM_PARAM_OUTPUT, 261 RS_PROGRAM_PARAM_CONSTANT, 262 RS_PROGRAM_PARAM_TEXTURE_TYPE, 263 }; 264 265 enum RsPrimitive { 266 RS_PRIMITIVE_POINT, 267 RS_PRIMITIVE_LINE, 268 RS_PRIMITIVE_LINE_STRIP, 269 RS_PRIMITIVE_TRIANGLE, 270 RS_PRIMITIVE_TRIANGLE_STRIP, 271 RS_PRIMITIVE_TRIANGLE_FAN, 272 273 RS_PRIMITIVE_INVALID = 100, 274 }; 275 276 enum RsPathPrimitive { 277 RS_PATH_PRIMITIVE_QUADRATIC_BEZIER, 278 RS_PATH_PRIMITIVE_CUBIC_BEZIER 279 }; 280 281 enum RsError { 282 RS_ERROR_NONE = 0, 283 RS_ERROR_BAD_SHADER = 1, 284 RS_ERROR_BAD_SCRIPT = 2, 285 RS_ERROR_BAD_VALUE = 3, 286 RS_ERROR_OUT_OF_MEMORY = 4, 287 RS_ERROR_DRIVER = 5, 288 289 RS_ERROR_FATAL_UNKNOWN = 0x1000, 290 RS_ERROR_FATAL_DRIVER = 0x1001, 291 RS_ERROR_FATAL_PROGRAM_LINK = 0x1002 292 }; 293 294 enum RsAnimationInterpolation { 295 RS_ANIMATION_INTERPOLATION_STEP, 296 RS_ANIMATION_INTERPOLATION_LINEAR, 297 RS_ANIMATION_INTERPOLATION_BEZIER, 298 RS_ANIMATION_INTERPOLATION_CARDINAL, 299 RS_ANIMATION_INTERPOLATION_HERMITE, 300 RS_ANIMATION_INTERPOLATION_BSPLINE 301 }; 302 303 enum RsAnimationEdge { 304 RS_ANIMATION_EDGE_UNDEFINED, 305 RS_ANIMATION_EDGE_CONSTANT, 306 RS_ANIMATION_EDGE_GRADIENT, 307 RS_ANIMATION_EDGE_CYCLE, 308 RS_ANIMATION_EDGE_OSCILLATE, 309 RS_ANIMATION_EDGE_CYLE_RELATIVE 310 }; 311 312 enum RsA3DClassID { 313 RS_A3D_CLASS_ID_UNKNOWN, 314 RS_A3D_CLASS_ID_MESH, 315 RS_A3D_CLASS_ID_TYPE, 316 RS_A3D_CLASS_ID_ELEMENT, 317 RS_A3D_CLASS_ID_ALLOCATION, 318 RS_A3D_CLASS_ID_PROGRAM_VERTEX, 319 RS_A3D_CLASS_ID_PROGRAM_RASTER, 320 RS_A3D_CLASS_ID_PROGRAM_FRAGMENT, 321 RS_A3D_CLASS_ID_PROGRAM_STORE, 322 RS_A3D_CLASS_ID_SAMPLER, 323 RS_A3D_CLASS_ID_ANIMATION, 324 RS_A3D_CLASS_ID_ADAPTER_1D, 325 RS_A3D_CLASS_ID_ADAPTER_2D, 326 RS_A3D_CLASS_ID_SCRIPT_C 327 }; 328 329 enum RsCullMode { 330 RS_CULL_BACK, 331 RS_CULL_FRONT, 332 RS_CULL_NONE, 333 RS_CULL_INVALID = 100, 334 }; 335 336 typedef struct { 337 RsA3DClassID classID; 338 const char* objectName; 339 } RsFileIndexEntry; 340 341 // Script to Script 342 typedef struct { 343 uint32_t xStart; 344 uint32_t xEnd; 345 uint32_t yStart; 346 uint32_t yEnd; 347 uint32_t zStart; 348 uint32_t zEnd; 349 uint32_t arrayStart; 350 uint32_t arrayEnd; 351 352 } RsScriptCall; 353 354 #ifdef __cplusplus 355 }; 356 #endif 357 358 #endif // RENDER_SCRIPT_DEFINES_H 359 360 361 362 363