blob: c73bb5ea15bf505856dd9ffa1438c21169b5bf09 [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
32class Script : public ObjectBase
33{
34public:
Jason Sams8c6bc692009-09-16 15:04:38 -070035 typedef void (* InvokeFunc_t)(void);
Jason Sams326e0dd2009-05-22 14:03:28 -070036
Jason Samse514b452009-09-25 14:51:22 -070037 Script(Context *);
Jason Sams326e0dd2009-05-22 14:03:28 -070038 virtual ~Script();
39
Jason Sams928b7342009-06-08 18:50:13 -070040 struct Enviroment_t {
Jason Samsef5867a2010-07-28 11:17:53 -070041 int64_t mStartTimeMillis;
42 int64_t mLastDtTime;
Romain Guy98e10fd2009-07-30 18:45:01 -070043 const char* mTimeZone;
44
Jason Samsa0a1b6f2009-06-10 15:04:38 -070045 ObjectBaseRef<ProgramVertex> mVertex;
46 ObjectBaseRef<ProgramFragment> mFragment;
Jason Samsb681c8a2009-09-28 18:12:56 -070047 ObjectBaseRef<ProgramRaster> mRaster;
Jason Samsccc010b2010-05-13 18:30:11 -070048 ObjectBaseRef<ProgramStore> mFragmentStore;
Jason Samsbe36bf32010-05-11 14:03:58 -070049
50 uint32_t mInvokeFunctionCount;
51 InvokeFunc_t *mInvokeFunctions;
52 uint32_t mFieldCount;
53 void ** mFieldAddress;
54
Jason Samse402ed32009-11-03 11:25:42 -080055 char * mScriptText;
Jason Sams8c6bc692009-09-16 15:04:38 -070056 uint32_t mScriptTextLength;
Jason Samsdd663fa2010-08-11 13:26:28 -070057
58 bool mIsThreadable;
Jason Sams928b7342009-06-08 18:50:13 -070059 };
60 Enviroment_t mEnviroment;
Jason Sams326e0dd2009-05-22 14:03:28 -070061
Alex Sakhartchouk700ba382010-10-08 15:00:05 -070062 void initSlots();
63 void setSlot(uint32_t slot, Allocation *a);
Jason Samsbe36bf32010-05-11 14:03:58 -070064 void setVar(uint32_t slot, const void *val, uint32_t len);
Jason Sams8c6bc692009-09-16 15:04:38 -070065
Jason Samsace3e012010-07-15 17:11:13 -070066 virtual void runForEach(Context *rsc,
67 const Allocation * ain,
68 Allocation * aout,
69 const void * usr,
70 const RsScriptCall *sc = NULL) = 0;
Jason Samsc61346b2010-05-28 18:23:22 -070071
Jason Sams22fa3712010-05-19 17:22:57 -070072 virtual void Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len) = 0;
Jason Samsc61346b2010-05-28 18:23:22 -070073 virtual void setupScript(Context *rsc) = 0;
74 virtual uint32_t run(Context *) = 0;
Alex Sakhartchouk700ba382010-10-08 15:00:05 -070075protected:
76 ObjectBaseRef<Allocation> *mSlots;
77 ObjectBaseRef<const Type> *mTypes;
78
Jason Sams326e0dd2009-05-22 14:03:28 -070079};
80
81
82
83}
84}
85#endif
86