rsScriptC.h revision b81a0eb8180791e4eaab1253b59fa8bd562b046b
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
24
25// ---------------------------------------------------------------------------
26namespace android {
27namespace renderscript {
28
29
30class ScriptC : public Script {
31public:
32    typedef int (*RunScript_t)();
33    typedef void (*VoidFunc_t)();
34
35    ScriptC(Context *);
36    virtual ~ScriptC();
37
38
39    const Allocation *ptrToAllocation(const void *) const;
40
41
42    virtual void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len);
43
44    virtual uint32_t run(Context *);
45
46    virtual void runForEach(Context *rsc,
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(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 *);
63    Script * setTLS(Script *);
64};
65
66class ScriptCState {
67public:
68    ScriptCState();
69    ~ScriptCState();
70
71    char * mScriptText;
72    size_t mScriptLen;
73
74    struct SymbolTable_t {
75        const char * mName;
76        void * mPtr;
77        bool threadable;
78    };
79    static const SymbolTable_t * lookupSymbol(const char *);
80    static const SymbolTable_t * lookupSymbolCL(const char *);
81    static const SymbolTable_t * lookupSymbolGL(const char *);
82};
83
84
85}
86}
87#endif
88