blob: b6112dd7c927d141e85c071a57f8c2c093a5b877 [file] [log] [blame]
Jason Sams170dc842012-02-23 17:14:39 -08001/*
2 * Copyright (C) 2008-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 <utils/Log.h>
18#include <malloc.h>
19
20#include "RenderScript.h"
21#include "Element.h"
22#include "Type.h"
23#include "Allocation.h"
24#include "Script.h"
25
26void Script::invoke(uint32_t slot, const void *v, size_t len) {
27 rsScriptInvokeV(mRS->mContext, getID(), slot, v, len);
28}
29
30void Script::forEach(uint32_t slot, const Allocation *ain, const Allocation *aout,
31 const void *usr, size_t usrLen) {
32 if ((ain == NULL) && (aout == NULL)) {
33 mRS->throwError("At least one of ain or aout is required to be non-null.");
34 }
35 void *in_id = BaseObj::getObjID(ain);
36 void *out_id = BaseObj::getObjID(aout);
37 rsScriptForEach(mRS->mContext, getID(), slot, in_id, out_id, usr, usrLen);
38}
39
40
41Script::Script(void *id, RenderScript *rs) : BaseObj(id, rs) {
42}
43
44
45void Script::bindAllocation(const Allocation *va, uint32_t slot) {
46 rsScriptBindAllocation(mRS->mContext, getID(), BaseObj::getObjID(va), slot);
47}
48
49
50void Script::setVar(uint32_t index, const BaseObj *o) {
51 rsScriptSetVarObj(mRS->mContext, getID(), index, (o == NULL) ? 0 : o->getID());
52}
53
54void Script::setVar(uint32_t index, const void *v, size_t len) {
55 rsScriptSetVarV(mRS->mContext, getID(), index, v, len);
56}
57
58
59
60void Script::FieldBase::init(RenderScript *rs, uint32_t dimx, uint32_t usages) {
61 mAllocation = Allocation::createSized(rs, mElement, dimx, RS_ALLOCATION_USAGE_SCRIPT | usages);
62}
63
64//Script::FieldBase::FieldBase() {
65//}
66
67