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