blob: 8aa99eff49dee5916fb951d2522d8ef77a64b7a4 [file] [log] [blame]
Jason Sams326e0dd2009-05-22 14:03:28 -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#ifndef ANDROID_RS_SCRIPT_C_H
18#define ANDROID_RS_SCRIPT_C_H
19
20#include "rsScript.h"
21
22#include "RenderScriptEnv.h"
23
Joe Onorato57b79ce2009-08-09 22:57:44 -070024#include <utils/KeyedVector.h>
25
Jack Palevich1ef8b802009-05-28 15:53:04 -070026struct ACCscript;
27
Jason Sams326e0dd2009-05-22 14:03:28 -070028// ---------------------------------------------------------------------------
29namespace android {
30namespace renderscript {
31
Jack Palevich1ef8b802009-05-28 15:53:04 -070032
Jason Sams326e0dd2009-05-22 14:03:28 -070033
34class ScriptC : public Script
35{
36public:
Jason Samse45ac6e2009-07-20 14:31:06 -070037 typedef int (*RunScript_t)(uint32_t launchIndex);
Jason Sams1d54f102009-09-03 15:43:13 -070038 typedef void (*VoidFunc_t)();
Jason Sams326e0dd2009-05-22 14:03:28 -070039
40 ScriptC();
41 virtual ~ScriptC();
42
Jason Samsefb8de12009-06-08 15:20:31 -070043 struct Program_t {
44 const char * mScriptText;
45 uint32_t mScriptTextLength;
Jason Sams326e0dd2009-05-22 14:03:28 -070046
Jason Sams928b7342009-06-08 18:50:13 -070047
48 int mVersionMajor;
49 int mVersionMinor;
Jason Sams326e0dd2009-05-22 14:03:28 -070050
Jason Samse45ac6e2009-07-20 14:31:06 -070051 RunScript_t mScript;
Jason Sams1d54f102009-09-03 15:43:13 -070052 VoidFunc_t mInit;
53
54 void ** mSlotPointers[MAX_SCRIPT_BANKS];
Jason Samsefb8de12009-06-08 15:20:31 -070055 };
56
Jason Samsefb8de12009-06-08 15:20:31 -070057 Program_t mProgram;
Jason Sams326e0dd2009-05-22 14:03:28 -070058
Jack Palevich1ef8b802009-05-28 15:53:04 -070059 ACCscript* mAccScript;
Jason Sams326e0dd2009-05-22 14:03:28 -070060
Jason Samsefb8de12009-06-08 15:20:31 -070061 virtual bool run(Context *, uint32_t launchID);
Jason Sams326e0dd2009-05-22 14:03:28 -070062};
63
Jack Palevich1ef8b802009-05-28 15:53:04 -070064class ScriptCState
Jason Sams326e0dd2009-05-22 14:03:28 -070065{
66public:
67 ScriptCState();
68 ~ScriptCState();
69
Jason Sams1f526332009-06-05 17:35:09 -070070 ACCscript* mAccScript;
Jason Samsefb8de12009-06-08 15:20:31 -070071
72 ScriptC::Program_t mProgram;
Jason Sams10308932009-06-09 12:15:30 -070073 Script::Enviroment_t mEnviroment;
Jason Sams326e0dd2009-05-22 14:03:28 -070074
Jason Sams8b2c0652009-08-12 17:54:11 -070075 ObjectBaseRef<const Type> mConstantBufferTypes[MAX_SCRIPT_BANKS];
Jason Samsfa517192009-08-13 12:59:04 -070076 String8 mSlotNames[MAX_SCRIPT_BANKS];
Jason Sams90b36a82009-08-17 13:56:09 -070077 bool mSlotWritable[MAX_SCRIPT_BANKS];
Jason Sams326e0dd2009-05-22 14:03:28 -070078
79 void clear();
Jason Samsa0a1b6f2009-06-10 15:04:38 -070080 void runCompiler(Context *rsc);
Joe Onorato57b79ce2009-08-09 22:57:44 -070081 void appendVarDefines(String8 *str);
Jason Sams8b2c0652009-08-12 17:54:11 -070082 void appendTypes(String8 *str);
Jason Sams29df66f2009-07-16 15:08:06 -070083
84 struct SymbolTable_t {
85 const char * mName;
86 void * mPtr;
Jason Samse45ac6e2009-07-20 14:31:06 -070087 const char * mRet;
88 const char * mParam;
Jason Sams29df66f2009-07-16 15:08:06 -070089 };
90 static SymbolTable_t gSyms[];
91 static const SymbolTable_t * lookupSymbol(const char *);
Jason Samsf1685042009-07-16 17:47:40 -070092 static void appendDecls(String8 *str);
Joe Onorato57b79ce2009-08-09 22:57:44 -070093
94 KeyedVector<String8,int> mInt32Defines;
95 KeyedVector<String8,float> mFloatDefines;
Jason Sams326e0dd2009-05-22 14:03:28 -070096};
97
98
99}
100}
101#endif
102
103
104