summaryrefslogtreecommitdiff
path: root/scriptc
diff options
context:
space:
mode:
authorShih-wei Liao <sliao@google.com>2011-01-26 15:00:44 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-01-26 15:00:44 -0800
commit3710df41e945d6dfed573556be5bedded2a15e61 (patch)
tree1079ccfebc0f62447e21da09cff0770b2f931374 /scriptc
parent1f03b14b9be40c4b2d6ad1107fdc29cb719b5007 (diff)
parent4c3a95fbed69fed21a2def11ee11953b834a4eea (diff)
downloadrs-3710df41e945d6dfed573556be5bedded2a15e61.tar.gz
am dde78c2b: am 79204b98: Merge "Part II of fixing b/2943524: On-device linking rs_core." into honeycomb
* commit 'dde78c2b1c2c2ea28b6799ac135477386ae5df93': Part II of fixing b/2943524: On-device linking rs_core.
Diffstat (limited to 'scriptc')
-rw-r--r--scriptc/rs_core.rsh184
1 files changed, 40 insertions, 144 deletions
diff --git a/scriptc/rs_core.rsh b/scriptc/rs_core.rsh
index 5a1c2916..104ad281 100644
--- a/scriptc/rs_core.rsh
+++ b/scriptc/rs_core.rsh
@@ -1,11 +1,7 @@
#ifndef __RS_CORE_RSH__
#define __RS_CORE_RSH__
-#ifdef BCC_PREPARE_BC
-#define _RS_STATIC extern
-#else
-#define _RS_STATIC static
-#endif
+#define _RS_RUNTIME extern
// Debugging, print to the LOG a description string and a value.
extern void __attribute__((overloadable))
@@ -41,56 +37,19 @@ extern void __attribute__((overloadable))
#define RS_DEBUG(a) rsDebug(#a, a)
#define RS_DEBUG_MARKER rsDebug(__FILE__, __LINE__)
-_RS_STATIC void __attribute__((overloadable)) rsDebug(const char *s, float2 v) {
- rsDebug(s, v.x, v.y);
-}
-_RS_STATIC void __attribute__((overloadable)) rsDebug(const char *s, float3 v) {
- rsDebug(s, v.x, v.y, v.z);
-}
-_RS_STATIC void __attribute__((overloadable)) rsDebug(const char *s, float4 v) {
- rsDebug(s, v.x, v.y, v.z, v.w);
-}
+_RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float2 v);
+_RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float3 v);
+_RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float4 v);
-_RS_STATIC uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b)
-{
- uchar4 c;
- c.x = (uchar)(r * 255.f);
- c.y = (uchar)(g * 255.f);
- c.z = (uchar)(b * 255.f);
- c.w = 255;
- return c;
-}
+_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b);
-_RS_STATIC uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b, float a)
-{
- uchar4 c;
- c.x = (uchar)(r * 255.f);
- c.y = (uchar)(g * 255.f);
- c.z = (uchar)(b * 255.f);
- c.w = (uchar)(a * 255.f);
- return c;
-}
+_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b, float a);
-_RS_STATIC uchar4 __attribute__((overloadable)) rsPackColorTo8888(float3 color)
-{
- color *= 255.f;
- uchar4 c = {color.x, color.y, color.z, 255};
- return c;
-}
+_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float3 color);
-_RS_STATIC uchar4 __attribute__((overloadable)) rsPackColorTo8888(float4 color)
-{
- color *= 255.f;
- uchar4 c = {color.x, color.y, color.z, color.w};
- return c;
-}
+_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float4 color);
-_RS_STATIC float4 rsUnpackColor8888(uchar4 c)
-{
- float4 ret = (float4)0.0039156862745f;
- ret *= convert_float4(c);
- return ret;
-}
+_RS_RUNTIME float4 rsUnpackColor8888(uchar4 c);
//extern uchar4 __attribute__((overloadable)) rsPackColorTo565(float r, float g, float b);
//extern uchar4 __attribute__((overloadable)) rsPackColorTo565(float3);
@@ -101,35 +60,23 @@ _RS_STATIC float4 rsUnpackColor8888(uchar4 c)
// Matrix ops
/////////////////////////////////////////////////////
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixSet(rs_matrix4x4 *m, uint32_t row, uint32_t col, float v) {
- m->m[row * 4 + col] = v;
-}
+_RS_RUNTIME void __attribute__((overloadable))
+rsMatrixSet(rs_matrix4x4 *m, uint32_t row, uint32_t col, float v);
-_RS_STATIC float __attribute__((overloadable))
-rsMatrixGet(const rs_matrix4x4 *m, uint32_t row, uint32_t col) {
- return m->m[row * 4 + col];
-}
+_RS_RUNTIME float __attribute__((overloadable))
+rsMatrixGet(const rs_matrix4x4 *m, uint32_t row, uint32_t col);
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixSet(rs_matrix3x3 *m, uint32_t row, uint32_t col, float v) {
- m->m[row * 3 + col] = v;
-}
+_RS_RUNTIME void __attribute__((overloadable))
+rsMatrixSet(rs_matrix3x3 *m, uint32_t row, uint32_t col, float v);
-_RS_STATIC float __attribute__((overloadable))
-rsMatrixGet(const rs_matrix3x3 *m, uint32_t row, uint32_t col) {
- return m->m[row * 3 + col];
-}
+_RS_RUNTIME float __attribute__((overloadable))
+rsMatrixGet(const rs_matrix3x3 *m, uint32_t row, uint32_t col);
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixSet(rs_matrix2x2 *m, uint32_t row, uint32_t col, float v) {
- m->m[row * 2 + col] = v;
-}
+_RS_RUNTIME void __attribute__((overloadable))
+rsMatrixSet(rs_matrix2x2 *m, uint32_t row, uint32_t col, float v);
-_RS_STATIC float __attribute__((overloadable))
-rsMatrixGet(const rs_matrix2x2 *m, uint32_t row, uint32_t col) {
- return m->m[row * 2 + col];
-}
+_RS_RUNTIME float __attribute__((overloadable))
+rsMatrixGet(const rs_matrix2x2 *m, uint32_t row, uint32_t col);
extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix4x4 *m);
extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix3x3 *m);
@@ -188,61 +135,23 @@ rsMatrixLoadFrustum(rs_matrix4x4 *m, float left, float right, float bottom, floa
extern void __attribute__((overloadable))
rsMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far);
-_RS_STATIC float4 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, float4 in) {
- float4 ret;
- ret.x = (m->m[0] * in.x) + (m->m[4] * in.y) + (m->m[8] * in.z) + (m->m[12] * in.w);
- ret.y = (m->m[1] * in.x) + (m->m[5] * in.y) + (m->m[9] * in.z) + (m->m[13] * in.w);
- ret.z = (m->m[2] * in.x) + (m->m[6] * in.y) + (m->m[10] * in.z) + (m->m[14] * in.w);
- ret.w = (m->m[3] * in.x) + (m->m[7] * in.y) + (m->m[11] * in.z) + (m->m[15] * in.w);
- return ret;
-}
+_RS_RUNTIME float4 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix4x4 *m, float4 in);
-_RS_STATIC float4 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, float3 in) {
- float4 ret;
- ret.x = (m->m[0] * in.x) + (m->m[4] * in.y) + (m->m[8] * in.z) + m->m[12];
- ret.y = (m->m[1] * in.x) + (m->m[5] * in.y) + (m->m[9] * in.z) + m->m[13];
- ret.z = (m->m[2] * in.x) + (m->m[6] * in.y) + (m->m[10] * in.z) + m->m[14];
- ret.w = (m->m[3] * in.x) + (m->m[7] * in.y) + (m->m[11] * in.z) + m->m[15];
- return ret;
-}
+_RS_RUNTIME float4 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix4x4 *m, float3 in);
-_RS_STATIC float4 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, float2 in) {
- float4 ret;
- ret.x = (m->m[0] * in.x) + (m->m[4] * in.y) + m->m[12];
- ret.y = (m->m[1] * in.x) + (m->m[5] * in.y) + m->m[13];
- ret.z = (m->m[2] * in.x) + (m->m[6] * in.y) + m->m[14];
- ret.w = (m->m[3] * in.x) + (m->m[7] * in.y) + m->m[15];
- return ret;
-}
+_RS_RUNTIME float4 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix4x4 *m, float2 in);
-_RS_STATIC float3 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix3x3 *m, float3 in) {
- float3 ret;
- ret.x = (m->m[0] * in.x) + (m->m[3] * in.y) + (m->m[6] * in.z);
- ret.y = (m->m[1] * in.x) + (m->m[4] * in.y) + (m->m[7] * in.z);
- ret.z = (m->m[2] * in.x) + (m->m[5] * in.y) + (m->m[8] * in.z);
- return ret;
-}
+_RS_RUNTIME float3 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix3x3 *m, float3 in);
-_RS_STATIC float3 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix3x3 *m, float2 in) {
- float3 ret;
- ret.x = (m->m[0] * in.x) + (m->m[3] * in.y);
- ret.y = (m->m[1] * in.x) + (m->m[4] * in.y);
- ret.z = (m->m[2] * in.x) + (m->m[5] * in.y);
- return ret;
-}
+_RS_RUNTIME float3 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix3x3 *m, float2 in);
-_RS_STATIC float2 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix2x2 *m, float2 in) {
- float2 ret;
- ret.x = (m->m[0] * in.x) + (m->m[2] * in.y);
- ret.y = (m->m[1] * in.x) + (m->m[3] * in.y);
- return ret;
-}
+_RS_RUNTIME float2 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix2x2 *m, float2 in);
// Returns true if the matrix was successfully inversed
extern bool __attribute__((overloadable)) rsMatrixInverse(rs_matrix4x4 *m);
@@ -505,26 +414,13 @@ rsIsSphereInFrustum(float4 *sphere,
// int ops
/////////////////////////////////////////////////////
-__inline__ _RS_STATIC uint __attribute__((overloadable, always_inline)) rsClamp(uint amount, uint low, uint high) {
- return amount < low ? low : (amount > high ? high : amount);
-}
-__inline__ _RS_STATIC int __attribute__((overloadable, always_inline)) rsClamp(int amount, int low, int high) {
- return amount < low ? low : (amount > high ? high : amount);
-}
-__inline__ _RS_STATIC ushort __attribute__((overloadable, always_inline)) rsClamp(ushort amount, ushort low, ushort high) {
- return amount < low ? low : (amount > high ? high : amount);
-}
-__inline__ _RS_STATIC short __attribute__((overloadable, always_inline)) rsClamp(short amount, short low, short high) {
- return amount < low ? low : (amount > high ? high : amount);
-}
-__inline__ _RS_STATIC uchar __attribute__((overloadable, always_inline)) rsClamp(uchar amount, uchar low, uchar high) {
- return amount < low ? low : (amount > high ? high : amount);
-}
-__inline__ _RS_STATIC char __attribute__((overloadable, always_inline)) rsClamp(char amount, char low, char high) {
- return amount < low ? low : (amount > high ? high : amount);
-}
+_RS_RUNTIME uint __attribute__((overloadable, always_inline)) rsClamp(uint amount, uint low, uint high);
+_RS_RUNTIME int __attribute__((overloadable, always_inline)) rsClamp(int amount, int low, int high);
+_RS_RUNTIME ushort __attribute__((overloadable, always_inline)) rsClamp(ushort amount, ushort low, ushort high);
+_RS_RUNTIME short __attribute__((overloadable, always_inline)) rsClamp(short amount, short low, short high);
+_RS_RUNTIME uchar __attribute__((overloadable, always_inline)) rsClamp(uchar amount, uchar low, uchar high);
+_RS_RUNTIME char __attribute__((overloadable, always_inline)) rsClamp(char amount, char low, char high);
-#undef _RS_STATIC
+#undef _RS_RUNTIME
#endif
-