rsScript.h revision dd663fa8367bfacb6c77b368f91adf614cd0beba
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_H
18#define ANDROID_RS_SCRIPT_H
19
20#include "rsAllocation.h"
21
22
23// ---------------------------------------------------------------------------
24namespace android {
25namespace renderscript {
26
27class ProgramVertex;
28class ProgramFragment;
29class ProgramRaster;
30class ProgramStore;
31
32#define MAX_SCRIPT_BANKS 32
33
34class Script : public ObjectBase
35{
36public:
37    typedef void (* InvokeFunc_t)(void);
38
39    Script(Context *);
40    virtual ~Script();
41
42    struct Enviroment_t {
43        int64_t mStartTimeMillis;
44        int64_t mLastDtTime;
45        const char* mTimeZone;
46
47        ObjectBaseRef<ProgramVertex> mVertex;
48        ObjectBaseRef<ProgramFragment> mFragment;
49        ObjectBaseRef<ProgramRaster> mRaster;
50        ObjectBaseRef<ProgramStore> mFragmentStore;
51
52        uint32_t mInvokeFunctionCount;
53        InvokeFunc_t *mInvokeFunctions;
54        uint32_t mFieldCount;
55        void ** mFieldAddress;
56
57        char * mScriptText;
58        uint32_t mScriptTextLength;
59
60        bool mIsThreadable;
61    };
62    Enviroment_t mEnviroment;
63
64    ObjectBaseRef<Allocation> mSlots[MAX_SCRIPT_BANKS];
65    ObjectBaseRef<const Type> mTypes[MAX_SCRIPT_BANKS];
66    bool mSlotWritable[MAX_SCRIPT_BANKS];
67
68    void setVar(uint32_t slot, const void *val, uint32_t len);
69
70    virtual void runForEach(Context *rsc,
71                            const Allocation * ain,
72                            Allocation * aout,
73                            const void * usr,
74                            const RsScriptCall *sc = NULL) = 0;
75
76    virtual void Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len) = 0;
77    virtual void setupScript(Context *rsc) = 0;
78    virtual uint32_t run(Context *) = 0;
79};
80
81
82
83}
84}
85#endif
86
87