diff options
author | Jason Sams <rjsams@android.com> | 2010-03-18 14:36:05 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2010-03-18 14:36:05 -0700 |
commit | 4ab7b236efd06f53b345a73d3c25d2ec714c861e (patch) | |
tree | 2e8032f25118ecb10cec2c72a734157619c38b7e /libs | |
parent | a0d6b59d875edb54b1c820fd4573552989c3869b (diff) | |
download | frameworks_base-4ab7b236efd06f53b345a73d3c25d2ec714c861e.zip frameworks_base-4ab7b236efd06f53b345a73d3c25d2ec714c861e.tar.gz frameworks_base-4ab7b236efd06f53b345a73d3c25d2ec714c861e.tar.bz2 |
More rsh headers for renderscript and a llvm compatible test script for fountain.
Change-Id: If5d682e549e6f849ba809619587feb58c1e4ed0a
Diffstat (limited to 'libs')
-rw-r--r-- | libs/rs/java/Fountain/res/raw/fountain2.rs | 74 | ||||
-rw-r--r-- | libs/rs/scriptc/rs_graphics.rsh | 65 |
2 files changed, 139 insertions, 0 deletions
diff --git a/libs/rs/java/Fountain/res/raw/fountain2.rs b/libs/rs/java/Fountain/res/raw/fountain2.rs new file mode 100644 index 0000000..6eb1580 --- /dev/null +++ b/libs/rs/java/Fountain/res/raw/fountain2.rs @@ -0,0 +1,74 @@ +// Fountain test script +#pragma version(1) + +#include "rs_types.rsh" +#include "rs_math.rsh" +#include "rs_graphics.rsh" + +int newPart = 0; + +typedef struct Control_s { + int x, y; + int rate; + int count; + float r, g, b; + rs_allocation partBuffer; + rs_mesh partMesh; +} Control_t; +extern Control_t *Control; + +typedef struct Point_s{ + float2 delta; + float2 position; + unsigned int color; +} Point_t; +extern Point_t *point; + +int main(int launchID) { + int ct; + int count = Control->count; + int rate = Control->rate; + float height = getHeight(); + Point_t * p = point; + + if (rate) { + float rMax = ((float)rate) * 0.005f; + int x = Control->x; + int y = Control->y; + int color = ((int)(Control->r * 255.f)) | + ((int)(Control->g * 255.f)) << 8 | + ((int)(Control->b * 255.f)) << 16 | + (0xf0 << 24); + Point_t * np = &p[newPart]; + + while (rate--) { + np->delta = vec2Rand(rMax); + np->position.x = x; + np->position.y = y; + np->color = color; + newPart++; + np++; + if (newPart >= count) { + newPart = 0; + np = &p[newPart]; + } + } + } + + for (ct=0; ct < count; ct++) { + float dy = p->delta.y + 0.15f; + float posy = p->position.y + dy; + if ((posy > height) && (dy > 0)) { + dy *= -0.3f; + } + p->delta.y = dy; + p->position.x += p->delta.x; + p->position.y = posy; + p++; + } + + uploadToBufferObject(Control->partBuffer); + drawSimpleMesh(Control->partMesh); + + return 1; +} diff --git a/libs/rs/scriptc/rs_graphics.rsh b/libs/rs/scriptc/rs_graphics.rsh new file mode 100644 index 0000000..70cd562 --- /dev/null +++ b/libs/rs/scriptc/rs_graphics.rsh @@ -0,0 +1,65 @@ + + +extern float2 vec2Rand(float len); + +extern float3 float3Norm(float3); +extern float float3Length(float3); +extern float3 float3Add(float3 lhs, float3 rhs); +extern float3 float3Sub(float3 lhs, float3 rhs); +extern float3 float3Cross(float3 lhs, float3 rhs); +extern float float3Dot(float3 lhs, float3 rhs); +extern float3 float3Scale(float3 v, float scale); + +extern float4 float4Add(float4 lhs, float4 rhs); +extern float4 float4Sub(float4 lhs, float4 rhs); +extern float4 float4Cross(float4 lhs, float4 rhs); +extern float float4Dot(float4 lhs, float4 rhs); +extern float4 float4Scale(float4 v, float scale); + + // context +extern void bindProgramFragment(rs_program_fragment); +extern void bindProgramStore(rs_program_store); +extern void bindProgramVertex(rs_program_vertex); + +extern void bindSampler(rs_program_fragment, int slot, rs_sampler); +extern void bindSampler(rs_program_fragment, int slot, rs_allocation); + +extern void vpLoadModelMatrix(const float *); +extern void vpLoadTextureMatrix(const float *); + + +// drawing +extern void drawRect(float x1, float y1, float x2, float y2, float z); +extern void drawQuad(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4); +extern void drawQuadTexCoords(float x1, float y1, float z1, float u1, float v1, float x2, float y2, float z2, float u2, float v2, float x3, float y3, float z3, float u3, float v3, float x4, float y4, float z4, float u4, float v4); +extern void drawSprite(float x, float y, float z, float w, float h); +extern void drawSpriteScreenspace(float x, float y, float z, float w, float h); +extern void drawLine(float x1, float y1, float z1, float x2, float y2, float z2); +extern void drawPoint(float x1, float y1, float z1); +extern void drawSimpleMesh(int ism); +extern void drawSimpleMeshRange(int ism, int start, int len); + +// misc +extern void pfClearColor(float, float, float, float); +extern void color(float, float, float, float); +extern void hsb(float, float, float, float); +extern void hsbToRgb(float, float, float, float*); +extern int hsbToAbgr(float, float, float, float); + +extern void uploadToTexture(int, int); +extern void uploadToBufferObject(int); + +extern int colorFloatRGBAtoUNorm8(float, float, float, float); +extern int colorFloatRGBto565(float, float, float); + +extern int getWidth(); +extern int getHeight(); + +extern int sendToClient(void *data, int cmdID, int len, int waitForSpace); + +extern void debugF(const char *, float); +extern void debugI32(const char *, int); +extern void debugHexI32(const char *, int); + + + |