blob: ae124b45e741d32177cfcfee14a9f7379fd0c1eb [file] [log] [blame]
Jason Samsd19f10d2009-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 Onoratod7b37742009-08-09 22:57:44 -070024#include <utils/KeyedVector.h>
25
Jack Palevichec5a20b2009-05-28 15:53:04 -070026struct ACCscript;
27
Jason Samsd19f10d2009-05-22 14:03:28 -070028// ---------------------------------------------------------------------------
29namespace android {
30namespace renderscript {
31
Jack Palevichec5a20b2009-05-28 15:53:04 -070032
Jason Samsd19f10d2009-05-22 14:03:28 -070033
34class ScriptC : public Script
35{
36public:
Jason Samsc97bb882009-07-20 14:31:06 -070037 typedef int (*RunScript_t)(uint32_t launchIndex);
Jason Sams2525a812009-09-03 15:43:13 -070038 typedef void (*VoidFunc_t)();
Jason Samsd19f10d2009-05-22 14:03:28 -070039
Jason Samsa9e7a052009-09-25 14:51:22 -070040 ScriptC(Context *);
Jason Samsd19f10d2009-05-22 14:03:28 -070041 virtual ~ScriptC();
42
Jason Sams3a833d82009-06-08 15:20:31 -070043 struct Program_t {
44 const char * mScriptText;
45 uint32_t mScriptTextLength;
Jason Samsd19f10d2009-05-22 14:03:28 -070046
Jason Sams928f5cf2009-06-08 18:50:13 -070047
48 int mVersionMajor;
49 int mVersionMinor;
Jason Samsd19f10d2009-05-22 14:03:28 -070050
Jason Samsc97bb882009-07-20 14:31:06 -070051 RunScript_t mScript;
Jason Sams2525a812009-09-03 15:43:13 -070052 VoidFunc_t mInit;
53
54 void ** mSlotPointers[MAX_SCRIPT_BANKS];
Jason Sams3a833d82009-06-08 15:20:31 -070055 };
56
Jason Sams3a833d82009-06-08 15:20:31 -070057 Program_t mProgram;
Jason Samsd19f10d2009-05-22 14:03:28 -070058
Jack Palevichec5a20b2009-05-28 15:53:04 -070059 ACCscript* mAccScript;
Jason Samsd19f10d2009-05-22 14:03:28 -070060
Jason Samse60446b2009-09-24 14:55:38 -070061 virtual void setupScript();
Jason Sams3a833d82009-06-08 15:20:31 -070062 virtual bool run(Context *, uint32_t launchID);
Jason Samsd19f10d2009-05-22 14:03:28 -070063};
64
Jack Palevichec5a20b2009-05-28 15:53:04 -070065class ScriptCState
Jason Samsd19f10d2009-05-22 14:03:28 -070066{
67public:
68 ScriptCState();
69 ~ScriptCState();
70
Jason Samsbe2e8412009-09-16 15:04:38 -070071 ScriptC *mScript;
Jason Samsd19f10d2009-05-22 14:03:28 -070072
Jason Sams43ee06852009-08-12 17:54:11 -070073 ObjectBaseRef<const Type> mConstantBufferTypes[MAX_SCRIPT_BANKS];
Jason Samsfbf0b9e2009-08-13 12:59:04 -070074 String8 mSlotNames[MAX_SCRIPT_BANKS];
Jason Sams334ea0c2009-08-17 13:56:09 -070075 bool mSlotWritable[MAX_SCRIPT_BANKS];
Jason Samsbe2e8412009-09-16 15:04:38 -070076 String8 mInvokableNames[MAX_SCRIPT_BANKS];
Jason Samsd19f10d2009-05-22 14:03:28 -070077
78 void clear();
Jason Samsbe2e8412009-09-16 15:04:38 -070079 void runCompiler(Context *rsc, ScriptC *s);
Jason Sams66b27712009-09-25 15:25:00 -070080 void appendVarDefines(const Context *rsc, String8 *str);
81 void appendTypes(const Context *rsc, String8 *str);
Jason Sams54440a02009-07-16 15:08:06 -070082
83 struct SymbolTable_t {
84 const char * mName;
85 void * mPtr;
Jason Samsc97bb882009-07-20 14:31:06 -070086 const char * mRet;
87 const char * mParam;
Jason Sams54440a02009-07-16 15:08:06 -070088 };
89 static SymbolTable_t gSyms[];
90 static const SymbolTable_t * lookupSymbol(const char *);
Jason Sams764205c2009-07-16 17:47:40 -070091 static void appendDecls(String8 *str);
Joe Onoratod7b37742009-08-09 22:57:44 -070092
93 KeyedVector<String8,int> mInt32Defines;
94 KeyedVector<String8,float> mFloatDefines;
Jason Samsd19f10d2009-05-22 14:03:28 -070095};
96
97
98}
99}
100#endif
101
102
103