blob: 38965862bc209b560a630577ddd7fea7f7a267b9 [file] [log] [blame]
Jason Sams8eaba4f2012-08-14 14:38:05 -07001/*
2 * Copyright (C) 2012 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#include "rsContext.h"
18#include "rsScriptIntrinsic.h"
19#include <time.h>
20
21using namespace android;
22using namespace android::renderscript;
23
24ScriptIntrinsic::ScriptIntrinsic(Context *rsc) : Script(rsc) {
Jason Sams75adb822013-10-22 11:43:54 -070025 mIntrinsicID = 0;
Jason Sams8eaba4f2012-08-14 14:38:05 -070026}
27
28ScriptIntrinsic::~ScriptIntrinsic() {
Jason Sams75adb822013-10-22 11:43:54 -070029 if (mIntrinsicID != 0) {
30 mRSC->mHal.funcs.script.destroy(mRSC, this);
31 }
Jason Sams8eaba4f2012-08-14 14:38:05 -070032}
33
Stephen Hines41d6c762012-08-21 17:07:38 -070034bool ScriptIntrinsic::init(Context *rsc, RsScriptIntrinsicID iid, Element *e) {
Jason Sams8eaba4f2012-08-14 14:38:05 -070035 mIntrinsicID = iid;
36 mElement.set(e);
Jason Sams17f03fc2012-08-21 18:30:01 -070037 mSlots = new ObjectBaseRef<Allocation>[2];
38 mTypes = new ObjectBaseRef<const Type>[2];
39
Jason Sams8eaba4f2012-08-14 14:38:05 -070040 rsc->mHal.funcs.script.initIntrinsic(rsc, this, iid, e);
41
Jason Sams17f03fc2012-08-21 18:30:01 -070042
Jason Sams8eaba4f2012-08-14 14:38:05 -070043 return true;
44}
45
46bool ScriptIntrinsic::freeChildren() {
47 return false;
48}
49
50void ScriptIntrinsic::setupScript(Context *rsc) {
51}
52
53uint32_t ScriptIntrinsic::run(Context *rsc) {
54 rsAssert(!"ScriptIntrinsic::run - should not happen");
55 return 0;
56}
57
Chris Wailes4b3c34e2014-06-11 12:00:29 -070058void ScriptIntrinsic::runForEach(Context* rsc,
59 uint32_t slot,
60 const Allocation** ains,
61 size_t inLen,
62 Allocation* aout,
63 const void* usr,
64 size_t usrBytes,
65 const RsScriptCall* sc) {
66
Jason Samsc0d68472015-01-20 14:29:52 -080067 rsc->mHal.funcs.script.invokeForEachMulti(rsc, this, slot, ains, inLen,
68 aout, usr, usrBytes, sc);
Chris Wailes4b3c34e2014-06-11 12:00:29 -070069}
70
Jason Sams8eaba4f2012-08-14 14:38:05 -070071void ScriptIntrinsic::Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) {
72}
73
74void ScriptIntrinsic::serialize(Context *rsc, OStream *stream) const {
75}
76
77RsA3DClassID ScriptIntrinsic::getClassId() const {
78 return (RsA3DClassID)0;
79}
80
81
82
83namespace android {
84namespace renderscript {
85
86
87RsScript rsi_ScriptIntrinsicCreate(Context *rsc, uint32_t id, RsElement ve) {
88 ScriptIntrinsic *si = new ScriptIntrinsic(rsc);
Stephen Hines41d6c762012-08-21 17:07:38 -070089 if (!si->init(rsc, (RsScriptIntrinsicID)id, (Element *)ve)) {
Jason Sams8eaba4f2012-08-14 14:38:05 -070090 delete si;
Chris Wailes44bef6f2014-08-12 13:51:10 -070091 return nullptr;
Jason Sams8eaba4f2012-08-14 14:38:05 -070092 }
Jason Samsc5c744a2013-02-22 15:32:29 -080093 si->incUserRef();
Jason Sams8eaba4f2012-08-14 14:38:05 -070094 return si;
95}
96
97}
98}