Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 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 | |
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 | |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 32 | #define MAX_SCRIPT_BANKS 32 |
Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 33 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 34 | class Script : public ObjectBase |
| 35 | { |
| 36 | public: |
Jason Sams | be2e841 | 2009-09-16 15:04:38 -0700 | [diff] [blame] | 37 | typedef void (* InvokeFunc_t)(void); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 38 | |
Jason Sams | a9e7a05 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 39 | Script(Context *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 40 | virtual ~Script(); |
| 41 | |
Jason Sams | 928f5cf | 2009-06-08 18:50:13 -0700 | [diff] [blame] | 42 | struct Enviroment_t { |
Romain Guy | 584a375 | 2009-07-30 18:45:01 -0700 | [diff] [blame] | 43 | uint32_t mStartTimeMillis; |
| 44 | const char* mTimeZone; |
| 45 | |
Jason Sams | 3eaa338 | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 46 | ObjectBaseRef<ProgramVertex> mVertex; |
| 47 | ObjectBaseRef<ProgramFragment> mFragment; |
Jason Sams | 5235cf3 | 2009-09-28 18:12:56 -0700 | [diff] [blame] | 48 | ObjectBaseRef<ProgramRaster> mRaster; |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 49 | ObjectBaseRef<ProgramStore> mFragmentStore; |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 50 | |
| 51 | uint32_t mInvokeFunctionCount; |
| 52 | InvokeFunc_t *mInvokeFunctions; |
| 53 | uint32_t mFieldCount; |
| 54 | void ** mFieldAddress; |
| 55 | |
Jason Sams | 9d5e03d | 2009-11-03 11:25:42 -0800 | [diff] [blame] | 56 | char * mScriptText; |
Jason Sams | be2e841 | 2009-09-16 15:04:38 -0700 | [diff] [blame] | 57 | uint32_t mScriptTextLength; |
Jason Sams | 928f5cf | 2009-06-08 18:50:13 -0700 | [diff] [blame] | 58 | }; |
| 59 | Enviroment_t mEnviroment; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 60 | |
Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 61 | ObjectBaseRef<Allocation> mSlots[MAX_SCRIPT_BANKS]; |
Jason Sams | fbf0b9e | 2009-08-13 12:59:04 -0700 | [diff] [blame] | 62 | ObjectBaseRef<const Type> mTypes[MAX_SCRIPT_BANKS]; |
Jason Sams | 334ea0c | 2009-08-17 13:56:09 -0700 | [diff] [blame] | 63 | bool mSlotWritable[MAX_SCRIPT_BANKS]; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 64 | |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 65 | void setVar(uint32_t slot, const void *val, uint32_t len); |
Jason Sams | be2e841 | 2009-09-16 15:04:38 -0700 | [diff] [blame] | 66 | |
Jason Sams | 8f8a572 | 2010-07-15 17:11:13 -0700 | [diff] [blame^] | 67 | virtual void runForEach(Context *rsc, |
| 68 | const Allocation * ain, |
| 69 | Allocation * aout, |
| 70 | const void * usr, |
| 71 | const RsScriptCall *sc = NULL) = 0; |
Jason Sams | f17bccc | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 72 | |
Jason Sams | d79b2e9 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 73 | virtual void Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len) = 0; |
Jason Sams | f17bccc | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 74 | virtual void setupScript(Context *rsc) = 0; |
| 75 | virtual uint32_t run(Context *) = 0; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | |
| 79 | |
| 80 | } |
| 81 | } |
| 82 | #endif |
| 83 | |