blob: 9c29ca6f640e167ebd607f332bb7ed120fa723e6 [file] [log] [blame]
Jason Samse45ac6e2009-07-20 14:31:06 -07001/*
2 * Copyright (C) 2009 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#include "rsContext.h"
18#include "rsScriptC.h"
19#include "rsMatrix.h"
20
21#include "acc/acc.h"
Joe Onorato9c4e4ca2009-08-09 11:39:02 -070022#include "utils/Timers.h"
Jason Samse45ac6e2009-07-20 14:31:06 -070023
Romain Guy98e10fd2009-07-30 18:45:01 -070024#include <time.h>
Romain Guy98e10fd2009-07-30 18:45:01 -070025
Jason Samse45ac6e2009-07-20 14:31:06 -070026using namespace android;
27using namespace android::renderscript;
28
29#define GET_TLS() Context::ScriptTLSStruct * tls = \
30 (Context::ScriptTLSStruct *)pthread_getspecific(Context::gThreadTLSKey); \
31 Context * rsc = tls->mContext; \
32 ScriptC * sc = (ScriptC *) tls->mScript
33
Jason Samsbe36bf32010-05-11 14:03:58 -070034
Jason Samse45ac6e2009-07-20 14:31:06 -070035//////////////////////////////////////////////////////////////////////////////
36// Math routines
37//////////////////////////////////////////////////////////////////////////////
38
Romain Guy2275d632009-08-18 11:39:17 -070039static float SC_sinf_fast(float x)
40{
41 const float A = 1.0f / (2.0f * M_PI);
42 const float B = -16.0f;
43 const float C = 8.0f;
Jason Samsa57c0a72009-09-04 14:42:41 -070044
Romain Guy2275d632009-08-18 11:39:17 -070045 // scale angle for easy argument reduction
46 x *= A;
Jason Samsa57c0a72009-09-04 14:42:41 -070047
Romain Guy2275d632009-08-18 11:39:17 -070048 if (fabsf(x) >= 0.5f) {
49 // argument reduction
50 x = x - ceilf(x + 0.5f) + 1.0f;
51 }
Jason Samsa57c0a72009-09-04 14:42:41 -070052
Romain Guy2275d632009-08-18 11:39:17 -070053 const float y = B * x * fabsf(x) + C * x;
54 return 0.2215f * (y * fabsf(y) - y) + y;
55}
56
57static float SC_cosf_fast(float x)
58{
59 x += float(M_PI / 2);
60
61 const float A = 1.0f / (2.0f * M_PI);
62 const float B = -16.0f;
63 const float C = 8.0f;
Jason Samsa57c0a72009-09-04 14:42:41 -070064
Romain Guy2275d632009-08-18 11:39:17 -070065 // scale angle for easy argument reduction
66 x *= A;
Jason Samsa57c0a72009-09-04 14:42:41 -070067
Romain Guy2275d632009-08-18 11:39:17 -070068 if (fabsf(x) >= 0.5f) {
69 // argument reduction
70 x = x - ceilf(x + 0.5f) + 1.0f;
71 }
Jason Samsa57c0a72009-09-04 14:42:41 -070072
Romain Guy2275d632009-08-18 11:39:17 -070073 const float y = B * x * fabsf(x) + C * x;
74 return 0.2215f * (y * fabsf(y) - y) + y;
75}
76
Jason Sams22fa3712010-05-19 17:22:57 -070077
Jason Samse45ac6e2009-07-20 14:31:06 -070078static float SC_randf(float max)
79{
80 float r = (float)rand();
81 return r / RAND_MAX * max;
82}
83
Romain Guy39dbc802009-07-31 11:20:59 -070084static float SC_randf2(float min, float max)
85{
86 float r = (float)rand();
87 return r / RAND_MAX * (max - min) + min;
88}
89
Jason Sams22fa3712010-05-19 17:22:57 -070090static int SC_randi(int max)
91{
92 return (int)SC_randf(max);
93}
94
95static int SC_randi2(int min, int max)
96{
97 return (int)SC_randf2(min, max);
98}
99
Jason Samsbe36bf32010-05-11 14:03:58 -0700100static float SC_frac(float v)
101{
102 int i = (int)floor(v);
103 return fmin(v - i, 0x1.fffffep-1f);
104}
105
Romain Guy98e10fd2009-07-30 18:45:01 -0700106//////////////////////////////////////////////////////////////////////////////
107// Time routines
108//////////////////////////////////////////////////////////////////////////////
Jason Samse45ac6e2009-07-20 14:31:06 -0700109
Joe Onorato9c4e4ca2009-08-09 11:39:02 -0700110static int32_t SC_second()
Romain Guy98e10fd2009-07-30 18:45:01 -0700111{
112 GET_TLS();
113
114 time_t rawtime;
115 time(&rawtime);
116
Romain Guy519cdc92009-11-11 15:36:06 -0800117 struct tm *timeinfo;
118 timeinfo = localtime(&rawtime);
119 return timeinfo->tm_sec;
Romain Guy98e10fd2009-07-30 18:45:01 -0700120}
121
Joe Onorato9c4e4ca2009-08-09 11:39:02 -0700122static int32_t SC_minute()
Romain Guy98e10fd2009-07-30 18:45:01 -0700123{
124 GET_TLS();
Jason Samse5ffb872009-08-09 17:01:55 -0700125
Romain Guy98e10fd2009-07-30 18:45:01 -0700126 time_t rawtime;
127 time(&rawtime);
Jason Samse5ffb872009-08-09 17:01:55 -0700128
Romain Guy519cdc92009-11-11 15:36:06 -0800129 struct tm *timeinfo;
130 timeinfo = localtime(&rawtime);
131 return timeinfo->tm_min;
Jason Samse5ffb872009-08-09 17:01:55 -0700132}
Romain Guy98e10fd2009-07-30 18:45:01 -0700133
Joe Onorato9c4e4ca2009-08-09 11:39:02 -0700134static int32_t SC_hour()
Romain Guy98e10fd2009-07-30 18:45:01 -0700135{
136 GET_TLS();
Jason Samse5ffb872009-08-09 17:01:55 -0700137
Romain Guy98e10fd2009-07-30 18:45:01 -0700138 time_t rawtime;
139 time(&rawtime);
Jason Samse5ffb872009-08-09 17:01:55 -0700140
Romain Guy519cdc92009-11-11 15:36:06 -0800141 struct tm *timeinfo;
142 timeinfo = localtime(&rawtime);
143 return timeinfo->tm_hour;
Romain Guy39dbc802009-07-31 11:20:59 -0700144}
145
Joe Onorato9c4e4ca2009-08-09 11:39:02 -0700146static int32_t SC_day()
Romain Guy39dbc802009-07-31 11:20:59 -0700147{
148 GET_TLS();
Jason Samse5ffb872009-08-09 17:01:55 -0700149
Romain Guy39dbc802009-07-31 11:20:59 -0700150 time_t rawtime;
151 time(&rawtime);
Jason Samse5ffb872009-08-09 17:01:55 -0700152
Romain Guy519cdc92009-11-11 15:36:06 -0800153 struct tm *timeinfo;
154 timeinfo = localtime(&rawtime);
155 return timeinfo->tm_mday;
Jason Samse5ffb872009-08-09 17:01:55 -0700156}
Jason Samse45ac6e2009-07-20 14:31:06 -0700157
Joe Onorato9c4e4ca2009-08-09 11:39:02 -0700158static int32_t SC_month()
Romain Guy39dbc802009-07-31 11:20:59 -0700159{
160 GET_TLS();
Jason Samse5ffb872009-08-09 17:01:55 -0700161
Romain Guy39dbc802009-07-31 11:20:59 -0700162 time_t rawtime;
163 time(&rawtime);
Jason Samse5ffb872009-08-09 17:01:55 -0700164
Romain Guy519cdc92009-11-11 15:36:06 -0800165 struct tm *timeinfo;
166 timeinfo = localtime(&rawtime);
167 return timeinfo->tm_mon;
Jason Samse5ffb872009-08-09 17:01:55 -0700168}
Romain Guy39dbc802009-07-31 11:20:59 -0700169
Joe Onorato9c4e4ca2009-08-09 11:39:02 -0700170static int32_t SC_year()
Romain Guy39dbc802009-07-31 11:20:59 -0700171{
172 GET_TLS();
Jason Samse5ffb872009-08-09 17:01:55 -0700173
Romain Guy39dbc802009-07-31 11:20:59 -0700174 time_t rawtime;
175 time(&rawtime);
Jason Samse5ffb872009-08-09 17:01:55 -0700176
Romain Guy519cdc92009-11-11 15:36:06 -0800177 struct tm *timeinfo;
178 timeinfo = localtime(&rawtime);
179 return timeinfo->tm_year;
Romain Guy39dbc802009-07-31 11:20:59 -0700180}
181
Jason Sams22fa3712010-05-19 17:22:57 -0700182static int64_t SC_uptimeMillis2()
183{
184 return nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC));
185}
186
187static int64_t SC_startTimeMillis2()
188{
189 GET_TLS();
190 return sc->mEnviroment.mStartTimeMillis;
191}
192
193static int64_t SC_elapsedTimeMillis2()
194{
195 GET_TLS();
196 return nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC))
197 - sc->mEnviroment.mStartTimeMillis;
198}
199
Joe Onorato9c4e4ca2009-08-09 11:39:02 -0700200static int32_t SC_uptimeMillis()
201{
202 return nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC));
203}
204
205static int32_t SC_startTimeMillis()
206{
207 GET_TLS();
208 return sc->mEnviroment.mStartTimeMillis;
209}
210
211static int32_t SC_elapsedTimeMillis()
212{
213 GET_TLS();
214 return nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC))
215 - sc->mEnviroment.mStartTimeMillis;
216}
217
Jason Samse45ac6e2009-07-20 14:31:06 -0700218//////////////////////////////////////////////////////////////////////////////
219// Matrix routines
220//////////////////////////////////////////////////////////////////////////////
221
222
223static void SC_matrixLoadIdentity(rsc_Matrix *mat)
224{
225 Matrix *m = reinterpret_cast<Matrix *>(mat);
226 m->loadIdentity();
227}
228
229static void SC_matrixLoadFloat(rsc_Matrix *mat, const float *f)
230{
231 Matrix *m = reinterpret_cast<Matrix *>(mat);
232 m->load(f);
233}
234
235static void SC_matrixLoadMat(rsc_Matrix *mat, const rsc_Matrix *newmat)
236{
237 Matrix *m = reinterpret_cast<Matrix *>(mat);
238 m->load(reinterpret_cast<const Matrix *>(newmat));
239}
240
241static void SC_matrixLoadRotate(rsc_Matrix *mat, float rot, float x, float y, float z)
242{
243 Matrix *m = reinterpret_cast<Matrix *>(mat);
244 m->loadRotate(rot, x, y, z);
245}
246
247static void SC_matrixLoadScale(rsc_Matrix *mat, float x, float y, float z)
248{
249 Matrix *m = reinterpret_cast<Matrix *>(mat);
250 m->loadScale(x, y, z);
251}
252
253static void SC_matrixLoadTranslate(rsc_Matrix *mat, float x, float y, float z)
254{
255 Matrix *m = reinterpret_cast<Matrix *>(mat);
256 m->loadTranslate(x, y, z);
257}
258
259static void SC_matrixLoadMultiply(rsc_Matrix *mat, const rsc_Matrix *lhs, const rsc_Matrix *rhs)
260{
261 Matrix *m = reinterpret_cast<Matrix *>(mat);
262 m->loadMultiply(reinterpret_cast<const Matrix *>(lhs),
263 reinterpret_cast<const Matrix *>(rhs));
264}
265
266static void SC_matrixMultiply(rsc_Matrix *mat, const rsc_Matrix *rhs)
267{
268 Matrix *m = reinterpret_cast<Matrix *>(mat);
269 m->multiply(reinterpret_cast<const Matrix *>(rhs));
270}
271
272static void SC_matrixRotate(rsc_Matrix *mat, float rot, float x, float y, float z)
273{
274 Matrix *m = reinterpret_cast<Matrix *>(mat);
275 m->rotate(rot, x, y, z);
276}
277
278static void SC_matrixScale(rsc_Matrix *mat, float x, float y, float z)
279{
280 Matrix *m = reinterpret_cast<Matrix *>(mat);
281 m->scale(x, y, z);
282}
283
284static void SC_matrixTranslate(rsc_Matrix *mat, float x, float y, float z)
285{
286 Matrix *m = reinterpret_cast<Matrix *>(mat);
287 m->translate(x, y, z);
288}
289
290
Jason Samse45ac6e2009-07-20 14:31:06 -0700291//////////////////////////////////////////////////////////////////////////////
292//
293//////////////////////////////////////////////////////////////////////////////
294
Jason Samsbe36bf32010-05-11 14:03:58 -0700295static uint32_t SC_allocGetDimX(RsAllocation va)
296{
297 GET_TLS();
298 const Allocation *a = static_cast<const Allocation *>(va);
299 //LOGE("SC_allocGetDimX a=%p", a);
300 //LOGE(" type=%p", a->getType());
301 return a->getType()->getDimX();
302}
303
304static uint32_t SC_allocGetDimY(RsAllocation va)
305{
306 GET_TLS();
307 const Allocation *a = static_cast<const Allocation *>(va);
308 return a->getType()->getDimY();
309}
310
311static uint32_t SC_allocGetDimZ(RsAllocation va)
312{
313 GET_TLS();
314 const Allocation *a = static_cast<const Allocation *>(va);
315 return a->getType()->getDimZ();
316}
317
318static uint32_t SC_allocGetDimLOD(RsAllocation va)
319{
320 GET_TLS();
321 const Allocation *a = static_cast<const Allocation *>(va);
322 return a->getType()->getDimLOD();
323}
324
325static uint32_t SC_allocGetDimFaces(RsAllocation va)
326{
327 GET_TLS();
328 const Allocation *a = static_cast<const Allocation *>(va);
329 return a->getType()->getDimFaces();
330}
331
Jason Sams7bf29dd2010-07-19 15:38:19 -0700332const void * SC_getElementAtX(RsAllocation va, uint32_t x)
333{
334 const Allocation *a = static_cast<const Allocation *>(va);
335 const Type *t = a->getType();
336 const uint8_t *p = (const uint8_t *)a->getPtr();
337 return &p[t->getElementSizeBytes() * x];
338}
339
340const void * SC_getElementAtXY(RsAllocation va, uint32_t x, uint32_t y)
341{
342 const Allocation *a = static_cast<const Allocation *>(va);
343 const Type *t = a->getType();
344 const uint8_t *p = (const uint8_t *)a->getPtr();
345 return &p[t->getElementSizeBytes() * (x + y*t->getDimX())];
346}
347
348const void * SC_getElementAtXYZ(RsAllocation va, uint32_t x, uint32_t y, uint32_t z)
349{
350 const Allocation *a = static_cast<const Allocation *>(va);
351 const Type *t = a->getType();
352 const uint8_t *p = (const uint8_t *)a->getPtr();
353 return &p[t->getElementSizeBytes() * (x + y*t->getDimX())];
354}
Jason Samsbe36bf32010-05-11 14:03:58 -0700355
Jason Samse45ac6e2009-07-20 14:31:06 -0700356
Jason Sams22fa3712010-05-19 17:22:57 -0700357static void SC_debugF(const char *s, float f) {
358 LOGE("%s %f, 0x%08x", s, f, *((int *) (&f)));
Jason Samsc9d43db2009-07-28 12:02:16 -0700359}
Jason Sams22fa3712010-05-19 17:22:57 -0700360static void SC_debugFv2(const char *s, rsvF_2 fv) {
361 float *f = (float *)&fv;
362 LOGE("%s {%f, %f}", s, f[0], f[1]);
Romain Guy370ed152009-08-20 17:08:33 -0700363}
Jason Sams22fa3712010-05-19 17:22:57 -0700364static void SC_debugFv3(const char *s, rsvF_4 fv) {
365 float *f = (float *)&fv;
366 LOGE("%s {%f, %f, %f}", s, f[0], f[1], f[2]);
Jason Samsc9d43db2009-07-28 12:02:16 -0700367}
Jason Sams22fa3712010-05-19 17:22:57 -0700368static void SC_debugFv4(const char *s, rsvF_4 fv) {
369 float *f = (float *)&fv;
370 LOGE("%s {%f, %f, %f, %f}", s, f[0], f[1], f[2], f[3]);
371}
372static void SC_debugI32(const char *s, int32_t i) {
373 LOGE("%s %i 0x%x", s, i, i);
Romain Guy370ed152009-08-20 17:08:33 -0700374}
375
Jason Sams7bf29dd2010-07-19 15:38:19 -0700376static void SC_debugP(const char *s, const void *p) {
377 LOGE("%s %p", s, p);
378}
379
Jason Sams8c401ef2009-10-06 13:58:47 -0700380static uint32_t SC_toClient(void *data, int cmdID, int len, int waitForSpace)
381{
382 GET_TLS();
Jason Samsbe36bf32010-05-11 14:03:58 -0700383 //LOGE("SC_toClient %i %i %i", cmdID, len, waitForSpace);
Jason Sams8c401ef2009-10-06 13:58:47 -0700384 return rsc->sendMessageToClient(data, cmdID, len, waitForSpace != 0);
385}
386
Jason Sams3a27c952009-10-07 18:14:01 -0700387static void SC_scriptCall(int scriptID)
388{
389 GET_TLS();
Jason Samsc61346b2010-05-28 18:23:22 -0700390 rsc->runScript((Script *)scriptID);
Jason Sams3a27c952009-10-07 18:14:01 -0700391}
392
Jason Samsbe36bf32010-05-11 14:03:58 -0700393int SC_divsi3(int a, int b)
394{
395 return a / b;
396}
Jason Sams3a27c952009-10-07 18:14:01 -0700397
Jason Samsce92d4b2010-05-17 14:55:34 -0700398int SC_getAllocation(const void *ptr)
399{
400 GET_TLS();
401 const Allocation *alloc = sc->ptrToAllocation(ptr);
402 return (int)alloc;
403}
404
405
Jason Samsace3e012010-07-15 17:11:13 -0700406void SC_ForEach(RsScript vs,
407 RsAllocation vin,
408 RsAllocation vout,
409 const void *usr)
Jason Samsc61346b2010-05-28 18:23:22 -0700410{
411 GET_TLS();
Jason Samsace3e012010-07-15 17:11:13 -0700412 const Allocation *ain = static_cast<const Allocation *>(vin);
Jason Samsc61346b2010-05-28 18:23:22 -0700413 Allocation *aout = static_cast<Allocation *>(vout);
Jason Samsace3e012010-07-15 17:11:13 -0700414 Script *s = static_cast<Script *>(vs);
415 s->runForEach(rsc, ain, aout, usr);
Jason Samsc61346b2010-05-28 18:23:22 -0700416}
417
Jason Samsace3e012010-07-15 17:11:13 -0700418void SC_ForEach2(RsScript vs,
419 RsAllocation vin,
420 RsAllocation vout,
421 const void *usr,
422 const RsScriptCall *call)
Jason Samsc61346b2010-05-28 18:23:22 -0700423{
424 GET_TLS();
Jason Samsace3e012010-07-15 17:11:13 -0700425 const Allocation *ain = static_cast<const Allocation *>(vin);
Jason Samsc61346b2010-05-28 18:23:22 -0700426 Allocation *aout = static_cast<Allocation *>(vout);
Jason Samsc61346b2010-05-28 18:23:22 -0700427 Script *s = static_cast<Script *>(vs);
Jason Samsace3e012010-07-15 17:11:13 -0700428 s->runForEach(rsc, ain, aout, usr, call);
Jason Samsc61346b2010-05-28 18:23:22 -0700429}
430
Jason Samse45ac6e2009-07-20 14:31:06 -0700431//////////////////////////////////////////////////////////////////////////////
432// Class implementation
433//////////////////////////////////////////////////////////////////////////////
434
Jason Samsbe36bf32010-05-11 14:03:58 -0700435// llvm name mangling ref
436// <builtin-type> ::= v # void
437// ::= b # bool
438// ::= c # char
439// ::= a # signed char
440// ::= h # unsigned char
441// ::= s # short
442// ::= t # unsigned short
443// ::= i # int
444// ::= j # unsigned int
445// ::= l # long
446// ::= m # unsigned long
447// ::= x # long long, __int64
448// ::= y # unsigned long long, __int64
449// ::= f # float
450// ::= d # double
Jason Samse45ac6e2009-07-20 14:31:06 -0700451
Jason Samsaeb094b2010-05-18 13:35:45 -0700452static ScriptCState::SymbolTable_t gSyms[] = {
Jason Samsbe36bf32010-05-11 14:03:58 -0700453 { "__divsi3", (void *)&SC_divsi3 },
454
Jason Sams22fa3712010-05-19 17:22:57 -0700455 // allocation
456 { "rsAllocationGetDimX", (void *)&SC_allocGetDimX },
457 { "rsAllocationGetDimY", (void *)&SC_allocGetDimY },
458 { "rsAllocationGetDimZ", (void *)&SC_allocGetDimZ },
459 { "rsAllocationGetDimLOD", (void *)&SC_allocGetDimLOD },
460 { "rsAllocationGetDimFaces", (void *)&SC_allocGetDimFaces },
461 { "rsGetAllocation", (void *)&SC_getAllocation },
462
Jason Sams7bf29dd2010-07-19 15:38:19 -0700463 { "_Z14rsGetElementAt13rs_allocationj", (void *)&SC_getElementAtX },
464 { "_Z14rsGetElementAt13rs_allocationjj", (void *)&SC_getElementAtXY },
465 { "_Z14rsGetElementAt13rs_allocationjjj", (void *)&SC_getElementAtXYZ },
466
467
Jason Sams22fa3712010-05-19 17:22:57 -0700468 // Debug
469 { "_Z7rsDebugPKcf", (void *)&SC_debugF },
470 { "_Z7rsDebugPKcDv2_f", (void *)&SC_debugFv2 },
471 { "_Z7rsDebugPKcDv3_f", (void *)&SC_debugFv3 },
472 { "_Z7rsDebugPKcDv4_f", (void *)&SC_debugFv4 },
473 { "_Z7rsDebugPKci", (void *)&SC_debugI32 },
Jason Sams7bf29dd2010-07-19 15:38:19 -0700474 { "_Z7rsDebugPKcPKv", (void *)&SC_debugP },
Jason Sams22fa3712010-05-19 17:22:57 -0700475 //extern void __attribute__((overloadable))rsDebug(const char *, const void *);
476
477
478 // RS Math
479 { "_Z6rsRandi", (void *)&SC_randi },
480 { "_Z6rsRandii", (void *)&SC_randi2 },
481 { "_Z6rsRandf", (void *)&SC_randf },
482 { "_Z6rsRandff", (void *)&SC_randf2 },
483 { "_Z6rsFracf", (void *)&SC_frac },
484
485 // time
486 { "rsSecond", (void *)&SC_second },
487 { "rsMinute", (void *)&SC_minute },
488 { "rsHour", (void *)&SC_hour },
489 { "rsDay", (void *)&SC_day },
490 { "rsMonth", (void *)&SC_month },
491 { "rsYear", (void *)&SC_year },
492 { "rsUptimeMillis", (void*)&SC_uptimeMillis2 },
493 { "rsStartTimeMillis", (void*)&SC_startTimeMillis2 },
494 { "rsElapsedTimeMillis", (void*)&SC_elapsedTimeMillis2 },
495
496 { "rsSendToClient", (void *)&SC_toClient },
497
498 // matrix
499 { "rsMatrixLoadIdentity", (void *)&SC_matrixLoadIdentity },
500 { "rsMatrixLoadFloat", (void *)&SC_matrixLoadFloat },
501 { "rsMatrixLoadMat", (void *)&SC_matrixLoadMat },
502 { "rsMatrixLoadRotate", (void *)&SC_matrixLoadRotate },
503 { "rsMatrixLoadScale", (void *)&SC_matrixLoadScale },
504 { "rsMatrixLoadTranslate", (void *)&SC_matrixLoadTranslate },
505 { "rsMatrixLoadMultiply", (void *)&SC_matrixLoadMultiply },
506 { "rsMatrixMultiply", (void *)&SC_matrixMultiply },
507 { "rsMatrixRotate", (void *)&SC_matrixRotate },
508 { "rsMatrixScale", (void *)&SC_matrixScale },
509 { "rsMatrixTranslate", (void *)&SC_matrixTranslate },
510
Jason Samsace3e012010-07-15 17:11:13 -0700511 { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach },
512 //{ "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach2 },
Jason Sams22fa3712010-05-19 17:22:57 -0700513
514////////////////////////////////////////////////////////////////////
515
Jason Samsbe36bf32010-05-11 14:03:58 -0700516 //{ "sinf_fast", (void *)&SC_sinf_fast },
517 //{ "cosf_fast", (void *)&SC_cosf_fast },
Jason Samse45ac6e2009-07-20 14:31:06 -0700518
Jason Samsbe36bf32010-05-11 14:03:58 -0700519 { "scriptCall", (void *)&SC_scriptCall },
Jason Samsce92d4b2010-05-17 14:55:34 -0700520
Jason Samsc9d43db2009-07-28 12:02:16 -0700521
Jason Samsbe36bf32010-05-11 14:03:58 -0700522 { NULL, NULL }
Jason Samse45ac6e2009-07-20 14:31:06 -0700523};
524
525const ScriptCState::SymbolTable_t * ScriptCState::lookupSymbol(const char *sym)
526{
527 ScriptCState::SymbolTable_t *syms = gSyms;
528
529 while (syms->mPtr) {
530 if (!strcmp(syms->mName, sym)) {
531 return syms;
532 }
533 syms++;
534 }
535 return NULL;
536}
537