• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // ---------------------------------------------------------------------------
24 namespace android {
25 namespace renderscript {
26 
27 class ProgramVertex;
28 class ProgramFragment;
29 class ProgramRaster;
30 class ProgramStore;
31 
32 class Script : public ObjectBase {
33 public:
34     struct Hal {
35         void * drv;
36 
37         struct DriverInfo {
38             int mVersionMajor;
39             int mVersionMinor;
40 
41             size_t exportedVariableCount;
42             size_t exportedFunctionCount;
43             size_t exportedPragmaCount;
44             char const **exportedPragmaKeyList;
45             char const **exportedPragmaValueList;
46 
47             int (* root)();
48             bool isThreadable;
49         };
50         DriverInfo info;
51     };
52     Hal mHal;
53 
54     typedef void (* InvokeFunc_t)(void);
55 
56     Script(Context *);
57     virtual ~Script();
58 
59     struct Enviroment_t {
60         int64_t mStartTimeMillis;
61         int64_t mLastDtTime;
62         const char* mTimeZone;
63 
64         ObjectBaseRef<ProgramVertex> mVertex;
65         ObjectBaseRef<ProgramFragment> mFragment;
66         ObjectBaseRef<ProgramRaster> mRaster;
67         ObjectBaseRef<ProgramStore> mFragmentStore;
68     };
69     Enviroment_t mEnviroment;
70 
71     void initSlots();
72     void setSlot(uint32_t slot, Allocation *a);
73     void setVar(uint32_t slot, const void *val, size_t len);
74     void setVarObj(uint32_t slot, ObjectBase *val);
75 
76     virtual bool freeChildren();
77 
78     virtual void runForEach(Context *rsc,
79                             const Allocation * ain,
80                             Allocation * aout,
81                             const void * usr,
82                             size_t usrBytes,
83                             const RsScriptCall *sc = NULL) = 0;
84 
85     virtual void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) = 0;
86     virtual void setupScript(Context *rsc) = 0;
87     virtual uint32_t run(Context *) = 0;
88 protected:
89     ObjectBaseRef<Allocation> *mSlots;
90     ObjectBaseRef<const Type> *mTypes;
91 
92 };
93 
94 
95 }
96 }
97 #endif
98 
99