rsScriptC.h revision 02000b3cdcb2ac369bd06313932b26d4b8e023a9
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 24struct BCCOpaqueScript; 25 26// --------------------------------------------------------------------------- 27namespace android { 28namespace renderscript { 29 30 31class ScriptC : public Script { 32public: 33 typedef int (*RunScript_t)(); 34 typedef void (*VoidFunc_t)(); 35 36 ScriptC(Context *); 37 virtual ~ScriptC(); 38 39 struct Program_t { 40 int mVersionMajor; 41 int mVersionMinor; 42 43 RunScript_t mRoot; 44 VoidFunc_t mInit; 45 46 uint32_t * mObjectSlotList; 47 uint32_t mObjectSlotCount; 48 }; 49 50 51 Program_t mProgram; 52 53 BCCOpaqueScript *mBccScript; 54 55 const Allocation *ptrToAllocation(const void *) const; 56 57 58 virtual void Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len); 59 60 virtual uint32_t run(Context *); 61 62 virtual void runForEach(Context *rsc, 63 const Allocation * ain, 64 Allocation * aout, 65 const void * usr, 66 const RsScriptCall *sc = NULL); 67 68 virtual void serialize(OStream *stream) const { } 69 virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SCRIPT_C; } 70 static Type *createFromStream(Context *rsc, IStream *stream) { return NULL; } 71 72protected: 73 void setupScript(Context *); 74 void setupGLState(Context *); 75 Script * setTLS(Script *); 76}; 77 78class ScriptCState { 79public: 80 ScriptCState(); 81 ~ScriptCState(); 82 83 char * mScriptText; 84 size_t mScriptLen; 85 86 bool runCompiler(Context *rsc, ScriptC *s, const char *resName, const char *cacheDir); 87 88 struct SymbolTable_t { 89 const char * mName; 90 void * mPtr; 91 bool threadable; 92 }; 93 static const SymbolTable_t * lookupSymbol(const char *); 94 static const SymbolTable_t * lookupSymbolCL(const char *); 95 static const SymbolTable_t * lookupSymbolGL(const char *); 96}; 97 98 99} 100} 101#endif 102