blob: 976ae78fb23e84c70594d90afaa3db806be2c948 [file] [log] [blame]
Jason Sams326e0dd2009-05-22 14:03:28 -07001/*
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
Jason Samsa0a1b6f2009-06-10 15:04:38 -070022
Jason Sams326e0dd2009-05-22 14:03:28 -070023// ---------------------------------------------------------------------------
24namespace android {
25namespace renderscript {
26
Jason Samsa0a1b6f2009-06-10 15:04:38 -070027class ProgramVertex;
28class ProgramFragment;
29class ProgramRaster;
Jason Samsccc010b2010-05-13 18:30:11 -070030class ProgramStore;
Jason Sams326e0dd2009-05-22 14:03:28 -070031
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080032class Script : public ObjectBase {
Jason Sams326e0dd2009-05-22 14:03:28 -070033public:
Jason Samsbad80742011-03-16 16:29:28 -070034 struct Hal {
35 void * drv;
36
Jason Samsbad80742011-03-16 16:29:28 -070037 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
Jason Sams8c6bc692009-09-16 15:04:38 -070054 typedef void (* InvokeFunc_t)(void);
Jason Sams326e0dd2009-05-22 14:03:28 -070055
Jason Samse514b452009-09-25 14:51:22 -070056 Script(Context *);
Jason Sams326e0dd2009-05-22 14:03:28 -070057 virtual ~Script();
58
Jason Sams928b7342009-06-08 18:50:13 -070059 struct Enviroment_t {
Jason Samsef5867a2010-07-28 11:17:53 -070060 int64_t mStartTimeMillis;
61 int64_t mLastDtTime;
Romain Guy98e10fd2009-07-30 18:45:01 -070062
Jason Samsa0a1b6f2009-06-10 15:04:38 -070063 ObjectBaseRef<ProgramVertex> mVertex;
64 ObjectBaseRef<ProgramFragment> mFragment;
Jason Samsb681c8a2009-09-28 18:12:56 -070065 ObjectBaseRef<ProgramRaster> mRaster;
Jason Samsccc010b2010-05-13 18:30:11 -070066 ObjectBaseRef<ProgramStore> mFragmentStore;
Jason Sams928b7342009-06-08 18:50:13 -070067 };
68 Enviroment_t mEnviroment;
Jason Sams326e0dd2009-05-22 14:03:28 -070069
Alex Sakhartchouk700ba382010-10-08 15:00:05 -070070 void initSlots();
71 void setSlot(uint32_t slot, Allocation *a);
Alex Sakhartchoukb81a0eb2011-06-03 10:18:01 -070072 void setVar(uint32_t slot, const void *val, size_t len);
Jason Samsa5eb6e12010-11-16 17:37:02 -080073 void setVarObj(uint32_t slot, ObjectBase *val);
Jason Sams8c6bc692009-09-16 15:04:38 -070074
Stephen Hines4ee16ff2011-08-31 17:41:39 -070075 virtual bool freeChildren();
76
Jason Samsace3e012010-07-15 17:11:13 -070077 virtual void runForEach(Context *rsc,
78 const Allocation * ain,
79 Allocation * aout,
80 const void * usr,
Jason Sams87fe59a2011-04-20 15:09:01 -070081 size_t usrBytes,
Jason Samsace3e012010-07-15 17:11:13 -070082 const RsScriptCall *sc = NULL) = 0;
Jason Samsc61346b2010-05-28 18:23:22 -070083
Alex Sakhartchoukb81a0eb2011-06-03 10:18:01 -070084 virtual void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) = 0;
Jason Samsc61346b2010-05-28 18:23:22 -070085 virtual void setupScript(Context *rsc) = 0;
86 virtual uint32_t run(Context *) = 0;
Alex Sakhartchouk700ba382010-10-08 15:00:05 -070087protected:
Jason Sams77020c52011-11-22 12:49:11 -080088 bool mInitialized;
Alex Sakhartchouk700ba382010-10-08 15:00:05 -070089 ObjectBaseRef<Allocation> *mSlots;
90 ObjectBaseRef<const Type> *mTypes;
91
Jason Sams326e0dd2009-05-22 14:03:28 -070092};
93
94
Jason Sams326e0dd2009-05-22 14:03:28 -070095}
96}
97#endif
98