blob: c8881a4b4070dbf600fca12eac5bc6cb03b59688 [file] [log] [blame]
Jason Sams326e0dd2009-05-22 14:03:28 -07001/*
Stephen Hines44199772012-02-21 20:13:12 -08002 * Copyright (C) 2009-2012 The Android Open Source Project
Jason Sams326e0dd2009-05-22 14:03:28 -07003 *
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
Jean-Luc Brouillet23037482014-03-25 16:27:34 -070020#include "rsEnv.h"
Jason Sams326e0dd2009-05-22 14:03:28 -070021#include "rsScript.h"
22
Jason Sams326e0dd2009-05-22 14:03:28 -070023// ---------------------------------------------------------------------------
24namespace android {
25namespace renderscript {
26
Jack Palevich1ef8b802009-05-28 15:53:04 -070027
Jean-Luc Brouillet23037482014-03-25 16:27:34 -070028/** This class represents a script compiled from an .rs file. */
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080029class ScriptC : public Script {
Jason Sams326e0dd2009-05-22 14:03:28 -070030public:
Jason Samsbe36bf32010-05-11 14:03:58 -070031 typedef int (*RunScript_t)();
Jason Sams1d54f102009-09-03 15:43:13 -070032 typedef void (*VoidFunc_t)();
Jason Sams326e0dd2009-05-22 14:03:28 -070033
Jason Samse514b452009-09-25 14:51:22 -070034 ScriptC(Context *);
Jason Sams326e0dd2009-05-22 14:03:28 -070035 virtual ~ScriptC();
36
David Gross6c1876b2016-01-15 11:52:14 -080037 void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) override;
Jason Sams22fa3712010-05-19 17:22:57 -070038
Jason Samsc61346b2010-05-28 18:23:22 -070039 virtual uint32_t run(Context *);
40
David Gross6c1876b2016-01-15 11:52:14 -080041 void runForEach(Context *rsc,
42 uint32_t slot,
43 const Allocation ** ains,
44 size_t inLen,
45 Allocation * aout,
46 const void * usr,
47 size_t usrBytes,
48 const RsScriptCall *sc = nullptr) override;
Chris Wailes4b3c34e2014-06-11 12:00:29 -070049
David Gross6c1876b2016-01-15 11:52:14 -080050 void runReduce(Context *rsc, uint32_t slot, const Allocation *ain,
51 Allocation *aout, const RsScriptCall *sc) override;
52
53 void runReduceNew(Context *rsc, uint32_t slot,
54 const Allocation ** ains, size_t inLen,
55 Allocation *aout, const RsScriptCall *sc) override;
Matt Wala14ce0072015-07-30 17:30:25 -070056
Jason Samse3150cf2012-07-24 18:10:20 -070057 virtual void serialize(Context *rsc, OStream *stream) const { }
Alex Sakhartchoukb825f672010-06-04 10:06:50 -070058 virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SCRIPT_C; }
Chris Wailes44bef6f2014-08-12 13:51:10 -070059 static Type *createFromStream(Context *rsc, IStream *stream) { return nullptr; }
Jason Samsc61346b2010-05-28 18:23:22 -070060
Jason Samsbad80742011-03-16 16:29:28 -070061 bool runCompiler(Context *rsc, const char *resName, const char *cacheDir,
62 const uint8_t *bitcode, size_t bitcodeLen);
63
Jason Samscdfdb8f2011-03-17 16:12:47 -070064//protected:
Jason Samsc61346b2010-05-28 18:23:22 -070065 void setupScript(Context *);
66 void setupGLState(Context *);
Stephen Hinesf6af3bd2014-12-23 17:47:43 -080067
68#if !defined(RS_COMPATIBILITY_LIB)
69 static bool createCacheDir(const char *cacheDir);
70#endif
Jason Sams326e0dd2009-05-22 14:03:28 -070071};
72
Jason Sams326e0dd2009-05-22 14:03:28 -070073}
74}
75#endif