1 /*
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
21 using namespace android;
22 using namespace android::renderscript;
23
ScriptIntrinsic(Context * rsc)24 ScriptIntrinsic::ScriptIntrinsic(Context *rsc) : Script(rsc) {
25 mIntrinsicID = 0;
26 }
27
~ScriptIntrinsic()28 ScriptIntrinsic::~ScriptIntrinsic() {
29 if (mIntrinsicID != 0) {
30 mRSC->mHal.funcs.script.destroy(mRSC, this);
31 }
32 }
33
init(Context * rsc,RsScriptIntrinsicID iid,Element * e)34 bool ScriptIntrinsic::init(Context *rsc, RsScriptIntrinsicID iid, Element *e) {
35 mIntrinsicID = iid;
36 mElement.set(e);
37 mSlots = new ObjectBaseRef<Allocation>[2];
38 mTypes = new ObjectBaseRef<const Type>[2];
39
40 rsc->mHal.funcs.script.initIntrinsic(rsc, this, iid, e);
41
42
43 return true;
44 }
45
freeChildren()46 bool ScriptIntrinsic::freeChildren() {
47 return false;
48 }
49
setupScript(Context * rsc)50 void ScriptIntrinsic::setupScript(Context *rsc) {
51 }
52
run(Context * rsc)53 uint32_t ScriptIntrinsic::run(Context *rsc) {
54 rsAssert(!"ScriptIntrinsic::run - should not happen");
55 return 0;
56 }
57
runForEach(Context * rsc,uint32_t slot,const Allocation ** ains,size_t inLen,Allocation * aout,const void * usr,size_t usrBytes,const RsScriptCall * sc)58 void 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
67 rsc->mHal.funcs.script.invokeForEachMulti(rsc, this, slot, ains, inLen,
68 aout, usr, usrBytes, sc);
69 }
70
runReduce(Context * rsc,uint32_t slot,const Allocation ** ains,size_t inLen,Allocation * aout,const RsScriptCall * sc)71 void ScriptIntrinsic::runReduce(Context *rsc, uint32_t slot,
72 const Allocation ** ains, size_t inLen,
73 Allocation *aout, const RsScriptCall *sc) {
74 }
75
Invoke(Context * rsc,uint32_t slot,const void * data,size_t len)76 void ScriptIntrinsic::Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) {
77 }
78
serialize(Context * rsc,OStream * stream) const79 void ScriptIntrinsic::serialize(Context *rsc, OStream *stream) const {
80 }
81
getClassId() const82 RsA3DClassID ScriptIntrinsic::getClassId() const {
83 return (RsA3DClassID)0;
84 }
85
86
87
88 namespace android {
89 namespace renderscript {
90
91
rsi_ScriptIntrinsicCreate(Context * rsc,uint32_t id,RsElement ve)92 RsScript rsi_ScriptIntrinsicCreate(Context *rsc, uint32_t id, RsElement ve) {
93 ScriptIntrinsic *si = new ScriptIntrinsic(rsc);
94 if (!si->init(rsc, (RsScriptIntrinsicID)id, (Element *)ve)) {
95 delete si;
96 return nullptr;
97 }
98 si->incUserRef();
99 return si;
100 }
101
102 }
103 }
104