diff options
author | Jack Palevich <jackpal@google.com> | 2009-05-15 18:13:34 -0700 |
---|---|---|
committer | Jack Palevich <jackpal@google.com> | 2009-05-15 18:13:34 -0700 |
commit | 16e7972f0d986eebf846ea8feb50f4435a9c6970 (patch) | |
tree | f5de2dace8158a51e9aed2304311054ffa7c3013 /core | |
parent | b3af6b4805040ea42c01765387c99089822bbe7e (diff) | |
download | frameworks_base-16e7972f0d986eebf846ea8feb50f4435a9c6970.zip frameworks_base-16e7972f0d986eebf846ea8feb50f4435a9c6970.tar.gz frameworks_base-16e7972f0d986eebf846ea8feb50f4435a9c6970.tar.bz2 |
Fix bug 1856713 gl Pointer functions should use Buffer position
JSR239 and android.opengl gl Pointer functions (glColorPointer, etc.)
now respect the current setting of the Buffer position.
This fixes a regression introduced when we started requiring the
Buffers passed to the Pointer functions to be direct Buffers.
Diffstat (limited to 'core')
-rw-r--r-- | core/jni/android_opengl_GLES10.cpp | 25 | ||||
-rw-r--r-- | core/jni/com_google_android_gles_jni_GLImpl.cpp | 25 |
2 files changed, 34 insertions, 16 deletions
diff --git a/core/jni/android_opengl_GLES10.cpp b/core/jni/android_opengl_GLES10.cpp index 482d8eb..2685d75 100644 --- a/core/jni/android_opengl_GLES10.cpp +++ b/core/jni/android_opengl_GLES10.cpp @@ -133,6 +133,19 @@ releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit) commit ? 0 : JNI_ABORT); } +static void * +getDirectBufferPointer(JNIEnv *_env, jobject buffer) { + char* buf = (char*) _env->GetDirectBufferAddress(buffer); + if (buf) { + jint position = _env->GetIntField(buffer, positionID); + jint elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID); + buf += position << elementSizeShift; + } else { + _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); + } + return (void*) buf; +} + static int getNumCompressedTextureFormats() { int numCompressedTextureFormats = 0; @@ -305,9 +318,8 @@ android_glColorPointerBounds__IIILjava_nio_Buffer_2I GLvoid *pointer = (GLvoid *) 0; if (pointer_buf) { - pointer = (GLvoid *) _env->GetDirectBufferAddress(pointer_buf); + pointer = (GLvoid *) getDirectBufferPointer(_env, pointer_buf); if ( ! pointer ) { - _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); return; } } @@ -2779,9 +2791,8 @@ android_glNormalPointerBounds__IILjava_nio_Buffer_2I GLvoid *pointer = (GLvoid *) 0; if (pointer_buf) { - pointer = (GLvoid *) _env->GetDirectBufferAddress(pointer_buf); + pointer = (GLvoid *) getDirectBufferPointer(_env, pointer_buf); if ( ! pointer ) { - _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); return; } } @@ -3034,9 +3045,8 @@ android_glTexCoordPointerBounds__IIILjava_nio_Buffer_2I GLvoid *pointer = (GLvoid *) 0; if (pointer_buf) { - pointer = (GLvoid *) _env->GetDirectBufferAddress(pointer_buf); + pointer = (GLvoid *) getDirectBufferPointer(_env, pointer_buf); if ( ! pointer ) { - _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); return; } } @@ -3392,9 +3402,8 @@ android_glVertexPointerBounds__IIILjava_nio_Buffer_2I GLvoid *pointer = (GLvoid *) 0; if (pointer_buf) { - pointer = (GLvoid *) _env->GetDirectBufferAddress(pointer_buf); + pointer = (GLvoid *) getDirectBufferPointer(_env, pointer_buf); if ( ! pointer ) { - _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); return; } } diff --git a/core/jni/com_google_android_gles_jni_GLImpl.cpp b/core/jni/com_google_android_gles_jni_GLImpl.cpp index 11822e0..15e3a81 100644 --- a/core/jni/com_google_android_gles_jni_GLImpl.cpp +++ b/core/jni/com_google_android_gles_jni_GLImpl.cpp @@ -133,6 +133,19 @@ releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit) commit ? 0 : JNI_ABORT); } +static void * +getDirectBufferPointer(JNIEnv *_env, jobject buffer) { + char* buf = (char*) _env->GetDirectBufferAddress(buffer); + if (buf) { + jint position = _env->GetIntField(buffer, positionID); + jint elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID); + buf += position << elementSizeShift; + } else { + _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); + } + return (void*) buf; +} + static int getNumCompressedTextureFormats() { int numCompressedTextureFormats = 0; @@ -305,9 +318,8 @@ android_glColorPointerBounds__IIILjava_nio_Buffer_2I GLvoid *pointer = (GLvoid *) 0; if (pointer_buf) { - pointer = (GLvoid *) _env->GetDirectBufferAddress(pointer_buf); + pointer = (GLvoid *) getDirectBufferPointer(_env, pointer_buf); if ( ! pointer ) { - _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); return; } } @@ -2779,9 +2791,8 @@ android_glNormalPointerBounds__IILjava_nio_Buffer_2I GLvoid *pointer = (GLvoid *) 0; if (pointer_buf) { - pointer = (GLvoid *) _env->GetDirectBufferAddress(pointer_buf); + pointer = (GLvoid *) getDirectBufferPointer(_env, pointer_buf); if ( ! pointer ) { - _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); return; } } @@ -3034,9 +3045,8 @@ android_glTexCoordPointerBounds__IIILjava_nio_Buffer_2I GLvoid *pointer = (GLvoid *) 0; if (pointer_buf) { - pointer = (GLvoid *) _env->GetDirectBufferAddress(pointer_buf); + pointer = (GLvoid *) getDirectBufferPointer(_env, pointer_buf); if ( ! pointer ) { - _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); return; } } @@ -3392,9 +3402,8 @@ android_glVertexPointerBounds__IIILjava_nio_Buffer_2I GLvoid *pointer = (GLvoid *) 0; if (pointer_buf) { - pointer = (GLvoid *) _env->GetDirectBufferAddress(pointer_buf); + pointer = (GLvoid *) getDirectBufferPointer(_env, pointer_buf); if ( ! pointer ) { - _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); return; } } |