summaryrefslogtreecommitdiffstats
path: root/graphics/java/android/renderscript/BaseObj.java
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2009-07-31 16:26:13 -0700
committerJason Sams <rjsams@android.com>2009-07-31 16:26:13 -0700
commit36e612a488511940b61f09803b270aa1c61b68e0 (patch)
treed127d889ee21474d6fb845a190c87fb12eab2eca /graphics/java/android/renderscript/BaseObj.java
parentb5a57ad94388ebcd3717a6970a12449055eadabe (diff)
downloadframeworks_base-36e612a488511940b61f09803b270aa1c61b68e0.zip
frameworks_base-36e612a488511940b61f09803b270aa1c61b68e0.tar.gz
frameworks_base-36e612a488511940b61f09803b270aa1c61b68e0.tar.bz2
Begin splitting up RenderScript.java into seperate classes. First piece split off Element.
Diffstat (limited to 'graphics/java/android/renderscript/BaseObj.java')
-rw-r--r--graphics/java/android/renderscript/BaseObj.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/graphics/java/android/renderscript/BaseObj.java b/graphics/java/android/renderscript/BaseObj.java
new file mode 100644
index 0000000..f70aee5
--- /dev/null
+++ b/graphics/java/android/renderscript/BaseObj.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.renderscript;
+
+import android.util.Log;
+
+/**
+ * @hide
+ *
+ **/
+class BaseObj {
+
+ BaseObj(RenderScript rs) {
+ mRS = rs;
+ mID = 0;
+ }
+
+ public int getID() {
+ return mID;
+ }
+
+ int mID;
+ String mName;
+ RenderScript mRS;
+
+ public void setName(String s) throws IllegalStateException, IllegalArgumentException
+ {
+ if(s.length() < 1) {
+ throw new IllegalArgumentException("setName does not accept a zero length string.");
+ }
+ if(mName != null) {
+ throw new IllegalArgumentException("setName object already has a name.");
+ }
+
+ try {
+ byte[] bytes = s.getBytes("UTF-8");
+ mRS.nAssignName(mID, bytes);
+ mName = s;
+ } catch (java.io.UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected void finalize() throws Throwable
+ {
+ if (mID != 0) {
+ Log.v(RenderScript.LOG_TAG,
+ "Element finalized without having released the RS reference.");
+ }
+ super.finalize();
+ }
+}
+