rsScriptC.h revision f4d216ee0f0ef18edbde208a61dc4e2fe4c8f050
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 "rsEnv.h" 21#include "rsScript.h" 22 23#if !defined(RS_COMPATIBILITY_LIB) && !defined(ANDROID_RS_SERIALIZE) 24#include "bcinfo/BitcodeTranslator.h" 25#endif 26 27// --------------------------------------------------------------------------- 28namespace android { 29namespace renderscript { 30 31 32/** This class represents a script compiled from an .rs file. */ 33class ScriptC : public Script { 34public: 35 typedef int (*RunScript_t)(); 36 typedef void (*VoidFunc_t)(); 37 38 ScriptC(Context *); 39 virtual ~ScriptC(); 40 41 virtual void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len); 42 43 virtual uint32_t run(Context *); 44 45 virtual void runForEach(Context *rsc, 46 uint32_t slot, 47 const Allocation * ain, 48 Allocation * aout, 49 const void * usr, 50 size_t usrBytes, 51 const RsScriptCall *sc = NULL); 52 53 virtual void serialize(Context *rsc, OStream *stream) const { } 54 virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SCRIPT_C; } 55 static Type *createFromStream(Context *rsc, IStream *stream) { return NULL; } 56 57 bool runCompiler(Context *rsc, const char *resName, const char *cacheDir, 58 const uint8_t *bitcode, size_t bitcodeLen); 59 60//protected: 61 void setupScript(Context *); 62 void setupGLState(Context *); 63private: 64#if !defined(RS_COMPATIBILITY_LIB) && !defined(ANDROID_RS_SERIALIZE) 65 bcinfo::BitcodeTranslator *BT; 66#endif 67 68#if !defined(RS_COMPATIBILITY_LIB) 69 bool createCacheDir(const char *cacheDir); 70#endif 71}; 72 73} 74} 75#endif 76