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