Home | History | Annotate | Download | only in rs_support
      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 // ---------------------------------------------------------------------------
     25 namespace android {
     26 namespace renderscript {
     27 
     28 
     29 class ScriptC : public Script {
     30 public:
     31     typedef int (*RunScript_t)();
     32     typedef void (*VoidFunc_t)();
     33 
     34     ScriptC(Context *);
     35     virtual ~ScriptC();
     36 
     37     virtual void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len);
     38 
     39     virtual uint32_t run(Context *);
     40 
     41     virtual void runForEach(Context *rsc,
     42                             uint32_t slot,
     43                             const Allocation * ain,
     44                             Allocation * aout,
     45                             const void * usr,
     46                             size_t usrBytes,
     47                             const RsScriptCall *sc = NULL);
     48 
     49     virtual void serialize(Context *rsc, OStream *stream) const {    }
     50     virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SCRIPT_C; }
     51     static Type *createFromStream(Context *rsc, IStream *stream) { return NULL; }
     52 
     53     bool runCompiler(Context *rsc, const char *resName, const char *cacheDir,
     54                      const uint8_t *bitcode, size_t bitcodeLen);
     55 
     56 //protected:
     57     void setupScript(Context *);
     58     void setupGLState(Context *);
     59     Script * setTLS(Script *);
     60 };
     61 
     62 class ScriptCState {
     63 public:
     64     ScriptCState();
     65     ~ScriptCState();
     66 
     67     char * mScriptText;
     68     size_t mScriptLen;
     69 
     70     struct SymbolTable_t {
     71         const char * mName;
     72         void * mPtr;
     73         bool threadable;
     74     };
     75     static const SymbolTable_t * lookupSymbol(const char *);
     76     static const SymbolTable_t * lookupSymbolCL(const char *);
     77     static const SymbolTable_t * lookupSymbolGL(const char *);
     78 };
     79 
     80 
     81 }
     82 }
     83 #endif
     84