rsScriptC.h revision 57b79ceb1126e3797fa42367b97dd7bcfcda1ed9
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
39    ScriptC();
40    virtual ~ScriptC();
41
42    struct Program_t {
43        const char * mScriptText;
44        uint32_t mScriptTextLength;
45
46
47        int mVersionMajor;
48        int mVersionMinor;
49
50        RunScript_t mScript;
51    };
52
53    Program_t mProgram;
54
55    ACCscript*    mAccScript;
56
57    virtual bool run(Context *, uint32_t launchID);
58};
59
60class ScriptCState
61{
62public:
63    ScriptCState();
64    ~ScriptCState();
65
66    ACCscript* mAccScript;
67
68    ScriptC::Program_t mProgram;
69    Script::Enviroment_t mEnviroment;
70
71    Vector<const Type *> mConstantBufferTypes;
72
73    void clear();
74    void runCompiler(Context *rsc);
75    void appendVarDefines(String8 *str);
76
77    struct SymbolTable_t {
78        const char * mName;
79        void * mPtr;
80        const char * mRet;
81        const char * mParam;
82    };
83    static SymbolTable_t gSyms[];
84    static const SymbolTable_t * lookupSymbol(const char *);
85    static void appendDecls(String8 *str);
86
87    KeyedVector<String8,int> mInt32Defines;
88    KeyedVector<String8,float> mFloatDefines;
89};
90
91
92}
93}
94#endif
95
96
97
98