rsScriptC.h revision ada7f272890d8791bc518c95989ad7d13050834d
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#include <utils/KeyedVector.h>
25
26struct ACCscript;
27
28// ---------------------------------------------------------------------------
29namespace android {
30namespace renderscript {
31
32
33
34class ScriptC : public Script
35{
36public:
37    typedef int (*RunScript_t)(uint32_t launchIndex);
38    typedef void (*VoidFunc_t)();
39
40    ScriptC();
41    virtual ~ScriptC();
42
43    struct Program_t {
44        const char * mScriptText;
45        uint32_t mScriptTextLength;
46
47
48        int mVersionMajor;
49        int mVersionMinor;
50
51        RunScript_t mScript;
52        VoidFunc_t mInit;
53
54        void ** mSlotPointers[MAX_SCRIPT_BANKS];
55    };
56
57    Program_t mProgram;
58
59    ACCscript*    mAccScript;
60
61    virtual void setupScript();
62    virtual bool run(Context *, uint32_t launchID);
63};
64
65class ScriptCState
66{
67public:
68    ScriptCState();
69    ~ScriptCState();
70
71    ScriptC *mScript;
72
73    ObjectBaseRef<const Type> mConstantBufferTypes[MAX_SCRIPT_BANKS];
74    String8 mSlotNames[MAX_SCRIPT_BANKS];
75    bool mSlotWritable[MAX_SCRIPT_BANKS];
76    String8 mInvokableNames[MAX_SCRIPT_BANKS];
77
78    void clear();
79    void runCompiler(Context *rsc, ScriptC *s);
80    void appendVarDefines(String8 *str);
81    void appendTypes(String8 *str);
82
83    struct SymbolTable_t {
84        const char * mName;
85        void * mPtr;
86        const char * mRet;
87        const char * mParam;
88    };
89    static SymbolTable_t gSyms[];
90    static const SymbolTable_t * lookupSymbol(const char *);
91    static void appendDecls(String8 *str);
92
93    KeyedVector<String8,int> mInt32Defines;
94    KeyedVector<String8,float> mFloatDefines;
95};
96
97
98}
99}
100#endif
101
102
103
104