diff options
author | Elliott Hughes <enh@google.com> | 2011-04-08 20:01:01 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2011-04-11 15:31:20 -0700 |
commit | 24ce5fb2cc09d0a14406e7b935f8648c5720d27e (patch) | |
tree | 022bd63502ea1a649ecf32bdb3dc2e0205376901 /opengl/tools/glgen/stubs/jsr239 | |
parent | 7797e647fc8fcd5091b9449c0044f5cb70db5b47 (diff) | |
download | frameworks_base-24ce5fb2cc09d0a14406e7b935f8648c5720d27e.zip frameworks_base-24ce5fb2cc09d0a14406e7b935f8648c5720d27e.tar.gz frameworks_base-24ce5fb2cc09d0a14406e7b935f8648c5720d27e.tar.bz2 |
Kill the global references in the OpenGL wrappers.
Just use jniThrowException instead. Note that it would be trivial to throw
seemingly more appropriate exceptions (NullPointerException and
OutOfMemoryException in particular), but I'm only attempting to preserve
existing behavior here.
I also found shadowing bugs in some of the special-case functions, which
would previously always have leaked memory.
This also moves an accidental change to a generated file (ActivityThread ->
AppGlobals) into the generator, so it won't be overwritten in future.
Change-Id: Iab570310b568cb406c60dd0e2b8211f8a36ae590
Diffstat (limited to 'opengl/tools/glgen/stubs/jsr239')
-rw-r--r-- | opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp | 54 | ||||
-rw-r--r-- | opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl | 4 | ||||
-rw-r--r-- | opengl/tools/glgen/stubs/jsr239/glGetString.cpp | 12 |
3 files changed, 21 insertions, 49 deletions
diff --git a/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp b/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp index c2464b0..f7315ee 100644 --- a/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp +++ b/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp @@ -1,21 +1,23 @@ ** ** Copyright 2006, 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 +** 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 +** 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 +** 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. */ // This source file is automatically generated +#include "jni.h" +#include "JNIHelp.h" #include <android_runtime/AndroidRuntime.h> #include <utils/misc.h> @@ -63,10 +65,6 @@ static int initialized = 0; static jclass nioAccessClass; static jclass bufferClass; -static jclass OOMEClass; -static jclass UOEClass; -static jclass IAEClass; -static jclass AIOOBEClass; static jclass G11ImplClass; static jmethodID getBasePointerID; static jmethodID getBaseArrayID; @@ -84,7 +82,7 @@ static jfieldID have_OES_texture_cube_mapID; /* Cache method IDs each time the class is loaded. */ static void -nativeClassInitBuffer(JNIEnv *_env) +nativeClassInit(JNIEnv *_env, jclass glImplClass) { jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess"); nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal); @@ -114,26 +112,6 @@ nativeClassInitBuffer(JNIEnv *_env) _env->GetFieldID(bufferClass, "_elementSizeShift", "I"); } -static void -nativeClassInit(JNIEnv *_env, jclass glImplClass) -{ - nativeClassInitBuffer(_env); - - jclass IAEClassLocal = - _env->FindClass("java/lang/IllegalArgumentException"); - jclass OOMEClassLocal = - _env->FindClass("java/lang/OutOfMemoryError"); - jclass UOEClassLocal = - _env->FindClass("java/lang/UnsupportedOperationException"); - jclass AIOOBEClassLocal = - _env->FindClass("java/lang/ArrayIndexOutOfBoundsException"); - - IAEClass = (jclass) _env->NewGlobalRef(IAEClassLocal); - OOMEClass = (jclass) _env->NewGlobalRef(OOMEClassLocal); - UOEClass = (jclass) _env->NewGlobalRef(UOEClassLocal); - AIOOBEClass = (jclass) _env->NewGlobalRef(AIOOBEClassLocal); -} - static void * getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) { @@ -154,7 +132,7 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) *array = NULL; return (void *) (jint) pointer; } - + *array = (jarray) _env->CallStaticObjectMethod(nioAccessClass, getBaseArrayID, buffer); if (*array == NULL) { @@ -163,7 +141,7 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) offset = _env->CallStaticIntMethod(nioAccessClass, getBaseArrayOffsetID, buffer); data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0); - + return (void *) ((char *) data + offset); } @@ -207,7 +185,8 @@ getDirectBufferPointer(JNIEnv *_env, jobject buffer) { releasePointer(_env, array, buf, 0); } } else { - _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); + jniThrowException(_env, "java/lang/IllegalArgumentException", + "Must use a native order direct Buffer"); } } return buf; @@ -250,7 +229,7 @@ nextExtension(const GLubyte* pExtensions) { } } } - + static bool checkForExtension(const GLubyte* pExtensions, const GLubyte* pExtension) { for (;*pExtensions != '\0'; pExtensions = nextExtension(pExtensions)) { @@ -279,4 +258,3 @@ supportsExtension(JNIEnv *_env, jobject impl, jfieldID fieldId) { } // -------------------------------------------------------------------------- - diff --git a/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl b/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl index 3727106..cd730aa 100644 --- a/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl +++ b/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl @@ -18,7 +18,7 @@ package com.google.android.gles_jni; -import android.app.ActivityThread; +import android.app.AppGlobals; import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.os.Build; @@ -64,7 +64,7 @@ public class GLImpl implements GL10, GL10Ext, GL11, GL11Ext, GL11ExtensionPack { private static boolean allowIndirectBuffers(String appName) { boolean result = false; int version = 0; - IPackageManager pm = ActivityThread.getPackageManager(); + IPackageManager pm = AppGlobals.getPackageManager(); try { ApplicationInfo applicationInfo = pm.getApplicationInfo(appName, 0); if (applicationInfo != null) { diff --git a/opengl/tools/glgen/stubs/jsr239/glGetString.cpp b/opengl/tools/glgen/stubs/jsr239/glGetString.cpp index a400859..cd6e3f3 100644 --- a/opengl/tools/glgen/stubs/jsr239/glGetString.cpp +++ b/opengl/tools/glgen/stubs/jsr239/glGetString.cpp @@ -1,11 +1,5 @@ -#include <string.h>
-
/* const GLubyte * glGetString ( GLenum name ) */
-static
-jstring
-android_glGetString
- (JNIEnv *_env, jobject _this, jint name) {
- const char * chars = (const char *)glGetString((GLenum)name);
- jstring output = _env->NewStringUTF(chars);
- return output;
+static jstring android_glGetString(JNIEnv *_env, jobject, jint name) {
+ const char* chars = (const char*) glGetString((GLenum) name);
+ return _env->NewStringUTF(chars);
}
|