rsScriptC.h revision 700ba38f022208686523ab4280c4fc9f102aa273
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,
61                            const Allocation * ain,
62                            Allocation * aout,
63                            const void * usr,
64                            const RsScriptCall *sc = NULL);
65
66    virtual void serialize(OStream *stream) const {    }
67    virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SCRIPT_C; }
68    static Type *createFromStream(Context *rsc, IStream *stream) { return NULL; }
69
70protected:
71    void setupScript(Context *);
72    void setupGLState(Context *);
73    Script * setTLS(Script *);
74};
75
76class ScriptCState
77{
78public:
79    ScriptCState();
80    ~ScriptCState();
81
82    ObjectBaseRef<ScriptC> mScript;
83
84    void init(Context *rsc);
85
86    void clear(Context *rsc);
87    void runCompiler(Context *rsc, ScriptC *s);
88
89    struct SymbolTable_t {
90        const char * mName;
91        void * mPtr;
92    };
93    //static SymbolTable_t gSyms[];
94    static const SymbolTable_t * lookupSymbol(const char *);
95    static const SymbolTable_t * lookupSymbolCL(const char *);
96    static const SymbolTable_t * lookupSymbolGL(const char *);
97};
98
99
100}
101}
102#endif
103
104
105
106