Merge "Part II of fixing b/2943524: On-device linking rs_core." into honeycomb

This commit is contained in:
Shih-wei Liao
2011-01-26 14:56:41 -08:00
committed by Android (Google) Code Review

View File

@@ -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);
@@ -255,26 +164,13 @@ extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix2x2 *m);
// 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