blob: 7143c671a65846454ab8a2f090dfd41b8b158c8b [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_C_H
18#define ANDROID_RS_SCRIPT_C_H
19
20#include "rsScript.h"
21
22#include "RenderScriptEnv.h"
23
Shih-wei Liao2b2e6212011-01-14 06:21:28 -080024#include <bcc/bcc.h>
Jack Palevich1ef8b802009-05-28 15:53:04 -070025
Jason Sams326e0dd2009-05-22 14:03:28 -070026// ---------------------------------------------------------------------------
27namespace android {
28namespace renderscript {
29
Jack Palevich1ef8b802009-05-28 15:53:04 -070030
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080031class ScriptC : public Script {
Jason Sams326e0dd2009-05-22 14:03:28 -070032public:
Jason Samsbe36bf32010-05-11 14:03:58 -070033 typedef int (*RunScript_t)();
Jason Sams1d54f102009-09-03 15:43:13 -070034 typedef void (*VoidFunc_t)();
Jason Sams326e0dd2009-05-22 14:03:28 -070035
Jason Samse514b452009-09-25 14:51:22 -070036 ScriptC(Context *);
Jason Sams326e0dd2009-05-22 14:03:28 -070037 virtual ~ScriptC();
38
Jason Samsefb8de12009-06-08 15:20:31 -070039 struct Program_t {
Jason Sams928b7342009-06-08 18:50:13 -070040 int mVersionMajor;
41 int mVersionMinor;
Jason Sams326e0dd2009-05-22 14:03:28 -070042
Jason Samsbe36bf32010-05-11 14:03:58 -070043 RunScript_t mRoot;
Jason Sams1d54f102009-09-03 15:43:13 -070044 VoidFunc_t mInit;
Jason Samsefb8de12009-06-08 15:20:31 -070045 };
46
Jason Samsefb8de12009-06-08 15:20:31 -070047 Program_t mProgram;
Jason Sams326e0dd2009-05-22 14:03:28 -070048
Shih-wei Liao2b2e6212011-01-14 06:21:28 -080049 BCCScriptRef mBccScript;
Jason Sams326e0dd2009-05-22 14:03:28 -070050
Jason Samsce92d4b2010-05-17 14:55:34 -070051 const Allocation *ptrToAllocation(const void *) const;
52
Jason Sams22fa3712010-05-19 17:22:57 -070053
54 virtual void Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len);
55
Jason Samsc61346b2010-05-28 18:23:22 -070056 virtual uint32_t run(Context *);
57
Jason Samsace3e012010-07-15 17:11:13 -070058 virtual void runForEach(Context *rsc,
59 const Allocation * ain,
60 Allocation * aout,
61 const void * usr,
62 const RsScriptCall *sc = NULL);
Jason Samsc61346b2010-05-28 18:23:22 -070063
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070064 virtual void serialize(OStream *stream) const { }
Alex Sakhartchoukb825f672010-06-04 10:06:50 -070065 virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SCRIPT_C; }
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070066 static Type *createFromStream(Context *rsc, IStream *stream) { return NULL; }
Jason Samsc61346b2010-05-28 18:23:22 -070067
68protected:
69 void setupScript(Context *);
70 void setupGLState(Context *);
71 Script * setTLS(Script *);
Jason Sams326e0dd2009-05-22 14:03:28 -070072};
73
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080074class ScriptCState {
Jason Sams326e0dd2009-05-22 14:03:28 -070075public:
76 ScriptCState();
77 ~ScriptCState();
78
Jason Sams249d4532011-01-23 17:48:45 -080079 char * mScriptText;
80 size_t mScriptLen;
Jason Sams326e0dd2009-05-22 14:03:28 -070081
Jason Sams26b2c9f2011-01-19 16:14:21 -080082 bool runCompiler(Context *rsc, ScriptC *s, const char *resName, const char *cacheDir);
Jason Sams29df66f2009-07-16 15:08:06 -070083
84 struct SymbolTable_t {
85 const char * mName;
86 void * mPtr;
Jason Sams6bfc1b92010-11-01 14:26:30 -070087 bool threadable;
Jason Sams29df66f2009-07-16 15:08:06 -070088 };
Jason Sams29df66f2009-07-16 15:08:06 -070089 static const SymbolTable_t * lookupSymbol(const char *);
Jason Samsaeb094b2010-05-18 13:35:45 -070090 static const SymbolTable_t * lookupSymbolCL(const char *);
91 static const SymbolTable_t * lookupSymbolGL(const char *);
Jason Sams326e0dd2009-05-22 14:03:28 -070092};
93
94
95}
96}
97#endif