Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
Stephen Hines | 473a204 | 2012-02-21 20:13:12 -0800 | [diff] [blame^] | 2 | * Copyright (C) 2009-2012 The Android Open Source Project |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 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 Sams | 3eaa338 | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 22 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 23 | // --------------------------------------------------------------------------- |
| 24 | namespace android { |
| 25 | namespace renderscript { |
| 26 | |
Jason Sams | 3eaa338 | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 27 | class ProgramVertex; |
| 28 | class ProgramFragment; |
| 29 | class ProgramRaster; |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 30 | class ProgramStore; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 31 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 32 | class Script : public ObjectBase { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 33 | public: |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 34 | struct Hal { |
| 35 | void * drv; |
| 36 | |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 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 | |
Jason Sams | be2e841 | 2009-09-16 15:04:38 -0700 | [diff] [blame] | 54 | typedef void (* InvokeFunc_t)(void); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 55 | |
Jason Sams | a9e7a05 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 56 | Script(Context *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 57 | virtual ~Script(); |
| 58 | |
Jason Sams | 928f5cf | 2009-06-08 18:50:13 -0700 | [diff] [blame] | 59 | struct Enviroment_t { |
Jason Sams | 1796651 | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 60 | int64_t mStartTimeMillis; |
| 61 | int64_t mLastDtTime; |
Romain Guy | 584a375 | 2009-07-30 18:45:01 -0700 | [diff] [blame] | 62 | |
Jason Sams | 3eaa338 | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 63 | ObjectBaseRef<ProgramVertex> mVertex; |
| 64 | ObjectBaseRef<ProgramFragment> mFragment; |
Jason Sams | 5235cf3 | 2009-09-28 18:12:56 -0700 | [diff] [blame] | 65 | ObjectBaseRef<ProgramRaster> mRaster; |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 66 | ObjectBaseRef<ProgramStore> mFragmentStore; |
Jason Sams | 928f5cf | 2009-06-08 18:50:13 -0700 | [diff] [blame] | 67 | }; |
| 68 | Enviroment_t mEnviroment; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 69 | |
Alex Sakhartchouk | 6f91cb6 | 2010-10-08 15:00:05 -0700 | [diff] [blame] | 70 | void setSlot(uint32_t slot, Allocation *a); |
Alex Sakhartchouk | 17a8a19 | 2011-06-03 10:18:01 -0700 | [diff] [blame] | 71 | void setVar(uint32_t slot, const void *val, size_t len); |
Jason Sams | 6f4cf0b | 2010-11-16 17:37:02 -0800 | [diff] [blame] | 72 | void setVarObj(uint32_t slot, ObjectBase *val); |
Jason Sams | be2e841 | 2009-09-16 15:04:38 -0700 | [diff] [blame] | 73 | |
Stephen Hines | 514f979 | 2011-08-31 17:41:39 -0700 | [diff] [blame] | 74 | virtual bool freeChildren(); |
| 75 | |
Jason Sams | 8f8a572 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 76 | virtual void runForEach(Context *rsc, |
Stephen Hines | 473a204 | 2012-02-21 20:13:12 -0800 | [diff] [blame^] | 77 | uint32_t slot, |
Jason Sams | 8f8a572 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 78 | const Allocation * ain, |
| 79 | Allocation * aout, |
| 80 | const void * usr, |
Jason Sams | fcf7231 | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 81 | size_t usrBytes, |
Jason Sams | 8f8a572 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 82 | const RsScriptCall *sc = NULL) = 0; |
Jason Sams | f17bccc | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 83 | |
Alex Sakhartchouk | 17a8a19 | 2011-06-03 10:18:01 -0700 | [diff] [blame] | 84 | virtual void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) = 0; |
Jason Sams | f17bccc | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 85 | virtual void setupScript(Context *rsc) = 0; |
| 86 | virtual uint32_t run(Context *) = 0; |
Alex Sakhartchouk | 6f91cb6 | 2010-10-08 15:00:05 -0700 | [diff] [blame] | 87 | protected: |
Jason Sams | dd39fdf | 2011-11-22 12:49:11 -0800 | [diff] [blame] | 88 | bool mInitialized; |
Alex Sakhartchouk | 6f91cb6 | 2010-10-08 15:00:05 -0700 | [diff] [blame] | 89 | ObjectBaseRef<Allocation> *mSlots; |
| 90 | ObjectBaseRef<const Type> *mTypes; |
| 91 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 95 | } |
| 96 | } |
| 97 | #endif |
| 98 | |