rsScriptC.h revision 93eacc7ce0aad4314b4cb41a281f59ce54bb3286
1/* 2 * Copyright (C) 2009-2012 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 "rsEnv.h" 23 24#ifndef RS_COMPATIBILITY_LIB 25#ifndef ANDROID_RS_SERIALIZE 26#include "bcinfo/BitcodeTranslator.h" 27#endif 28#endif 29 30// --------------------------------------------------------------------------- 31namespace android { 32namespace renderscript { 33 34 35class ScriptC : public Script { 36public: 37 typedef int (*RunScript_t)(); 38 typedef void (*VoidFunc_t)(); 39 40 ScriptC(Context *); 41 virtual ~ScriptC(); 42 43 virtual void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len); 44 45 virtual uint32_t run(Context *); 46 47 virtual void runForEach(Context *rsc, 48 uint32_t slot, 49 const Allocation * ain, 50 Allocation * aout, 51 const void * usr, 52 size_t usrBytes, 53 const RsScriptCall *sc = NULL); 54 55 virtual void serialize(Context *rsc, OStream *stream) const { } 56 virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SCRIPT_C; } 57 static Type *createFromStream(Context *rsc, IStream *stream) { return NULL; } 58 59 bool runCompiler(Context *rsc, const char *resName, const char *cacheDir, 60 const uint8_t *bitcode, size_t bitcodeLen); 61 62//protected: 63 void setupScript(Context *); 64 void setupGLState(Context *); 65private: 66#ifndef RS_COMPATIBILITY_LIB 67#ifndef ANDROID_RS_SERIALIZE 68 bcinfo::BitcodeTranslator *BT; 69#endif 70 71 bool createCacheDir(const char *cacheDir); 72#endif 73}; 74 75class ScriptCState { 76public: 77 ScriptCState(); 78 ~ScriptCState(); 79 80 char * mScriptText; 81 size_t mScriptLen; 82 83 struct SymbolTable_t { 84 const char * mName; 85 void * mPtr; 86 bool threadable; 87 }; 88 static const SymbolTable_t * lookupSymbol(const char *); 89 static const SymbolTable_t * lookupSymbolCL(const char *); 90 static const SymbolTable_t * lookupSymbolGL(const char *); 91}; 92 93 94} 95} 96#endif 97