2009-05-22 14:03:28 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2009 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ANDROID_RS_SCRIPT_C_H
|
|
|
|
#define ANDROID_RS_SCRIPT_C_H
|
|
|
|
|
|
|
|
#include "rsScript.h"
|
|
|
|
|
|
|
|
#include "RenderScriptEnv.h"
|
|
|
|
|
2011-02-25 09:34:33 -08:00
|
|
|
struct BCCOpaqueScript;
|
2009-05-28 15:53:04 -07:00
|
|
|
|
2009-05-22 14:03:28 -07:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
namespace android {
|
|
|
|
namespace renderscript {
|
|
|
|
|
2009-05-28 15:53:04 -07:00
|
|
|
|
2010-11-09 17:00:54 -08:00
|
|
|
class ScriptC : public Script {
|
2009-05-22 14:03:28 -07:00
|
|
|
public:
|
2010-05-11 14:03:58 -07:00
|
|
|
typedef int (*RunScript_t)();
|
2009-09-03 15:43:13 -07:00
|
|
|
typedef void (*VoidFunc_t)();
|
2009-05-22 14:03:28 -07:00
|
|
|
|
2009-09-25 14:51:22 -07:00
|
|
|
ScriptC(Context *);
|
2009-05-22 14:03:28 -07:00
|
|
|
virtual ~ScriptC();
|
|
|
|
|
2009-06-08 15:20:31 -07:00
|
|
|
struct Program_t {
|
2009-06-08 18:50:13 -07:00
|
|
|
int mVersionMajor;
|
|
|
|
int mVersionMinor;
|
2009-05-22 14:03:28 -07:00
|
|
|
|
2010-05-11 14:03:58 -07:00
|
|
|
RunScript_t mRoot;
|
2009-09-03 15:43:13 -07:00
|
|
|
VoidFunc_t mInit;
|
2011-01-27 00:14:13 -08:00
|
|
|
|
|
|
|
uint32_t * mObjectSlotList;
|
|
|
|
uint32_t mObjectSlotCount;
|
2009-06-08 15:20:31 -07:00
|
|
|
};
|
|
|
|
|
2011-01-27 00:14:13 -08:00
|
|
|
|
2009-06-08 15:20:31 -07:00
|
|
|
Program_t mProgram;
|
2009-05-22 14:03:28 -07:00
|
|
|
|
2011-02-25 09:34:33 -08:00
|
|
|
BCCOpaqueScript *mBccScript;
|
2009-05-22 14:03:28 -07:00
|
|
|
|
2010-05-17 14:55:34 -07:00
|
|
|
const Allocation *ptrToAllocation(const void *) const;
|
|
|
|
|
2010-05-19 17:22:57 -07:00
|
|
|
|
|
|
|
virtual void Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len);
|
|
|
|
|
2010-05-28 18:23:22 -07:00
|
|
|
virtual uint32_t run(Context *);
|
|
|
|
|
2010-07-15 17:11:13 -07:00
|
|
|
virtual void runForEach(Context *rsc,
|
|
|
|
const Allocation * ain,
|
|
|
|
Allocation * aout,
|
|
|
|
const void * usr,
|
|
|
|
const RsScriptCall *sc = NULL);
|
2010-05-28 18:23:22 -07:00
|
|
|
|
2010-05-21 12:53:13 -07:00
|
|
|
virtual void serialize(OStream *stream) const { }
|
2010-06-04 10:06:50 -07:00
|
|
|
virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SCRIPT_C; }
|
2010-05-21 12:53:13 -07:00
|
|
|
static Type *createFromStream(Context *rsc, IStream *stream) { return NULL; }
|
2010-05-28 18:23:22 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void setupScript(Context *);
|
|
|
|
void setupGLState(Context *);
|
|
|
|
Script * setTLS(Script *);
|
2009-05-22 14:03:28 -07:00
|
|
|
};
|
|
|
|
|
2010-11-09 17:00:54 -08:00
|
|
|
class ScriptCState {
|
2009-05-22 14:03:28 -07:00
|
|
|
public:
|
|
|
|
ScriptCState();
|
|
|
|
~ScriptCState();
|
|
|
|
|
2011-01-23 17:48:45 -08:00
|
|
|
char * mScriptText;
|
|
|
|
size_t mScriptLen;
|
2009-05-22 14:03:28 -07:00
|
|
|
|
2011-01-19 16:14:21 -08:00
|
|
|
bool runCompiler(Context *rsc, ScriptC *s, const char *resName, const char *cacheDir);
|
2009-07-16 15:08:06 -07:00
|
|
|
|
|
|
|
struct SymbolTable_t {
|
|
|
|
const char * mName;
|
|
|
|
void * mPtr;
|
2010-11-01 14:26:30 -07:00
|
|
|
bool threadable;
|
2009-07-16 15:08:06 -07:00
|
|
|
};
|
|
|
|
static const SymbolTable_t * lookupSymbol(const char *);
|
2010-05-18 13:35:45 -07:00
|
|
|
static const SymbolTable_t * lookupSymbolCL(const char *);
|
|
|
|
static const SymbolTable_t * lookupSymbolGL(const char *);
|
2009-05-22 14:03:28 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|