Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 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 | |
Chih-Hung Hsieh | 11496ac | 2016-11-15 15:14:05 -0800 | [diff] [blame] | 21 | namespace android { |
| 22 | namespace renderscript { |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 23 | |
| 24 | ScriptIntrinsic::ScriptIntrinsic(Context *rsc) : Script(rsc) { |
Jason Sams | 75adb82 | 2013-10-22 11:43:54 -0700 | [diff] [blame] | 25 | mIntrinsicID = 0; |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | ScriptIntrinsic::~ScriptIntrinsic() { |
Jason Sams | 75adb82 | 2013-10-22 11:43:54 -0700 | [diff] [blame] | 29 | if (mIntrinsicID != 0) { |
| 30 | mRSC->mHal.funcs.script.destroy(mRSC, this); |
| 31 | } |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 32 | } |
| 33 | |
Stephen Hines | 41d6c76 | 2012-08-21 17:07:38 -0700 | [diff] [blame] | 34 | bool ScriptIntrinsic::init(Context *rsc, RsScriptIntrinsicID iid, Element *e) { |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 35 | mIntrinsicID = iid; |
| 36 | mElement.set(e); |
Jason Sams | 17f03fc | 2012-08-21 18:30:01 -0700 | [diff] [blame] | 37 | mSlots = new ObjectBaseRef<Allocation>[2]; |
| 38 | mTypes = new ObjectBaseRef<const Type>[2]; |
| 39 | |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 40 | rsc->mHal.funcs.script.initIntrinsic(rsc, this, iid, e); |
| 41 | |
Jason Sams | 17f03fc | 2012-08-21 18:30:01 -0700 | [diff] [blame] | 42 | |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 43 | return true; |
| 44 | } |
| 45 | |
| 46 | bool ScriptIntrinsic::freeChildren() { |
| 47 | return false; |
| 48 | } |
| 49 | |
| 50 | void ScriptIntrinsic::setupScript(Context *rsc) { |
| 51 | } |
| 52 | |
| 53 | uint32_t ScriptIntrinsic::run(Context *rsc) { |
| 54 | rsAssert(!"ScriptIntrinsic::run - should not happen"); |
| 55 | return 0; |
| 56 | } |
| 57 | |
Chris Wailes | 4b3c34e | 2014-06-11 12:00:29 -0700 | [diff] [blame] | 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 | |
Jason Sams | c0d6847 | 2015-01-20 14:29:52 -0800 | [diff] [blame] | 67 | rsc->mHal.funcs.script.invokeForEachMulti(rsc, this, slot, ains, inLen, |
| 68 | aout, usr, usrBytes, sc); |
Chris Wailes | 4b3c34e | 2014-06-11 12:00:29 -0700 | [diff] [blame] | 69 | } |
| 70 | |
David Gross | ae2ec3f | 2016-06-01 14:45:47 -0700 | [diff] [blame] | 71 | void ScriptIntrinsic::runReduce(Context *rsc, uint32_t slot, |
| 72 | const Allocation ** ains, size_t inLen, |
Matt Wala | 14ce007 | 2015-07-30 17:30:25 -0700 | [diff] [blame] | 73 | Allocation *aout, const RsScriptCall *sc) { |
| 74 | } |
| 75 | |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 76 | void ScriptIntrinsic::Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) { |
| 77 | } |
| 78 | |
| 79 | void ScriptIntrinsic::serialize(Context *rsc, OStream *stream) const { |
| 80 | } |
| 81 | |
| 82 | RsA3DClassID ScriptIntrinsic::getClassId() const { |
| 83 | return (RsA3DClassID)0; |
| 84 | } |
| 85 | |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 86 | RsScript rsi_ScriptIntrinsicCreate(Context *rsc, uint32_t id, RsElement ve) { |
| 87 | ScriptIntrinsic *si = new ScriptIntrinsic(rsc); |
Stephen Hines | 41d6c76 | 2012-08-21 17:07:38 -0700 | [diff] [blame] | 88 | if (!si->init(rsc, (RsScriptIntrinsicID)id, (Element *)ve)) { |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 89 | delete si; |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 90 | return nullptr; |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 91 | } |
Jason Sams | c5c744a | 2013-02-22 15:32:29 -0800 | [diff] [blame] | 92 | si->incUserRef(); |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 93 | return si; |
| 94 | } |
| 95 | |
Chih-Hung Hsieh | 11496ac | 2016-11-15 15:14:05 -0800 | [diff] [blame] | 96 | } // namespace renderscript |
| 97 | } // namespace android |