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 | |
| 21 | using namespace android; |
| 22 | using namespace android::renderscript; |
| 23 | |
| 24 | ScriptIntrinsic::ScriptIntrinsic(Context *rsc) : Script(rsc) { |
| 25 | } |
| 26 | |
| 27 | ScriptIntrinsic::~ScriptIntrinsic() { |
| 28 | } |
| 29 | |
Stephen Hines | 41d6c76 | 2012-08-21 17:07:38 -0700 | [diff] [blame] | 30 | bool ScriptIntrinsic::init(Context *rsc, RsScriptIntrinsicID iid, Element *e) { |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 31 | mIntrinsicID = iid; |
| 32 | mElement.set(e); |
Jason Sams | 17f03fc | 2012-08-21 18:30:01 -0700 | [diff] [blame] | 33 | mSlots = new ObjectBaseRef<Allocation>[2]; |
| 34 | mTypes = new ObjectBaseRef<const Type>[2]; |
| 35 | |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 36 | rsc->mHal.funcs.script.initIntrinsic(rsc, this, iid, e); |
| 37 | |
Jason Sams | 17f03fc | 2012-08-21 18:30:01 -0700 | [diff] [blame] | 38 | |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 39 | return true; |
| 40 | } |
| 41 | |
| 42 | bool ScriptIntrinsic::freeChildren() { |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | void ScriptIntrinsic::setupScript(Context *rsc) { |
| 47 | } |
| 48 | |
| 49 | uint32_t ScriptIntrinsic::run(Context *rsc) { |
| 50 | rsAssert(!"ScriptIntrinsic::run - should not happen"); |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | |
| 55 | void ScriptIntrinsic::runForEach(Context *rsc, |
| 56 | uint32_t slot, |
| 57 | const Allocation * ain, |
| 58 | Allocation * aout, |
| 59 | const void * usr, |
| 60 | size_t usrBytes, |
| 61 | const RsScriptCall *sc) { |
| 62 | |
| 63 | rsc->mHal.funcs.script.invokeForEach(rsc, this, slot, ain, aout, usr, usrBytes, sc); |
| 64 | } |
| 65 | |
| 66 | void ScriptIntrinsic::Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) { |
| 67 | } |
| 68 | |
| 69 | void ScriptIntrinsic::serialize(Context *rsc, OStream *stream) const { |
| 70 | } |
| 71 | |
| 72 | RsA3DClassID ScriptIntrinsic::getClassId() const { |
| 73 | return (RsA3DClassID)0; |
| 74 | } |
| 75 | |
| 76 | |
| 77 | |
| 78 | namespace android { |
| 79 | namespace renderscript { |
| 80 | |
| 81 | |
| 82 | RsScript rsi_ScriptIntrinsicCreate(Context *rsc, uint32_t id, RsElement ve) { |
| 83 | ScriptIntrinsic *si = new ScriptIntrinsic(rsc); |
Stephen Hines | 41d6c76 | 2012-08-21 17:07:38 -0700 | [diff] [blame] | 84 | if (!si->init(rsc, (RsScriptIntrinsicID)id, (Element *)ve)) { |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 85 | delete si; |
| 86 | return NULL; |
| 87 | } |
Jason Sams | c5c744a | 2013-02-22 15:32:29 -0800 | [diff] [blame] | 88 | si->incUserRef(); |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 89 | return si; |
| 90 | } |
| 91 | |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | |