Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
Jack Palevich | ec5a20b | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 24 | struct ACCscript; |
| 25 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 26 | // --------------------------------------------------------------------------- |
| 27 | namespace android { |
| 28 | namespace renderscript { |
| 29 | |
Jack Palevich | ec5a20b | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 30 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 31 | |
| 32 | class ScriptC : public Script |
| 33 | { |
| 34 | public: |
Jason Sams | c97bb88 | 2009-07-20 14:31:06 -0700 | [diff] [blame^] | 35 | typedef int (*RunScript_t)(uint32_t launchIndex); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 36 | |
| 37 | ScriptC(); |
| 38 | virtual ~ScriptC(); |
| 39 | |
Jason Sams | 3a833d8 | 2009-06-08 15:20:31 -0700 | [diff] [blame] | 40 | struct Program_t { |
| 41 | const char * mScriptText; |
| 42 | uint32_t mScriptTextLength; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 43 | |
Jason Sams | 928f5cf | 2009-06-08 18:50:13 -0700 | [diff] [blame] | 44 | |
| 45 | int mVersionMajor; |
| 46 | int mVersionMinor; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 47 | |
Jason Sams | c97bb88 | 2009-07-20 14:31:06 -0700 | [diff] [blame^] | 48 | RunScript_t mScript; |
Jason Sams | 3a833d8 | 2009-06-08 15:20:31 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
Jason Sams | 3a833d8 | 2009-06-08 15:20:31 -0700 | [diff] [blame] | 51 | Program_t mProgram; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 52 | |
Jack Palevich | ec5a20b | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 53 | ACCscript* mAccScript; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 54 | |
Jason Sams | 3a833d8 | 2009-06-08 15:20:31 -0700 | [diff] [blame] | 55 | virtual bool run(Context *, uint32_t launchID); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 56 | }; |
| 57 | |
Jack Palevich | ec5a20b | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 58 | class ScriptCState |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 59 | { |
| 60 | public: |
| 61 | ScriptCState(); |
| 62 | ~ScriptCState(); |
| 63 | |
Jason Sams | 39ddc950 | 2009-06-05 17:35:09 -0700 | [diff] [blame] | 64 | ACCscript* mAccScript; |
Jason Sams | 3a833d8 | 2009-06-08 15:20:31 -0700 | [diff] [blame] | 65 | |
| 66 | ScriptC::Program_t mProgram; |
Jason Sams | da423d8 | 2009-06-09 12:15:30 -0700 | [diff] [blame] | 67 | Script::Enviroment_t mEnviroment; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 68 | |
| 69 | Vector<const Type *> mConstantBufferTypes; |
| 70 | |
| 71 | void clear(); |
Jason Sams | 3eaa338 | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 72 | void runCompiler(Context *rsc); |
Jason Sams | 54440a0 | 2009-07-16 15:08:06 -0700 | [diff] [blame] | 73 | |
| 74 | struct SymbolTable_t { |
| 75 | const char * mName; |
| 76 | void * mPtr; |
Jason Sams | c97bb88 | 2009-07-20 14:31:06 -0700 | [diff] [blame^] | 77 | const char * mRet; |
| 78 | const char * mParam; |
Jason Sams | 54440a0 | 2009-07-16 15:08:06 -0700 | [diff] [blame] | 79 | }; |
| 80 | static SymbolTable_t gSyms[]; |
| 81 | static const SymbolTable_t * lookupSymbol(const char *); |
Jason Sams | 764205c | 2009-07-16 17:47:40 -0700 | [diff] [blame] | 82 | static void appendDecls(String8 *str); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | |
| 86 | } |
| 87 | } |
| 88 | #endif |
| 89 | |
| 90 | |
| 91 | |