blob: ea6aec5405be8993c1d09dd41137c4bfa608d192 [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
Jason Samsbe36bf32010-05-11 14:03:58 -070032#define MAX_SCRIPT_BANKS 32
Jason Sams8b2c0652009-08-12 17:54:11 -070033
Jason Sams326e0dd2009-05-22 14:03:28 -070034class Script : public ObjectBase
35{
36public:
Jason Sams8c6bc692009-09-16 15:04:38 -070037 typedef void (* InvokeFunc_t)(void);
Jason Sams326e0dd2009-05-22 14:03:28 -070038
Jason Samse514b452009-09-25 14:51:22 -070039 Script(Context *);
Jason Sams326e0dd2009-05-22 14:03:28 -070040 virtual ~Script();
41
Jason Sams928b7342009-06-08 18:50:13 -070042 struct Enviroment_t {
Romain Guy98e10fd2009-07-30 18:45:01 -070043 uint32_t mStartTimeMillis;
44 const char* mTimeZone;
45
Jason Samsa0a1b6f2009-06-10 15:04:38 -070046 ObjectBaseRef<ProgramVertex> mVertex;
47 ObjectBaseRef<ProgramFragment> mFragment;
Jason Samsb681c8a2009-09-28 18:12:56 -070048 ObjectBaseRef<ProgramRaster> mRaster;
Jason Samsccc010b2010-05-13 18:30:11 -070049 ObjectBaseRef<ProgramStore> mFragmentStore;
Jason Samsbe36bf32010-05-11 14:03:58 -070050
51 uint32_t mInvokeFunctionCount;
52 InvokeFunc_t *mInvokeFunctions;
53 uint32_t mFieldCount;
54 void ** mFieldAddress;
55
Jason Samse402ed32009-11-03 11:25:42 -080056 char * mScriptText;
Jason Sams8c6bc692009-09-16 15:04:38 -070057 uint32_t mScriptTextLength;
Jason Sams928b7342009-06-08 18:50:13 -070058 };
59 Enviroment_t mEnviroment;
Jason Sams326e0dd2009-05-22 14:03:28 -070060
Jason Sams8b2c0652009-08-12 17:54:11 -070061 ObjectBaseRef<Allocation> mSlots[MAX_SCRIPT_BANKS];
Jason Samsfa517192009-08-13 12:59:04 -070062 ObjectBaseRef<const Type> mTypes[MAX_SCRIPT_BANKS];
Jason Sams90b36a82009-08-17 13:56:09 -070063 bool mSlotWritable[MAX_SCRIPT_BANKS];
Jason Sams326e0dd2009-05-22 14:03:28 -070064
Jason Samsbe36bf32010-05-11 14:03:58 -070065 void setVar(uint32_t slot, const void *val, uint32_t len);
Jason Sams8c6bc692009-09-16 15:04:38 -070066
Jason Samsc61346b2010-05-28 18:23:22 -070067 virtual void runForEach(Context *rsc, const Allocation *ain, Allocation *aout) = 0;
68 virtual void runForEach(Context *rsc, const Allocation *ain, Allocation *aout, uint32_t xStart, uint32_t xEnd) = 0;
69 virtual void runForEach(Context *rsc, const Allocation *ain, Allocation *aout, uint32_t xStart, uint32_t yStart, uint32_t xEnd, uint32_t yEnd) = 0;
70
Jason Sams22fa3712010-05-19 17:22:57 -070071 virtual void Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len) = 0;
Jason Samsc61346b2010-05-28 18:23:22 -070072 virtual void setupScript(Context *rsc) = 0;
73 virtual uint32_t run(Context *) = 0;
Jason Sams326e0dd2009-05-22 14:03:28 -070074};
75
76
77
78}
79}
80#endif
81