Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 74befcc7 authored by Jack Palevich's avatar Jack Palevich Committed by Android Git Automerger
Browse files

am 981ccfbb: Implement Matrix Palette extension.

Merge commit '981ccfbb' into eclair-mr2-plus-aosp

* commit '981ccfbb':
  Implement Matrix Palette extension.
parents fac57636 981ccfbb
Loading
Loading
Loading
Loading
+32 −9
Original line number Diff line number Diff line
@@ -24,6 +24,13 @@
#include <GLES/gl.h>
#include <GLES/glext.h>

/* special calls implemented in Android's GLES wrapper used to more
 * efficiently bound-check passed arrays */
extern "C" {
GL_API void GL_APIENTRY glPointSizePointerOESBounds(GLenum type, GLsizei stride,
        const GLvoid *ptr, GLsizei count);
}

static int initialized = 0;

static jclass nioAccessClass;
@@ -122,6 +129,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;
}

// --------------------------------------------------------------------------

/* void glBindBuffer ( GLenum target, GLuint buffer ) */
@@ -2035,21 +2055,24 @@ exit:

/* void glPointSizePointerOES ( GLenum type, GLsizei stride, const GLvoid *pointer ) */
static void
android_glPointSizePointerOES__IILjava_nio_Buffer_2
  (JNIEnv *_env, jobject _this, jint type, jint stride, jobject pointer_buf) {
android_glPointSizePointerOESBounds__IILjava_nio_Buffer_2I
  (JNIEnv *_env, jobject _this, jint type, jint stride, jobject pointer_buf, jint remaining) {
    jarray _array = (jarray) 0;
    jint _remaining;
    GLvoid *pointer = (GLvoid *) 0;

    pointer = (GLvoid *)getPointer(_env, pointer_buf, &_array, &_remaining);
    glPointSizePointerOES(
    if (pointer_buf) {
        pointer = (GLvoid *) getDirectBufferPointer(_env, pointer_buf);
        if ( ! pointer ) {
            return;
        }
    }
    glPointSizePointerOESBounds(
        (GLenum)type,
        (GLsizei)stride,
        (GLvoid *)pointer
        (GLvoid *)pointer,
        (GLsizei)remaining
    );
    if (_array) {
        releasePointer(_env, _array, pointer, JNI_FALSE);
    }
}

/* void glTexCoordPointer ( GLint size, GLenum type, GLsizei stride, GLint offset ) */
@@ -2454,7 +2477,7 @@ static JNINativeMethod methods[] = {
{"glPointParameterx", "(II)V", (void *) android_glPointParameterx__II },
{"glPointParameterxv", "(I[II)V", (void *) android_glPointParameterxv__I_3II },
{"glPointParameterxv", "(ILjava/nio/IntBuffer;)V", (void *) android_glPointParameterxv__ILjava_nio_IntBuffer_2 },
{"glPointSizePointerOES", "(IILjava/nio/Buffer;)V", (void *) android_glPointSizePointerOES__IILjava_nio_Buffer_2 },
{"glPointSizePointerOESBounds", "(IILjava/nio/Buffer;I)V", (void *) android_glPointSizePointerOESBounds__IILjava_nio_Buffer_2I },
{"glTexCoordPointer", "(IIII)V", (void *) android_glTexCoordPointer__IIII },
{"glTexEnvi", "(III)V", (void *) android_glTexEnvi__III },
{"glTexEnviv", "(II[II)V", (void *) android_glTexEnviv__II_3II },
+65 −14
Original line number Diff line number Diff line
@@ -24,6 +24,15 @@
#include <GLES/gl.h>
#include <GLES/glext.h>

/* special calls implemented in Android's GLES wrapper used to more
 * efficiently bound-check passed arrays */
extern "C" {
GL_API void GL_APIENTRY glMatrixIndexPointerOESBounds(GLint size, GLenum type, GLsizei stride,
        const GLvoid *ptr, GLsizei count);
GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type, GLsizei stride,
        const GLvoid *ptr, GLsizei count);
}

static int initialized = 0;

static jclass nioAccessClass;
@@ -122,6 +131,18 @@ 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;
}
// --------------------------------------------------------------------------

/* void glBlendEquationSeparateOES ( GLenum modeRGB, GLenum modeAlpha ) */
@@ -1771,32 +1792,62 @@ android_glGenerateMipmapOES__I
static void
android_glCurrentPaletteMatrixOES__I
  (JNIEnv *_env, jobject _this, jint matrixpaletteindex) {
    _env->ThrowNew(UOEClass,
        "glCurrentPaletteMatrixOES");
    glCurrentPaletteMatrixOES(
        (GLuint)matrixpaletteindex
    );
}

/* void glLoadPaletteFromModelViewMatrixOES ( void ) */
static void
android_glLoadPaletteFromModelViewMatrixOES__
  (JNIEnv *_env, jobject _this) {
    _env->ThrowNew(UOEClass,
        "glLoadPaletteFromModelViewMatrixOES");
    glLoadPaletteFromModelViewMatrixOES();
}

/* void glMatrixIndexPointerOES ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) */
static void
android_glMatrixIndexPointerOES__IIILjava_nio_Buffer_2
  (JNIEnv *_env, jobject _this, jint size, jint type, jint stride, jobject pointer_buf) {
    _env->ThrowNew(UOEClass,
        "glMatrixIndexPointerOES");
android_glMatrixIndexPointerOESBounds__IIILjava_nio_Buffer_2I
  (JNIEnv *_env, jobject _this, jint size, jint type, jint stride, jobject pointer_buf, jint remaining) {
    jarray _array = (jarray) 0;
    jint _remaining;
    GLvoid *pointer = (GLvoid *) 0;

    if (pointer_buf) {
        pointer = (GLvoid *) getDirectBufferPointer(_env, pointer_buf);
        if ( ! pointer ) {
            return;
        }
    }
    glMatrixIndexPointerOESBounds(
        (GLint)size,
        (GLenum)type,
        (GLsizei)stride,
        (GLvoid *)pointer,
        (GLsizei)remaining
    );
}

/* void glWeightPointerOES ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) */
static void
android_glWeightPointerOES__IIILjava_nio_Buffer_2
  (JNIEnv *_env, jobject _this, jint size, jint type, jint stride, jobject pointer_buf) {
    _env->ThrowNew(UOEClass,
        "glWeightPointerOES");
android_glWeightPointerOESBounds__IIILjava_nio_Buffer_2I
  (JNIEnv *_env, jobject _this, jint size, jint type, jint stride, jobject pointer_buf, jint remaining) {
    jarray _array = (jarray) 0;
    jint _remaining;
    GLvoid *pointer = (GLvoid *) 0;

    if (pointer_buf) {
        pointer = (GLvoid *) getDirectBufferPointer(_env, pointer_buf);
        if ( ! pointer ) {
            return;
        }
    }
    glWeightPointerOESBounds(
        (GLint)size,
        (GLenum)type,
        (GLsizei)stride,
        (GLvoid *)pointer,
        (GLsizei)remaining
    );
}

/* void glDepthRangefOES ( GLclampf zNear, GLclampf zFar ) */
@@ -2426,8 +2477,8 @@ static JNINativeMethod methods[] = {
{"glGenerateMipmapOES", "(I)V", (void *) android_glGenerateMipmapOES__I },
{"glCurrentPaletteMatrixOES", "(I)V", (void *) android_glCurrentPaletteMatrixOES__I },
{"glLoadPaletteFromModelViewMatrixOES", "()V", (void *) android_glLoadPaletteFromModelViewMatrixOES__ },
{"glMatrixIndexPointerOES", "(IIILjava/nio/Buffer;)V", (void *) android_glMatrixIndexPointerOES__IIILjava_nio_Buffer_2 },
{"glWeightPointerOES", "(IIILjava/nio/Buffer;)V", (void *) android_glWeightPointerOES__IIILjava_nio_Buffer_2 },
{"glMatrixIndexPointerOESBounds", "(IIILjava/nio/Buffer;I)V", (void *) android_glMatrixIndexPointerOESBounds__IIILjava_nio_Buffer_2I },
{"glWeightPointerOESBounds", "(IIILjava/nio/Buffer;I)V", (void *) android_glWeightPointerOESBounds__IIILjava_nio_Buffer_2I },
{"glDepthRangefOES", "(FF)V", (void *) android_glDepthRangefOES__FF },
{"glFrustumfOES", "(FFFFFF)V", (void *) android_glFrustumfOES__FFFFFF },
{"glOrthofOES", "(FFFFFF)V", (void *) android_glOrthofOES__FFFFFF },
+74 −27
Original line number Diff line number Diff line
@@ -35,6 +35,12 @@ GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type,
        GLsizei stride, const GLvoid *pointer, GLsizei count);
GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type,
        GLsizei stride, const GLvoid *pointer, GLsizei count);
GL_API void GL_APIENTRY glPointSizePointerOESBounds(GLenum type,
        GLsizei stride, const GLvoid *pointer, GLsizei count);
GL_API void GL_APIENTRY glMatrixIndexPointerOESBounds(GLint size, GLenum type,
        GLsizei stride, const GLvoid *pointer, GLsizei count);
GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type,
        GLsizei stride, const GLvoid *pointer, GLsizei count);
}

static int initialized = 0;
@@ -5391,21 +5397,24 @@ exit:

/* void glPointSizePointerOES ( GLenum type, GLsizei stride, const GLvoid *pointer ) */
static void
android_glPointSizePointerOES__IILjava_nio_Buffer_2
  (JNIEnv *_env, jobject _this, jint type, jint stride, jobject pointer_buf) {
android_glPointSizePointerOESBounds__IILjava_nio_Buffer_2I
  (JNIEnv *_env, jobject _this, jint type, jint stride, jobject pointer_buf, jint remaining) {
    jarray _array = (jarray) 0;
    jint _remaining;
    GLvoid *pointer = (GLvoid *) 0;

    pointer = (GLvoid *)getPointer(_env, pointer_buf, &_array, &_remaining);
    glPointSizePointerOES(
    if (pointer_buf) {
        pointer = (GLvoid *) getDirectBufferPointer(_env, pointer_buf);
        if ( ! pointer ) {
            return;
        }
    }
    glPointSizePointerOESBounds(
        (GLenum)type,
        (GLsizei)stride,
        (GLvoid *)pointer
        (GLvoid *)pointer,
        (GLsizei)remaining
    );
    if (_array) {
        releasePointer(_env, _array, pointer, JNI_FALSE);
    }
}

/* void glTexCoordPointer ( GLint size, GLenum type, GLsizei stride, GLint offset ) */
@@ -5754,8 +5763,9 @@ android_glVertexPointer__IIII
static void
android_glCurrentPaletteMatrixOES__I
  (JNIEnv *_env, jobject _this, jint matrixpaletteindex) {
    _env->ThrowNew(UOEClass,
        "glCurrentPaletteMatrixOES");
    glCurrentPaletteMatrixOES(
        (GLuint)matrixpaletteindex
    );
}

/* void glDrawTexfOES ( GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height ) */
@@ -6050,40 +6060,77 @@ exit:
static void
android_glLoadPaletteFromModelViewMatrixOES__
  (JNIEnv *_env, jobject _this) {
    _env->ThrowNew(UOEClass,
        "glLoadPaletteFromModelViewMatrixOES");
    glLoadPaletteFromModelViewMatrixOES();
}

/* void glMatrixIndexPointerOES ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) */
static void
android_glMatrixIndexPointerOES__IIILjava_nio_Buffer_2
  (JNIEnv *_env, jobject _this, jint size, jint type, jint stride, jobject pointer_buf) {
    _env->ThrowNew(UOEClass,
        "glMatrixIndexPointerOES");
android_glMatrixIndexPointerOESBounds__IIILjava_nio_Buffer_2I
  (JNIEnv *_env, jobject _this, jint size, jint type, jint stride, jobject pointer_buf, jint remaining) {
    jarray _array = (jarray) 0;
    jint _remaining;
    GLvoid *pointer = (GLvoid *) 0;

    if (pointer_buf) {
        pointer = (GLvoid *) getDirectBufferPointer(_env, pointer_buf);
        if ( ! pointer ) {
            return;
        }
    }
    glMatrixIndexPointerOESBounds(
        (GLint)size,
        (GLenum)type,
        (GLsizei)stride,
        (GLvoid *)pointer,
        (GLsizei)remaining
    );
}

/* void glMatrixIndexPointerOES ( GLint size, GLenum type, GLsizei stride, GLint offset ) */
static void
android_glMatrixIndexPointerOES__IIII
  (JNIEnv *_env, jobject _this, jint size, jint type, jint stride, jint offset) {
    _env->ThrowNew(UOEClass,
        "glMatrixIndexPointerOES");
    glMatrixIndexPointerOES(
        (GLint)size,
        (GLenum)type,
        (GLsizei)stride,
        (const GLvoid *)offset
    );
}

/* void glWeightPointerOES ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) */
static void
android_glWeightPointerOES__IIILjava_nio_Buffer_2
  (JNIEnv *_env, jobject _this, jint size, jint type, jint stride, jobject pointer_buf) {
    _env->ThrowNew(UOEClass,
        "glWeightPointerOES");
android_glWeightPointerOESBounds__IIILjava_nio_Buffer_2I
  (JNIEnv *_env, jobject _this, jint size, jint type, jint stride, jobject pointer_buf, jint remaining) {
    jarray _array = (jarray) 0;
    jint _remaining;
    GLvoid *pointer = (GLvoid *) 0;

    if (pointer_buf) {
        pointer = (GLvoid *) getDirectBufferPointer(_env, pointer_buf);
        if ( ! pointer ) {
            return;
        }
    }
    glWeightPointerOESBounds(
        (GLint)size,
        (GLenum)type,
        (GLsizei)stride,
        (GLvoid *)pointer,
        (GLsizei)remaining
    );
}

/* void glWeightPointerOES ( GLint size, GLenum type, GLsizei stride, GLint offset ) */
static void
android_glWeightPointerOES__IIII
  (JNIEnv *_env, jobject _this, jint size, jint type, jint stride, jint offset) {
    _env->ThrowNew(UOEClass,
        "glWeightPointerOES");
    glWeightPointerOES(
        (GLint)size,
        (GLenum)type,
        (GLsizei)stride,
        (const GLvoid *)offset
    );
}

/* void glBindFramebufferOES ( GLint target, GLint framebuffer ) */
@@ -6584,7 +6631,7 @@ static JNINativeMethod methods[] = {
{"glPointParameterx", "(II)V", (void *) android_glPointParameterx__II },
{"glPointParameterxv", "(I[II)V", (void *) android_glPointParameterxv__I_3II },
{"glPointParameterxv", "(ILjava/nio/IntBuffer;)V", (void *) android_glPointParameterxv__ILjava_nio_IntBuffer_2 },
{"glPointSizePointerOES", "(IILjava/nio/Buffer;)V", (void *) android_glPointSizePointerOES__IILjava_nio_Buffer_2 },
{"glPointSizePointerOESBounds", "(IILjava/nio/Buffer;I)V", (void *) android_glPointSizePointerOESBounds__IILjava_nio_Buffer_2I },
{"glTexCoordPointer", "(IIII)V", (void *) android_glTexCoordPointer__IIII },
{"glTexEnvi", "(III)V", (void *) android_glTexEnvi__III },
{"glTexEnviv", "(II[II)V", (void *) android_glTexEnviv__II_3II },
@@ -6611,9 +6658,9 @@ static JNINativeMethod methods[] = {
{"glDrawTexxvOES", "([II)V", (void *) android_glDrawTexxvOES___3II },
{"glDrawTexxvOES", "(Ljava/nio/IntBuffer;)V", (void *) android_glDrawTexxvOES__Ljava_nio_IntBuffer_2 },
{"glLoadPaletteFromModelViewMatrixOES", "()V", (void *) android_glLoadPaletteFromModelViewMatrixOES__ },
{"glMatrixIndexPointerOES", "(IIILjava/nio/Buffer;)V", (void *) android_glMatrixIndexPointerOES__IIILjava_nio_Buffer_2 },
{"glMatrixIndexPointerOESBounds", "(IIILjava/nio/Buffer;I)V", (void *) android_glMatrixIndexPointerOESBounds__IIILjava_nio_Buffer_2I },
{"glMatrixIndexPointerOES", "(IIII)V", (void *) android_glMatrixIndexPointerOES__IIII },
{"glWeightPointerOES", "(IIILjava/nio/Buffer;)V", (void *) android_glWeightPointerOES__IIILjava_nio_Buffer_2 },
{"glWeightPointerOESBounds", "(IIILjava/nio/Buffer;I)V", (void *) android_glWeightPointerOESBounds__IIILjava_nio_Buffer_2I },
{"glWeightPointerOES", "(IIII)V", (void *) android_glWeightPointerOES__IIII },
{"glBindFramebufferOES", "(II)V", (void *) android_glBindFramebufferOES__II },
{"glBindRenderbufferOES", "(II)V", (void *) android_glBindRenderbufferOES__II },
+22 −2
Original line number Diff line number Diff line
@@ -150,6 +150,7 @@ public class GLES11 extends GLES10 {
	    _nativeClassInit();
    }

    private static Buffer _pointSizePointerOES;
    // C function void glBindBuffer ( GLenum target, GLuint buffer )

    public static native void glBindBuffer(
@@ -596,12 +597,31 @@ public class GLES11 extends GLES10 {

    // C function void glPointSizePointerOES ( GLenum type, GLsizei stride, const GLvoid *pointer )

    public static native void glPointSizePointerOES(
    private static native void glPointSizePointerOESBounds(
        int type,
        int stride,
        java.nio.Buffer pointer
        java.nio.Buffer pointer,
        int remaining
    );

    public static void glPointSizePointerOES(
        int type,
        int stride,
        java.nio.Buffer pointer
    ) {
        glPointSizePointerOESBounds(
            type,
            stride,
            pointer,
            pointer.remaining()
        );
        if (((type == GL_FLOAT) ||
             (type == GL_FIXED)) &&
            (stride >= 0)) {
            _pointSizePointerOES = pointer;
        }
    }

    // C function void glTexCoordPointer ( GLint size, GLenum type, GLsizei stride, GLint offset )

    public static native void glTexCoordPointer(
+54 −4
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@

package android.opengl;

import java.nio.Buffer;

public class GLES11Ext {
    public static final int GL_BLEND_EQUATION_RGB_OES                               = 0x8009;
    public static final int GL_BLEND_EQUATION_ALPHA_OES                             = 0x883D;
@@ -129,6 +131,12 @@ public class GLES11Ext {
	    _nativeClassInit();
    }
    
    private static final int GL_BYTE = GLES10.GL_BYTE;
    private static final int GL_FIXED = GLES10.GL_FIXED;
    private static final int GL_FLOAT = GLES10.GL_FLOAT;
    private static final int GL_SHORT = GLES10.GL_SHORT;
    
    private static Buffer _matrixIndexPointerOES;
    // C function void glBlendEquationSeparateOES ( GLenum modeRGB, GLenum modeAlpha )

    public static native void glBlendEquationSeparateOES(
@@ -866,21 +874,63 @@ public class GLES11Ext {

    // C function void glMatrixIndexPointerOES ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )

    public static native void glMatrixIndexPointerOES(
    private static native void glMatrixIndexPointerOESBounds(
        int size,
        int type,
        int stride,
        java.nio.Buffer pointer
        java.nio.Buffer pointer,
        int remaining
    );

    public static void glMatrixIndexPointerOES(
        int size,
        int type,
        int stride,
        java.nio.Buffer pointer
    ) {
        glMatrixIndexPointerOESBounds(
            size,
            type,
            stride,
            pointer,
            pointer.remaining()
        );
        if (((size == 2) ||
             (size == 3) ||
             (size == 4)) &&
            ((type == GL_FLOAT) ||
             (type == GL_BYTE) ||
             (type == GL_SHORT) ||
             (type == GL_FIXED)) &&
            (stride >= 0)) {
            _matrixIndexPointerOES = pointer;
        }
    }

    // C function void glWeightPointerOES ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )

    public static native void glWeightPointerOES(
    private static native void glWeightPointerOESBounds(
        int size,
        int type,
        int stride,
        java.nio.Buffer pointer,
        int remaining
    );

    public static void glWeightPointerOES(
        int size,
        int type,
        int stride,
        java.nio.Buffer pointer
    ) {
        glWeightPointerOESBounds(
            size,
            type,
            stride,
            pointer,
            pointer.remaining()
        );
    }

    // C function void glDepthRangefOES ( GLclampf zNear, GLclampf zFar )

Loading