1 /* 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 24 extern "C" { 25 #endif 26 27 ////////////////////////////////////////////////////// 28 // 29 30 typedef void * RsAdapter1D; 31 typedef void * RsAdapter2D; 32 typedef void * RsAllocation; 33 typedef void * RsContext; 34 typedef void * RsDevice; 35 typedef void * RsElement; 36 typedef void * RsFile; 37 typedef void * RsSampler; 38 typedef void * RsScript; 39 typedef void * RsSimpleMesh; 40 typedef void * RsType; 41 typedef void * RsLight; 42 43 typedef void * RsProgram; 44 typedef void * RsProgramVertex; 45 typedef void * RsProgramFragment; 46 typedef void * RsProgramFragmentStore; 47 typedef void * RsProgramRaster; 48 49 typedef void (* RsBitmapCallback_t)(void *); 50 51 enum RsDeviceParam { 52 RS_DEVICE_PARAM_FORCE_SOFTWARE_GL, 53 RS_DEVICE_PARAM_COUNT 54 }; 55 56 RsDevice rsDeviceCreate(); 57 void rsDeviceDestroy(RsDevice); 58 void rsDeviceSetConfig(RsDevice, RsDeviceParam, int32_t value); 59 60 RsContext rsContextCreate(RsDevice, uint32_t version); 61 RsContext rsContextCreateGL(RsDevice, uint32_t version, bool useDepth); 62 void rsContextDestroy(RsContext); 63 void rsObjDestroyOOB(RsContext, void *); 64 65 uint32_t rsContextGetMessage(RsContext, void *data, size_t *receiveLen, size_t bufferLen, bool wait); 66 void rsContextInitToClient(RsContext); 67 void rsContextDeinitToClient(RsContext); 68 69 #define RS_MAX_TEXTURE 2 70 #define RS_MAX_ATTRIBS 16 71 72 enum RsDataType { 73 RS_TYPE_NONE, 74 RS_TYPE_FLOAT_16, 75 RS_TYPE_FLOAT_32, 76 RS_TYPE_FLOAT_64, 77 RS_TYPE_SIGNED_8, 78 RS_TYPE_SIGNED_16, 79 RS_TYPE_SIGNED_32, 80 RS_TYPE_SIGNED_64, 81 RS_TYPE_UNSIGNED_8, 82 RS_TYPE_UNSIGNED_16, 83 RS_TYPE_UNSIGNED_32, 84 RS_TYPE_UNSIGNED_64, 85 86 RS_TYPE_UNSIGNED_5_6_5, 87 RS_TYPE_UNSIGNED_5_5_5_1, 88 RS_TYPE_UNSIGNED_4_4_4_4, 89 90 RS_TYPE_ELEMENT, 91 RS_TYPE_TYPE, 92 RS_TYPE_ALLOCATION, 93 RS_TYPE_SAMPLER, 94 RS_TYPE_SCRIPT, 95 RS_TYPE_MESH, 96 RS_TYPE_PROGRAM_FRAGMENT, 97 RS_TYPE_PROGRAM_VERTEX, 98 RS_TYPE_PROGRAM_RASTER, 99 RS_TYPE_PROGRAM_STORE 100 }; 101 102 enum RsDataKind { 103 RS_KIND_USER, 104 RS_KIND_COLOR, 105 RS_KIND_POSITION, 106 RS_KIND_TEXTURE, 107 RS_KIND_NORMAL, 108 RS_KIND_INDEX, 109 RS_KIND_POINT_SIZE, 110 111 RS_KIND_PIXEL_L, 112 RS_KIND_PIXEL_A, 113 RS_KIND_PIXEL_LA, 114 RS_KIND_PIXEL_RGB, 115 RS_KIND_PIXEL_RGBA, 116 117 }; 118 119 enum RsSamplerParam { 120 RS_SAMPLER_MIN_FILTER, 121 RS_SAMPLER_MAG_FILTER, 122 RS_SAMPLER_WRAP_S, 123 RS_SAMPLER_WRAP_T, 124 RS_SAMPLER_WRAP_R 125 }; 126 127 enum RsSamplerValue { 128 RS_SAMPLER_NEAREST, 129 RS_SAMPLER_LINEAR, 130 RS_SAMPLER_LINEAR_MIP_LINEAR, 131 RS_SAMPLER_WRAP, 132 RS_SAMPLER_CLAMP 133 }; 134 135 enum RsDimension { 136 RS_DIMENSION_X, 137 RS_DIMENSION_Y, 138 RS_DIMENSION_Z, 139 RS_DIMENSION_LOD, 140 RS_DIMENSION_FACE, 141 142 RS_DIMENSION_ARRAY_0 = 100, 143 RS_DIMENSION_ARRAY_1, 144 RS_DIMENSION_ARRAY_2, 145 RS_DIMENSION_ARRAY_3, 146 RS_DIMENSION_MAX = RS_DIMENSION_ARRAY_3 147 }; 148 149 enum RsDepthFunc { 150 RS_DEPTH_FUNC_ALWAYS, 151 RS_DEPTH_FUNC_LESS, 152 RS_DEPTH_FUNC_LEQUAL, 153 RS_DEPTH_FUNC_GREATER, 154 RS_DEPTH_FUNC_GEQUAL, 155 RS_DEPTH_FUNC_EQUAL, 156 RS_DEPTH_FUNC_NOTEQUAL 157 }; 158 159 enum RsBlendSrcFunc { 160 RS_BLEND_SRC_ZERO, // 0 161 RS_BLEND_SRC_ONE, // 1 162 RS_BLEND_SRC_DST_COLOR, // 2 163 RS_BLEND_SRC_ONE_MINUS_DST_COLOR, // 3 164 RS_BLEND_SRC_SRC_ALPHA, // 4 165 RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA, // 5 166 RS_BLEND_SRC_DST_ALPHA, // 6 167 RS_BLEND_SRC_ONE_MINUS_DST_ALPHA, // 7 168 RS_BLEND_SRC_SRC_ALPHA_SATURATE // 8 169 }; 170 171 enum RsBlendDstFunc { 172 RS_BLEND_DST_ZERO, // 0 173 RS_BLEND_DST_ONE, // 1 174 RS_BLEND_DST_SRC_COLOR, // 2 175 RS_BLEND_DST_ONE_MINUS_SRC_COLOR, // 3 176 RS_BLEND_DST_SRC_ALPHA, // 4 177 RS_BLEND_DST_ONE_MINUS_SRC_ALPHA, // 5 178 RS_BLEND_DST_DST_ALPHA, // 6 179 RS_BLEND_DST_ONE_MINUS_DST_ALPHA // 7 180 }; 181 182 enum RsTexEnvMode { 183 RS_TEX_ENV_MODE_NONE, 184 RS_TEX_ENV_MODE_REPLACE, 185 RS_TEX_ENV_MODE_MODULATE, 186 RS_TEX_ENV_MODE_DECAL 187 }; 188 189 enum RsProgramParam { 190 RS_PROGRAM_PARAM_INPUT, 191 RS_PROGRAM_PARAM_OUTPUT, 192 RS_PROGRAM_PARAM_CONSTANT, 193 RS_PROGRAM_PARAM_TEXTURE_COUNT, 194 }; 195 196 enum RsPrimitive { 197 RS_PRIMITIVE_POINT, 198 RS_PRIMITIVE_LINE, 199 RS_PRIMITIVE_LINE_STRIP, 200 RS_PRIMITIVE_TRIANGLE, 201 RS_PRIMITIVE_TRIANGLE_STRIP, 202 RS_PRIMITIVE_TRIANGLE_FAN 203 }; 204 205 enum RsError { 206 RS_ERROR_NONE, 207 RS_ERROR_BAD_SHADER, 208 RS_ERROR_BAD_SCRIPT 209 }; 210 211 #ifndef NO_RS_FUNCS 212 #include "rsgApiFuncDecl.h" 213 #endif 214 215 #ifdef __cplusplus 216 }; 217 #endif 218 219 #endif // RENDER_SCRIPT_H 220 221 222 223