blob: b2f545048e2ee73b2d67b06e38b1dc9b2b1a9497 [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
30BaseObj::BaseObj(void *id, RenderScript *rs) {
31 mRS = rs;
32 mID = id;
33}
34
35void BaseObj::checkValid() {
36 if (mID == 0) {
37 ALOGE("Invalid object.");
38 }
39}
40
41BaseObj::~BaseObj() {
42 rsObjDestroy(mRS->mContext, mID);
43 mRS = NULL;
44 mID = NULL;
45}
46
47void BaseObj::updateFromNative() {
48 const char *name = NULL;
49 rsaGetName(mRS, mID, &name);
50 mName = name;
51}
52
53bool BaseObj::equals(const BaseObj *obj) {
54 // Early-out check to see if both BaseObjs are actually the same
55 if (this == obj)
56 return true;
57 return mID == obj->mID;
58}
59
60
61