blob: 66e6fac711c2fb0fed565ee7c3b51c53e7c6a666 [file] [log] [blame]
Jason Samsf70b0fc82012-02-22 15:22:41 -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
18#include <rs.h>
19
20#include "RenderScript.h"
21#include "BaseObj.h"
22
23void * BaseObj::getID() const {
24 if (mID == NULL) {
25 ALOGE("Internal error: Object id 0.");
26 }
27 return mID;
28}
29
Jason Sams170dc842012-02-23 17:14:39 -080030void * BaseObj::getObjID(const BaseObj *o) {
31 return o == NULL ? NULL : o->getID();
32}
33
34
Jason Samsf70b0fc82012-02-22 15:22:41 -080035BaseObj::BaseObj(void *id, RenderScript *rs) {
36 mRS = rs;
37 mID = id;
38}
39
40void BaseObj::checkValid() {
41 if (mID == 0) {
42 ALOGE("Invalid object.");
43 }
44}
45
46BaseObj::~BaseObj() {
47 rsObjDestroy(mRS->mContext, mID);
48 mRS = NULL;
49 mID = NULL;
50}
51
52void BaseObj::updateFromNative() {
53 const char *name = NULL;
54 rsaGetName(mRS, mID, &name);
55 mName = name;
56}
57
58bool BaseObj::equals(const BaseObj *obj) {
59 // Early-out check to see if both BaseObjs are actually the same
60 if (this == obj)
61 return true;
62 return mID == obj->mID;
63}
64
65
66