/usr/local/google/home/srhines/android_trees/jb-mr2-dev/frameworks/rs/scriptc/rs_types.rsh
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2013 The Android Open Source Project
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00041 #ifndef __RS_TYPES_RSH__
00042 #define __RS_TYPES_RSH__
00043 
00044 /* Constants */
00045 #define M_E         2.718281828459045235360287471352662498f     /* e */
00046 #define M_LOG2E     1.442695040888963407359924681001892137f     /* log_2 e */
00047 #define M_LOG10E    0.434294481903251827651128918916605082f     /* log_10 e */
00048 #define M_LN2       0.693147180559945309417232121458176568f     /* log_e 2 */
00049 #define M_LN10      2.302585092994045684017991454684364208f     /* log_e 10 */
00050 #define M_PI        3.141592653589793238462643383279502884f     /* pi */
00051 #define M_PI_2      1.570796326794896619231321691639751442f     /* pi/2 */
00052 #define M_PI_4      0.785398163397448309615660845819875721f     /* pi/4 */
00053 #define M_1_PI      0.318309886183790671537767526745028724f     /* 1/pi */
00054 #define M_2_PIl     0.636619772367581343075535053490057448f     /* 2/pi */
00055 #define M_2_SQRTPI  1.128379167095512573896158903121545172f     /* 2/sqrt(pi) */
00056 #define M_SQRT2     1.414213562373095048801688724209698079f     /* sqrt(2) */
00057 #define M_SQRT1_2   0.707106781186547524400844362104849039f     /* 1/sqrt(2) */
00058 
00059 #include "stdbool.h"
00063 typedef char int8_t;
00067 typedef short int16_t;
00071 typedef int int32_t;
00075 typedef long long int64_t;
00079 typedef unsigned char uint8_t;
00083 typedef unsigned short uint16_t;
00087 typedef unsigned int uint32_t;
00091 typedef unsigned long long uint64_t;
00095 typedef uint8_t uchar;
00099 typedef uint16_t ushort;
00103 typedef uint32_t uint;
00107 typedef uint64_t ulong;
00111 typedef uint32_t size_t;
00115 typedef int32_t ssize_t;
00116 
00122 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_element;
00128 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_type;
00134 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_allocation;
00140 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_sampler;
00146 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_script;
00152 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_mesh;
00158 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_path;
00164 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_fragment;
00170 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_vertex;
00176 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_raster;
00182 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_store;
00188 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_font;
00189 
00195 typedef float float2 __attribute__((ext_vector_type(2)));
00200 typedef float float3 __attribute__((ext_vector_type(3)));
00206 typedef float float4 __attribute__((ext_vector_type(4)));
00207 
00212 typedef double double2 __attribute__((ext_vector_type(2)));
00217 typedef double double3 __attribute__((ext_vector_type(3)));
00222 typedef double double4 __attribute__((ext_vector_type(4)));
00223 
00228 typedef uchar uchar2 __attribute__((ext_vector_type(2)));
00233 typedef uchar uchar3 __attribute__((ext_vector_type(3)));
00238 typedef uchar uchar4 __attribute__((ext_vector_type(4)));
00239 
00244 typedef ushort ushort2 __attribute__((ext_vector_type(2)));
00249 typedef ushort ushort3 __attribute__((ext_vector_type(3)));
00254 typedef ushort ushort4 __attribute__((ext_vector_type(4)));
00255 
00260 typedef uint uint2 __attribute__((ext_vector_type(2)));
00265 typedef uint uint3 __attribute__((ext_vector_type(3)));
00270 typedef uint uint4 __attribute__((ext_vector_type(4)));
00271 
00276 typedef ulong ulong2 __attribute__((ext_vector_type(2)));
00281 typedef ulong ulong3 __attribute__((ext_vector_type(3)));
00286 typedef ulong ulong4 __attribute__((ext_vector_type(4)));
00287 
00292 typedef char char2 __attribute__((ext_vector_type(2)));
00297 typedef char char3 __attribute__((ext_vector_type(3)));
00302 typedef char char4 __attribute__((ext_vector_type(4)));
00303 
00308 typedef short short2 __attribute__((ext_vector_type(2)));
00313 typedef short short3 __attribute__((ext_vector_type(3)));
00318 typedef short short4 __attribute__((ext_vector_type(4)));
00319 
00324 typedef int int2 __attribute__((ext_vector_type(2)));
00329 typedef int int3 __attribute__((ext_vector_type(3)));
00334 typedef int int4 __attribute__((ext_vector_type(4)));
00335 
00340 typedef long long2 __attribute__((ext_vector_type(2)));
00345 typedef long long3 __attribute__((ext_vector_type(3)));
00350 typedef long long4 __attribute__((ext_vector_type(4)));
00351 
00358 typedef struct {
00359     float m[16];
00360 } rs_matrix4x4;
00367 typedef struct {
00368     float m[9];
00369 } rs_matrix3x3;
00376 typedef struct {
00377     float m[4];
00378 } rs_matrix2x2;
00379 
00383 typedef float4 rs_quaternion;
00384 
00385 #define RS_PACKED __attribute__((packed, aligned(4)))
00386 #define NULL ((void *)0)
00387 
00388 #if (defined(RS_VERSION) && (RS_VERSION >= 14))
00389 
00393 typedef enum {
00394     RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0,
00395     RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1,
00396     RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2,
00397     RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3,
00398     RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4,
00399     RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5
00400 } rs_allocation_cubemap_face;
00401 
00408 typedef enum {
00409     RS_ALLOCATION_USAGE_SCRIPT = 0x0001,
00410     RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002,
00411     RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004,
00412     RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008,
00413     RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010
00414 } rs_allocation_usage_type;
00415 
00416 #endif //defined(RS_VERSION) && (RS_VERSION >= 14)
00417 
00418 // New API's
00419 #if (defined(RS_VERSION) && (RS_VERSION >= 16))
00420 
00425 typedef enum {
00429     RS_PRIMITIVE_POINT              = 0,
00433     RS_PRIMITIVE_LINE               = 1,
00437     RS_PRIMITIVE_LINE_STRIP         = 2,
00441     RS_PRIMITIVE_TRIANGLE           = 3,
00447     RS_PRIMITIVE_TRIANGLE_STRIP     = 4,
00452     RS_PRIMITIVE_TRIANGLE_FAN       = 5,
00453 
00457     RS_PRIMITIVE_INVALID            = 100,
00458 } rs_primitive;
00459 
00478 typedef enum {
00479     RS_TYPE_NONE             = 0,
00480     RS_TYPE_FLOAT_32         = 2,
00481     RS_TYPE_FLOAT_64         = 3,
00482     RS_TYPE_SIGNED_8         = 4,
00483     RS_TYPE_SIGNED_16        = 5,
00484     RS_TYPE_SIGNED_32        = 6,
00485     RS_TYPE_SIGNED_64        = 7,
00486     RS_TYPE_UNSIGNED_8       = 8,
00487     RS_TYPE_UNSIGNED_16      = 9,
00488     RS_TYPE_UNSIGNED_32      = 10,
00489     RS_TYPE_UNSIGNED_64      = 11,
00490 
00491     RS_TYPE_BOOLEAN          = 12,
00492 
00493     RS_TYPE_UNSIGNED_5_6_5   = 13,
00494     RS_TYPE_UNSIGNED_5_5_5_1 = 14,
00495     RS_TYPE_UNSIGNED_4_4_4_4 = 15,
00496 
00497     RS_TYPE_MATRIX_4X4       = 16,
00498     RS_TYPE_MATRIX_3X3       = 17,
00499     RS_TYPE_MATRIX_2X2       = 18,
00500 
00501     RS_TYPE_ELEMENT          = 1000,
00502     RS_TYPE_TYPE             = 1001,
00503     RS_TYPE_ALLOCATION       = 1002,
00504     RS_TYPE_SAMPLER          = 1003,
00505     RS_TYPE_SCRIPT           = 1004,
00506     RS_TYPE_MESH             = 1005,
00507     RS_TYPE_PROGRAM_FRAGMENT = 1006,
00508     RS_TYPE_PROGRAM_VERTEX   = 1007,
00509     RS_TYPE_PROGRAM_RASTER   = 1008,
00510     RS_TYPE_PROGRAM_STORE    = 1009,
00511     RS_TYPE_FONT             = 1010,
00512 
00513     RS_TYPE_INVALID          = 10000,
00514 } rs_data_type;
00515 
00524 typedef enum {
00525     RS_KIND_USER         = 0,
00526 
00527     RS_KIND_PIXEL_L      = 7,
00528     RS_KIND_PIXEL_A      = 8,
00529     RS_KIND_PIXEL_LA     = 9,
00530     RS_KIND_PIXEL_RGB    = 10,
00531     RS_KIND_PIXEL_RGBA   = 11,
00532     RS_KIND_PIXEL_DEPTH  = 12,
00533     RS_KIND_PIXEL_YUV    = 13,
00534 
00535     RS_KIND_INVALID      = 100,
00536 } rs_data_kind;
00537 
00538 typedef enum {
00542     RS_DEPTH_FUNC_ALWAYS        = 0,
00547     RS_DEPTH_FUNC_LESS          = 1,
00552     RS_DEPTH_FUNC_LEQUAL        = 2,
00557     RS_DEPTH_FUNC_GREATER       = 3,
00562     RS_DEPTH_FUNC_GEQUAL        = 4,
00567     RS_DEPTH_FUNC_EQUAL         = 5,
00572     RS_DEPTH_FUNC_NOTEQUAL      = 6,
00576     RS_DEPTH_FUNC_INVALID       = 100,
00577 } rs_depth_func;
00578 
00579 typedef enum {
00580     RS_BLEND_SRC_ZERO                   = 0,
00581     RS_BLEND_SRC_ONE                    = 1,
00582     RS_BLEND_SRC_DST_COLOR              = 2,
00583     RS_BLEND_SRC_ONE_MINUS_DST_COLOR    = 3,
00584     RS_BLEND_SRC_SRC_ALPHA              = 4,
00585     RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA    = 5,
00586     RS_BLEND_SRC_DST_ALPHA              = 6,
00587     RS_BLEND_SRC_ONE_MINUS_DST_ALPHA    = 7,
00588     RS_BLEND_SRC_SRC_ALPHA_SATURATE     = 8,
00589 
00590     RS_BLEND_SRC_INVALID                = 100,
00591 } rs_blend_src_func;
00592 
00593 typedef enum {
00594     RS_BLEND_DST_ZERO                   = 0,
00595     RS_BLEND_DST_ONE                    = 1,
00596     RS_BLEND_DST_SRC_COLOR              = 2,
00597     RS_BLEND_DST_ONE_MINUS_SRC_COLOR    = 3,
00598     RS_BLEND_DST_SRC_ALPHA              = 4,
00599     RS_BLEND_DST_ONE_MINUS_SRC_ALPHA    = 5,
00600     RS_BLEND_DST_DST_ALPHA              = 6,
00601     RS_BLEND_DST_ONE_MINUS_DST_ALPHA    = 7,
00602 
00603     RS_BLEND_DST_INVALID                = 100,
00604 } rs_blend_dst_func;
00605 
00606 typedef enum {
00607     RS_CULL_BACK     = 0,
00608     RS_CULL_FRONT    = 1,
00609     RS_CULL_NONE     = 2,
00610 
00611     RS_CULL_INVALID  = 100,
00612 } rs_cull_mode;
00613 
00614 typedef enum {
00615     RS_SAMPLER_NEAREST              = 0,
00616     RS_SAMPLER_LINEAR               = 1,
00617     RS_SAMPLER_LINEAR_MIP_LINEAR    = 2,
00618     RS_SAMPLER_WRAP                 = 3,
00619     RS_SAMPLER_CLAMP                = 4,
00620     RS_SAMPLER_LINEAR_MIP_NEAREST   = 5,
00621     RS_SAMPLER_MIRRORED_REPEAT      = 6,
00622 
00623     RS_SAMPLER_INVALID              = 100,
00624 } rs_sampler_value;
00625 
00626 #endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
00627 
00628 #endif // __RS_TYPES_RSH__