blob: ad0e3ee13928fa12a6cd4397de062da58b174ee7 [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 Samsd19f10d2009-05-22 14:03:28 -070038
39 ScriptC();
40 virtual ~ScriptC();
41
Jason Sams3a833d82009-06-08 15:20:31 -070042 struct Program_t {
43 const char * mScriptText;
44 uint32_t mScriptTextLength;
Jason Samsd19f10d2009-05-22 14:03:28 -070045
Jason Sams928f5cf2009-06-08 18:50:13 -070046
47 int mVersionMajor;
48 int mVersionMinor;
Jason Samsd19f10d2009-05-22 14:03:28 -070049
Jason Samsc97bb882009-07-20 14:31:06 -070050 RunScript_t mScript;
Jason Sams3a833d82009-06-08 15:20:31 -070051 };
52
Jason Sams3a833d82009-06-08 15:20:31 -070053 Program_t mProgram;
Jason Samsd19f10d2009-05-22 14:03:28 -070054
Jack Palevichec5a20b2009-05-28 15:53:04 -070055 ACCscript* mAccScript;
Jason Samsd19f10d2009-05-22 14:03:28 -070056
Jason Sams3a833d82009-06-08 15:20:31 -070057 virtual bool run(Context *, uint32_t launchID);
Jason Samsd19f10d2009-05-22 14:03:28 -070058};
59
Jack Palevichec5a20b2009-05-28 15:53:04 -070060class ScriptCState
Jason Samsd19f10d2009-05-22 14:03:28 -070061{
62public:
63 ScriptCState();
64 ~ScriptCState();
65
Jason Sams39ddc9502009-06-05 17:35:09 -070066 ACCscript* mAccScript;
Jason Sams3a833d82009-06-08 15:20:31 -070067
68 ScriptC::Program_t mProgram;
Jason Samsda423d82009-06-09 12:15:30 -070069 Script::Enviroment_t mEnviroment;
Jason Samsd19f10d2009-05-22 14:03:28 -070070
71 Vector<const Type *> mConstantBufferTypes;
72
73 void clear();
Jason Sams3eaa3382009-06-10 15:04:38 -070074 void runCompiler(Context *rsc);
Joe Onoratod7b37742009-08-09 22:57:44 -070075 void appendVarDefines(String8 *str);
Jason Sams54440a02009-07-16 15:08:06 -070076
77 struct SymbolTable_t {
78 const char * mName;
79 void * mPtr;
Jason Samsc97bb882009-07-20 14:31:06 -070080 const char * mRet;
81 const char * mParam;
Jason Sams54440a02009-07-16 15:08:06 -070082 };
83 static SymbolTable_t gSyms[];
84 static const SymbolTable_t * lookupSymbol(const char *);
Jason Sams764205c2009-07-16 17:47:40 -070085 static void appendDecls(String8 *str);
Joe Onoratod7b37742009-08-09 22:57:44 -070086
87 KeyedVector<String8,int> mInt32Defines;
88 KeyedVector<String8,float> mFloatDefines;
Jason Samsd19f10d2009-05-22 14:03:28 -070089};
90
91
92}
93}
94#endif
95
96
97