Home | History | Annotate | Download | only in rs
      1 /*
      2  * Copyright (C) 2013 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 * RsScriptKernelID;
     44 typedef void * RsScriptFieldID;
     45 typedef void * RsScriptMethodID;
     46 typedef void * RsScriptGroup;
     47 typedef void * RsMesh;
     48 typedef void * RsPath;
     49 typedef void * RsType;
     50 typedef void * RsObjectBase;
     51 
     52 typedef void * RsProgram;
     53 typedef void * RsProgramVertex;
     54 typedef void * RsProgramFragment;
     55 typedef void * RsProgramStore;
     56 typedef void * RsProgramRaster;
     57 
     58 typedef void * RsNativeWindow;
     59 
     60 typedef void (* RsBitmapCallback_t)(void *);
     61 
     62 typedef struct {
     63     float m[16];
     64 } rs_matrix4x4;
     65 
     66 typedef struct {
     67     float m[9];
     68 } rs_matrix3x3;
     69 
     70 typedef struct {
     71     float m[4];
     72 } rs_matrix2x2;
     73 
     74 enum RsDeviceParam {
     75     RS_DEVICE_PARAM_FORCE_SOFTWARE_GL,
     76     RS_DEVICE_PARAM_COUNT
     77 };
     78 
     79 enum RsContextType {
     80     RS_CONTEXT_TYPE_NORMAL,
     81     RS_CONTEXT_TYPE_DEBUG,
     82     RS_CONTEXT_TYPE_PROFILE
     83 };
     84 
     85 typedef struct {
     86     uint32_t colorMin;
     87     uint32_t colorPref;
     88     uint32_t alphaMin;
     89     uint32_t alphaPref;
     90     uint32_t depthMin;
     91     uint32_t depthPref;
     92     uint32_t stencilMin;
     93     uint32_t stencilPref;
     94     uint32_t samplesMin;
     95     uint32_t samplesPref;
     96     float samplesQ;
     97 } RsSurfaceConfig;
     98 
     99 enum RsMessageToClientType {
    100     RS_MESSAGE_TO_CLIENT_NONE = 0,
    101     RS_MESSAGE_TO_CLIENT_EXCEPTION = 1,
    102     RS_MESSAGE_TO_CLIENT_RESIZE = 2,
    103     RS_MESSAGE_TO_CLIENT_ERROR = 3,
    104     RS_MESSAGE_TO_CLIENT_USER = 4,
    105     RS_MESSAGE_TO_CLIENT_NEW_BUFFER = 5
    106 };
    107 
    108 enum RsAllocationUsageType {
    109     RS_ALLOCATION_USAGE_SCRIPT = 0x0001,
    110     RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002,
    111     RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004,
    112     RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008,
    113     RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010,
    114     RS_ALLOCATION_USAGE_IO_INPUT = 0x0020,
    115     RS_ALLOCATION_USAGE_IO_OUTPUT = 0x0040,
    116     RS_ALLOCATION_USAGE_SHARED = 0x0080,
    117 
    118     RS_ALLOCATION_USAGE_ALL = 0x00FF
    119 };
    120 
    121 enum RsAllocationMipmapControl {
    122     RS_ALLOCATION_MIPMAP_NONE = 0,
    123     RS_ALLOCATION_MIPMAP_FULL = 1,
    124     RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE = 2
    125 };
    126 
    127 enum RsAllocationCubemapFace {
    128     RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0,
    129     RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1,
    130     RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2,
    131     RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3,
    132     RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4,
    133     RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5
    134 };
    135 
    136 enum RsDataType {
    137     RS_TYPE_NONE,
    138     RS_TYPE_FLOAT_16,
    139     RS_TYPE_FLOAT_32,
    140     RS_TYPE_FLOAT_64,
    141     RS_TYPE_SIGNED_8,
    142     RS_TYPE_SIGNED_16,
    143     RS_TYPE_SIGNED_32,
    144     RS_TYPE_SIGNED_64,
    145     RS_TYPE_UNSIGNED_8,
    146     RS_TYPE_UNSIGNED_16,
    147     RS_TYPE_UNSIGNED_32,
    148     RS_TYPE_UNSIGNED_64,
    149 
    150     RS_TYPE_BOOLEAN,
    151 
    152     RS_TYPE_UNSIGNED_5_6_5,
    153     RS_TYPE_UNSIGNED_5_5_5_1,
    154     RS_TYPE_UNSIGNED_4_4_4_4,
    155 
    156     RS_TYPE_MATRIX_4X4,
    157     RS_TYPE_MATRIX_3X3,
    158     RS_TYPE_MATRIX_2X2,
    159 
    160     RS_TYPE_ELEMENT = 1000,
    161     RS_TYPE_TYPE,
    162     RS_TYPE_ALLOCATION,
    163     RS_TYPE_SAMPLER,
    164     RS_TYPE_SCRIPT,
    165     RS_TYPE_MESH,
    166     RS_TYPE_PROGRAM_FRAGMENT,
    167     RS_TYPE_PROGRAM_VERTEX,
    168     RS_TYPE_PROGRAM_RASTER,
    169     RS_TYPE_PROGRAM_STORE,
    170     RS_TYPE_FONT,
    171 
    172     RS_TYPE_INVALID = 10000,
    173 };
    174 
    175 enum RsDataKind {
    176     RS_KIND_USER,
    177 
    178     RS_KIND_PIXEL_L = 7,
    179     RS_KIND_PIXEL_A,
    180     RS_KIND_PIXEL_LA,
    181     RS_KIND_PIXEL_RGB,
    182     RS_KIND_PIXEL_RGBA,
    183     RS_KIND_PIXEL_DEPTH,
    184     RS_KIND_PIXEL_YUV,
    185 
    186     RS_KIND_INVALID = 100,
    187 };
    188 
    189 enum RsSamplerParam {
    190     RS_SAMPLER_MIN_FILTER,
    191     RS_SAMPLER_MAG_FILTER,
    192     RS_SAMPLER_WRAP_S,
    193     RS_SAMPLER_WRAP_T,
    194     RS_SAMPLER_WRAP_R,
    195     RS_SAMPLER_ANISO
    196 };
    197 
    198 enum RsSamplerValue {
    199     RS_SAMPLER_NEAREST,
    200     RS_SAMPLER_LINEAR,
    201     RS_SAMPLER_LINEAR_MIP_LINEAR,
    202     RS_SAMPLER_WRAP,
    203     RS_SAMPLER_CLAMP,
    204     RS_SAMPLER_LINEAR_MIP_NEAREST,
    205     RS_SAMPLER_MIRRORED_REPEAT,
    206 
    207     RS_SAMPLER_INVALID = 100,
    208 };
    209 
    210 enum RsTextureTarget {
    211     RS_TEXTURE_2D,
    212     RS_TEXTURE_CUBE
    213 };
    214 
    215 enum RsDimension {
    216     RS_DIMENSION_X,
    217     RS_DIMENSION_Y,
    218     RS_DIMENSION_Z,
    219     RS_DIMENSION_LOD,
    220     RS_DIMENSION_FACE,
    221 
    222     RS_DIMENSION_ARRAY_0 = 100,
    223     RS_DIMENSION_ARRAY_1,
    224     RS_DIMENSION_ARRAY_2,
    225     RS_DIMENSION_ARRAY_3,
    226     RS_DIMENSION_MAX = RS_DIMENSION_ARRAY_3
    227 };
    228 
    229 enum RsDepthFunc {
    230     RS_DEPTH_FUNC_ALWAYS,
    231     RS_DEPTH_FUNC_LESS,
    232     RS_DEPTH_FUNC_LEQUAL,
    233     RS_DEPTH_FUNC_GREATER,
    234     RS_DEPTH_FUNC_GEQUAL,
    235     RS_DEPTH_FUNC_EQUAL,
    236     RS_DEPTH_FUNC_NOTEQUAL
    237 };
    238 
    239 enum RsBlendSrcFunc {
    240     RS_BLEND_SRC_ZERO,                  // 0
    241     RS_BLEND_SRC_ONE,                   // 1
    242     RS_BLEND_SRC_DST_COLOR,             // 2
    243     RS_BLEND_SRC_ONE_MINUS_DST_COLOR,   // 3
    244     RS_BLEND_SRC_SRC_ALPHA,             // 4
    245     RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA,   // 5
    246     RS_BLEND_SRC_DST_ALPHA,             // 6
    247     RS_BLEND_SRC_ONE_MINUS_DST_ALPHA,   // 7
    248     RS_BLEND_SRC_SRC_ALPHA_SATURATE,    // 8
    249     RS_BLEND_SRC_INVALID = 100,
    250 };
    251 
    252 enum RsBlendDstFunc {
    253     RS_BLEND_DST_ZERO,                  // 0
    254     RS_BLEND_DST_ONE,                   // 1
    255     RS_BLEND_DST_SRC_COLOR,             // 2
    256     RS_BLEND_DST_ONE_MINUS_SRC_COLOR,   // 3
    257     RS_BLEND_DST_SRC_ALPHA,             // 4
    258     RS_BLEND_DST_ONE_MINUS_SRC_ALPHA,   // 5
    259     RS_BLEND_DST_DST_ALPHA,             // 6
    260     RS_BLEND_DST_ONE_MINUS_DST_ALPHA,   // 7
    261 
    262     RS_BLEND_DST_INVALID = 100,
    263 };
    264 
    265 enum RsTexEnvMode {
    266     RS_TEX_ENV_MODE_NONE,
    267     RS_TEX_ENV_MODE_REPLACE,
    268     RS_TEX_ENV_MODE_MODULATE,
    269     RS_TEX_ENV_MODE_DECAL
    270 };
    271 
    272 enum RsProgramParam {
    273     RS_PROGRAM_PARAM_INPUT,
    274     RS_PROGRAM_PARAM_OUTPUT,
    275     RS_PROGRAM_PARAM_CONSTANT,
    276     RS_PROGRAM_PARAM_TEXTURE_TYPE,
    277 };
    278 
    279 enum RsPrimitive {
    280     RS_PRIMITIVE_POINT,
    281     RS_PRIMITIVE_LINE,
    282     RS_PRIMITIVE_LINE_STRIP,
    283     RS_PRIMITIVE_TRIANGLE,
    284     RS_PRIMITIVE_TRIANGLE_STRIP,
    285     RS_PRIMITIVE_TRIANGLE_FAN,
    286 
    287     RS_PRIMITIVE_INVALID = 100,
    288 };
    289 
    290 enum RsPathPrimitive {
    291     RS_PATH_PRIMITIVE_QUADRATIC_BEZIER,
    292     RS_PATH_PRIMITIVE_CUBIC_BEZIER
    293 };
    294 
    295 enum RsError {
    296     RS_ERROR_NONE = 0,
    297     RS_ERROR_BAD_SHADER = 1,
    298     RS_ERROR_BAD_SCRIPT = 2,
    299     RS_ERROR_BAD_VALUE = 3,
    300     RS_ERROR_OUT_OF_MEMORY = 4,
    301     RS_ERROR_DRIVER = 5,
    302 
    303     // Errors that only occur in the debug context.
    304     RS_ERROR_FATAL_DEBUG = 0x0800,
    305 
    306     RS_ERROR_FATAL_UNKNOWN = 0x1000,
    307     RS_ERROR_FATAL_DRIVER = 0x1001,
    308     RS_ERROR_FATAL_PROGRAM_LINK = 0x1002
    309 };
    310 
    311 enum RsAnimationInterpolation {
    312     RS_ANIMATION_INTERPOLATION_STEP,
    313     RS_ANIMATION_INTERPOLATION_LINEAR,
    314     RS_ANIMATION_INTERPOLATION_BEZIER,
    315     RS_ANIMATION_INTERPOLATION_CARDINAL,
    316     RS_ANIMATION_INTERPOLATION_HERMITE,
    317     RS_ANIMATION_INTERPOLATION_BSPLINE
    318 };
    319 
    320 enum RsAnimationEdge {
    321     RS_ANIMATION_EDGE_UNDEFINED,
    322     RS_ANIMATION_EDGE_CONSTANT,
    323     RS_ANIMATION_EDGE_GRADIENT,
    324     RS_ANIMATION_EDGE_CYCLE,
    325     RS_ANIMATION_EDGE_OSCILLATE,
    326     RS_ANIMATION_EDGE_CYLE_RELATIVE
    327 };
    328 
    329 enum RsA3DClassID {
    330     RS_A3D_CLASS_ID_UNKNOWN,
    331     RS_A3D_CLASS_ID_MESH,
    332     RS_A3D_CLASS_ID_TYPE,
    333     RS_A3D_CLASS_ID_ELEMENT,
    334     RS_A3D_CLASS_ID_ALLOCATION,
    335     RS_A3D_CLASS_ID_PROGRAM_VERTEX,
    336     RS_A3D_CLASS_ID_PROGRAM_RASTER,
    337     RS_A3D_CLASS_ID_PROGRAM_FRAGMENT,
    338     RS_A3D_CLASS_ID_PROGRAM_STORE,
    339     RS_A3D_CLASS_ID_SAMPLER,
    340     RS_A3D_CLASS_ID_ANIMATION,
    341     RS_A3D_CLASS_ID_ADAPTER_1D,
    342     RS_A3D_CLASS_ID_ADAPTER_2D,
    343     RS_A3D_CLASS_ID_SCRIPT_C,
    344     RS_A3D_CLASS_ID_SCRIPT_KERNEL_ID,
    345     RS_A3D_CLASS_ID_SCRIPT_FIELD_ID,
    346     RS_A3D_CLASS_ID_SCRIPT_METHOD_ID,
    347     RS_A3D_CLASS_ID_SCRIPT_GROUP
    348 };
    349 
    350 enum RsCullMode {
    351     RS_CULL_BACK,
    352     RS_CULL_FRONT,
    353     RS_CULL_NONE,
    354     RS_CULL_INVALID = 100,
    355 };
    356 
    357 enum RsScriptIntrinsicID {
    358     RS_SCRIPT_INTRINSIC_ID_UNDEFINED = 0,
    359     RS_SCRIPT_INTRINSIC_ID_CONVOLVE_3x3 = 1,
    360     RS_SCRIPT_INTRINSIC_ID_COLOR_MATRIX = 2,
    361     RS_SCRIPT_INTRINSIC_ID_LUT = 3,
    362     RS_SCRIPT_INTRINSIC_ID_CONVOLVE_5x5 = 4,
    363     RS_SCRIPT_INTRINSIC_ID_BLUR = 5,
    364     RS_SCRIPT_INTRINSIC_ID_YUV_TO_RGB = 6,
    365     RS_SCRIPT_INTRINSIC_ID_BLEND = 7,
    366     RS_SCRIPT_INTRINSIC_ID_3DLUT = 8,
    367     RS_SCRIPT_INTRINSIC_ID_HISTOGRAM = 9
    368 };
    369 
    370 typedef struct {
    371     RsA3DClassID classID;
    372     const char* objectName;
    373 } RsFileIndexEntry;
    374 
    375 enum RsForEachStrategy {
    376     RS_FOR_EACH_STRATEGY_SERIAL = 0,
    377     RS_FOR_EACH_STRATEGY_DONT_CARE = 1,
    378     RS_FOR_EACH_STRATEGY_DST_LINEAR = 2,
    379     RS_FOR_EACH_STRATEGY_TILE_SMALL = 3,
    380     RS_FOR_EACH_STRATEGY_TILE_MEDIUM = 4,
    381     RS_FOR_EACH_STRATEGY_TILE_LARGE = 5
    382 };
    383 
    384 // Script to Script
    385 typedef struct {
    386     enum RsForEachStrategy strategy;
    387     uint32_t xStart;
    388     uint32_t xEnd;
    389     uint32_t yStart;
    390     uint32_t yEnd;
    391     uint32_t zStart;
    392     uint32_t zEnd;
    393     uint32_t arrayStart;
    394     uint32_t arrayEnd;
    395 
    396 } RsScriptCall;
    397 
    398 enum RsContextFlags {
    399     RS_CONTEXT_SYNCHRONOUS = 1,
    400     RS_CONTEXT_LOW_LATENCY = 2,
    401     RS_CONTEXT_MAX = 4
    402 };
    403 
    404 
    405 #ifdef __cplusplus
    406 };
    407 #endif
    408 
    409 #endif // RENDER_SCRIPT_DEFINES_H
    410 
    411 
    412 
    413 
    414