summaryrefslogtreecommitdiffstats
path: root/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'opengl')
-rw-r--r--opengl/libagl/Android.mk2
-rw-r--r--opengl/libagl/egl.cpp30
-rw-r--r--opengl/libs/Android.mk2
-rw-r--r--opengl/libs/EGL/egl_display.cpp8
-rw-r--r--opengl/libs/GLES2/gl2.cpp11
-rw-r--r--opengl/libs/GLES_trace/src/gltrace_context.cpp12
-rw-r--r--opengl/libs/GLES_trace/src/gltrace_context.h4
-rw-r--r--opengl/libs/GLES_trace/src/gltrace_fixup.cpp11
-rw-r--r--opengl/specs/EGL_ANDROID_fence_sync.txt268
-rw-r--r--opengl/specs/README5
-rw-r--r--opengl/tests/Android.mk11
-rw-r--r--opengl/tests/hwc/hwcColorEquiv.cpp16
-rw-r--r--opengl/tests/hwc/hwcCommit.cpp8
-rw-r--r--opengl/tests/hwc/hwcRects.cpp12
-rw-r--r--opengl/tests/hwc/hwcStress.cpp14
-rw-r--r--opengl/tests/hwc/hwcTestLib.cpp20
-rw-r--r--opengl/tests/hwc/hwcTestLib.h12
-rwxr-xr-xopengl/tools/glgen/gen46
-rw-r--r--opengl/tools/glgen/specs/egl/EGL14.spec33
-rw-r--r--opengl/tools/glgen/specs/egl/checks.spec13
-rw-r--r--opengl/tools/glgen/src/CFunc.java8
-rw-r--r--opengl/tools/glgen/src/CType.java10
-rw-r--r--opengl/tools/glgen/src/EGLCodeEmitter.java58
-rw-r--r--opengl/tools/glgen/src/GenerateEGL.java109
-rw-r--r--opengl/tools/glgen/src/JType.java30
-rw-r--r--opengl/tools/glgen/src/JniCodeEmitter.java554
-rw-r--r--opengl/tools/glgen/static/egl/EGLConfig.java37
-rw-r--r--opengl/tools/glgen/static/egl/EGLContext.java37
-rw-r--r--opengl/tools/glgen/static/egl/EGLDisplay.java37
-rw-r--r--opengl/tools/glgen/static/egl/EGLObjectHandle.java47
-rw-r--r--opengl/tools/glgen/static/egl/EGLSurface.java37
-rw-r--r--opengl/tools/glgen/stubs/egl/EGL14Header.java-if151
-rw-r--r--opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp132
-rw-r--r--opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.cpp154
-rw-r--r--opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.java48
-rw-r--r--opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.nativeReg2
-rw-r--r--opengl/tools/glgen/stubs/egl/eglQueryString.cpp10
-rw-r--r--opengl/tools/glgen/stubs/egl/eglQueryString.java6
-rw-r--r--opengl/tools/glgen/stubs/egl/eglQueryString.nativeReg1
-rw-r--r--opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp9
-rw-r--r--opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp9
-rw-r--r--opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp10
-rw-r--r--opengl/tools/glgen/stubs/gles11/GLES11cHeader.cpp9
-rw-r--r--opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp9
-rw-r--r--opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.cpp328
-rw-r--r--opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.java47
-rw-r--r--opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.nativeReg4
-rw-r--r--opengl/tools/glgen/stubs/gles11/glGetActiveUniform.cpp329
-rw-r--r--opengl/tools/glgen/stubs/gles11/glGetActiveUniform.java46
-rw-r--r--opengl/tools/glgen/stubs/gles11/glGetActiveUniform.nativeReg4
-rw-r--r--opengl/tools/glgen/stubs/gles11/glGetShaderSource.cpp111
-rw-r--r--opengl/tools/glgen/stubs/gles11/glGetShaderSource.java25
-rw-r--r--opengl/tools/glgen/stubs/gles11/glGetShaderSource.nativeReg3
-rw-r--r--opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp13
-rw-r--r--opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl3
55 files changed, 2707 insertions, 258 deletions
diff --git a/opengl/libagl/Android.mk b/opengl/libagl/Android.mk
index 15e58f2..639c4d7 100644
--- a/opengl/libagl/Android.mk
+++ b/opengl/libagl/Android.mk
@@ -26,7 +26,7 @@ LOCAL_CFLAGS += -DLOG_TAG=\"libagl\"
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
LOCAL_CFLAGS += -fvisibility=hidden
-LOCAL_SHARED_LIBRARIES := libcutils libhardware libutils libpixelflinger libETC1
+LOCAL_SHARED_LIBRARIES := libcutils libhardware libutils libpixelflinger libETC1 libui
LOCAL_LDLIBS := -lpthread -ldl
ifeq ($(TARGET_ARCH),arm)
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index c31aebf..172ef95 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -31,6 +31,7 @@
#include <utils/threads.h>
#include <ui/ANativeObjectBase.h>
+#include <ui/Fence.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
@@ -372,7 +373,16 @@ EGLBoolean egl_window_surface_v2_t::connect()
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
// dequeue a buffer
- if (nativeWindow->dequeueBuffer(nativeWindow, &buffer) != NO_ERROR) {
+ int fenceFd = -1;
+ if (nativeWindow->dequeueBuffer(nativeWindow, &buffer,
+ &fenceFd) != NO_ERROR) {
+ return setError(EGL_BAD_ALLOC, EGL_FALSE);
+ }
+
+ // wait for the buffer
+ sp<Fence> fence(new Fence(fenceFd));
+ if (fence->wait(Fence::TIMEOUT_NEVER) != NO_ERROR) {
+ nativeWindow->cancelBuffer(nativeWindow, buffer, fenceFd);
return setError(EGL_BAD_ALLOC, EGL_FALSE);
}
@@ -392,8 +402,6 @@ EGLBoolean egl_window_surface_v2_t::connect()
// keep a reference on the buffer
buffer->common.incRef(&buffer->common);
- // Lock the buffer
- nativeWindow->lockBuffer(nativeWindow, buffer);
// pin the buffer down
if (lock(buffer, GRALLOC_USAGE_SW_READ_OFTEN |
GRALLOC_USAGE_SW_WRITE_OFTEN, &bits) != NO_ERROR) {
@@ -412,7 +420,7 @@ void egl_window_surface_v2_t::disconnect()
unlock(buffer);
}
// enqueue the last frame
- nativeWindow->queueBuffer(nativeWindow, buffer);
+ nativeWindow->queueBuffer(nativeWindow, buffer, -1);
if (buffer) {
buffer->common.decRef(&buffer->common);
buffer = 0;
@@ -517,15 +525,17 @@ EGLBoolean egl_window_surface_v2_t::swapBuffers()
unlock(buffer);
previousBuffer = buffer;
- nativeWindow->queueBuffer(nativeWindow, buffer);
+ nativeWindow->queueBuffer(nativeWindow, buffer, -1);
buffer = 0;
// dequeue a new buffer
- if (nativeWindow->dequeueBuffer(nativeWindow, &buffer) == NO_ERROR) {
-
- // TODO: lockBuffer should rather be executed when the very first
- // direct rendering occurs.
- nativeWindow->lockBuffer(nativeWindow, buffer);
+ int fenceFd = -1;
+ if (nativeWindow->dequeueBuffer(nativeWindow, &buffer, &fenceFd) == NO_ERROR) {
+ sp<Fence> fence(new Fence(fenceFd));
+ if (fence->wait(Fence::TIMEOUT_NEVER)) {
+ nativeWindow->cancelBuffer(nativeWindow, buffer, fenceFd);
+ return setError(EGL_BAD_ALLOC, EGL_FALSE);
+ }
// reallocate the depth-buffer if needed
if ((width != buffer->width) || (height != buffer->height)) {
diff --git a/opengl/libs/Android.mk b/opengl/libs/Android.mk
index 42aaa24..eea79f8 100644
--- a/opengl/libs/Android.mk
+++ b/opengl/libs/Android.mk
@@ -122,7 +122,7 @@ LOCAL_SRC_FILES:= \
GLES2/gl2.cpp.arm \
#
-LOCAL_SHARED_LIBRARIES += libcutils libEGL
+LOCAL_SHARED_LIBRARIES += libcutils libutils libEGL
LOCAL_LDLIBS := -lpthread -ldl
LOCAL_MODULE:= libGLESv2
diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp
index a46aa38..80072ab 100644
--- a/opengl/libs/EGL/egl_display.cpp
+++ b/opengl/libs/EGL/egl_display.cpp
@@ -263,7 +263,13 @@ EGLBoolean egl_display_t::terminate() {
Mutex::Autolock _l(lock);
if (refs == 0) {
- return setError(EGL_NOT_INITIALIZED, EGL_FALSE);
+ /*
+ * From the EGL spec (3.2):
+ * "Termination of a display that has already been terminated,
+ * (...), is allowed, but the only effect of such a call is
+ * to return EGL_TRUE (...)
+ */
+ return EGL_TRUE;
}
// this is specific to Android, display termination is ref-counted.
diff --git a/opengl/libs/GLES2/gl2.cpp b/opengl/libs/GLES2/gl2.cpp
index 4345c2b..b00af1b 100644
--- a/opengl/libs/GLES2/gl2.cpp
+++ b/opengl/libs/GLES2/gl2.cpp
@@ -26,6 +26,9 @@
#include <cutils/log.h>
#include <cutils/properties.h>
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+#include <utils/Trace.h>
+
#include "hooks.h"
#include "egl_impl.h"
@@ -40,6 +43,7 @@ using namespace android;
#undef CALL_GL_API_RETURN
#define DEBUG_CALL_GL_API 0
+#define SYSTRACE_CALL_GL_API 0
#if USE_FAST_TLS_KEY
@@ -86,6 +90,13 @@ using namespace android;
ALOGD("[" #_api "] 0x%x", status); \
}
+#elif SYSTRACE_CALL_GL_API
+
+ #define CALL_GL_API(_api, ...) \
+ ATRACE_CALL(); \
+ gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \
+ _c->_api(__VA_ARGS__);
+
#else
#define CALL_GL_API(_api, ...) \
diff --git a/opengl/libs/GLES_trace/src/gltrace_context.cpp b/opengl/libs/GLES_trace/src/gltrace_context.cpp
index 45dbb43..3a8decc 100644
--- a/opengl/libs/GLES_trace/src/gltrace_context.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_context.cpp
@@ -119,7 +119,7 @@ GLTraceContext *GLTraceState::createTraceContext(int version, EGLContext eglCont
const size_t DEFAULT_BUFFER_SIZE = 8192;
BufferedOutputStream *stream = new BufferedOutputStream(mStream, DEFAULT_BUFFER_SIZE);
- GLTraceContext *traceContext = new GLTraceContext(id, this, stream);
+ GLTraceContext *traceContext = new GLTraceContext(id, version, this, stream);
mPerContextState[eglContext] = traceContext;
return traceContext;
@@ -129,8 +129,10 @@ GLTraceContext *GLTraceState::getTraceContext(EGLContext c) {
return mPerContextState[c];
}
-GLTraceContext::GLTraceContext(int id, GLTraceState *state, BufferedOutputStream *stream) :
+GLTraceContext::GLTraceContext(int id, int version, GLTraceState *state,
+ BufferedOutputStream *stream) :
mId(id),
+ mVersion(version),
mState(state),
mBufferedOutputStream(stream),
mElementArrayBuffers(DefaultKeyedVector<GLuint, ElementArrayBuffer*>(NULL))
@@ -143,6 +145,10 @@ int GLTraceContext::getId() {
return mId;
}
+int GLTraceContext::getVersion() {
+ return mVersion;
+}
+
GLTraceState *GLTraceContext::getGlobalTraceState() {
return mState;
}
@@ -203,6 +209,8 @@ void GLTraceContext::traceGLMessage(GLMessage *msg) {
GLMessage_Function func = msg->function();
if (func == GLMessage::eglSwapBuffers
+ || func == GLMessage::eglCreateContext
+ || func == GLMessage::eglMakeCurrent
|| func == GLMessage::glDrawArrays
|| func == GLMessage::glDrawElements) {
mBufferedOutputStream->flush();
diff --git a/opengl/libs/GLES_trace/src/gltrace_context.h b/opengl/libs/GLES_trace/src/gltrace_context.h
index 323cfdc..4c38bba 100644
--- a/opengl/libs/GLES_trace/src/gltrace_context.h
+++ b/opengl/libs/GLES_trace/src/gltrace_context.h
@@ -50,6 +50,7 @@ public:
/** GL Trace Context info associated with each EGLContext */
class GLTraceContext {
int mId; /* unique context id */
+ int mVersion; /* GL version, e.g: egl_connection_t::GLESv2_INDEX */
GLTraceState *mState; /* parent GL Trace state (for per process GL Trace State Info) */
void *fbcontents; /* memory area to read framebuffer contents */
@@ -65,8 +66,9 @@ class GLTraceContext {
public:
gl_hooks_t *hooks;
- GLTraceContext(int id, GLTraceState *state, BufferedOutputStream *stream);
+ GLTraceContext(int id, int version, GLTraceState *state, BufferedOutputStream *stream);
int getId();
+ int getVersion();
GLTraceState *getGlobalTraceState();
void getCompressedFB(void **fb, unsigned *fbsize,
unsigned *fbwidth, unsigned *fbheight,
diff --git a/opengl/libs/GLES_trace/src/gltrace_fixup.cpp b/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
index 3597b26..1bd790e 100644
--- a/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
@@ -15,6 +15,7 @@
*/
#include <cutils/log.h>
+#include <EGL/egldefs.h>
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <GLES2/gl2.h>
@@ -592,6 +593,11 @@ void trace_VertexAttribPointerData(GLTraceContext *context,
}
void trace_VertexAttribPointerDataForGlDrawArrays(GLTraceContext *context, GLMessage *glmsg) {
+ if (context->getVersion() == egl_connection_t::GLESv1_INDEX) {
+ // only supported for GLES2 and above
+ return;
+ }
+
/* void glDrawArrays(GLenum mode, GLint first, GLsizei count) */
GLsizei count = glmsg->args(2).intvalue(0);
@@ -604,6 +610,11 @@ void trace_VertexAttribPointerDataForGlDrawArrays(GLTraceContext *context, GLMes
void trace_VertexAttribPointerDataForGlDrawElements(GLTraceContext *context, GLMessage *glmsg,
GLvoid *indices) {
+ if (context->getVersion() == egl_connection_t::GLESv1_INDEX) {
+ // only supported for GLES2 and above
+ return;
+ }
+
/* void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) */
GLsizei count = glmsg->args(1).intvalue(0);
GLenum type = glmsg->args(2).intvalue(0);
diff --git a/opengl/specs/EGL_ANDROID_fence_sync.txt b/opengl/specs/EGL_ANDROID_fence_sync.txt
new file mode 100644
index 0000000..316ee1c
--- /dev/null
+++ b/opengl/specs/EGL_ANDROID_fence_sync.txt
@@ -0,0 +1,268 @@
+Name
+
+ ANDROID_fence_sync
+
+Name Strings
+
+ EGL_ANDROID_fence_sync
+
+Contributors
+
+ Jamie Gennis
+
+Contact
+
+ Jamie Gennis, Google Inc. (jgennis 'at' google.com)
+
+Status
+
+ Draft.
+
+Version
+
+ Version 2, July 23, 2012
+
+Number
+
+ EGL Extension #XXX
+
+Dependencies
+
+ Requires EGL 1.1
+
+ This extension is written against the wording of the EGL 1.2 Specification
+
+ EGL_KHR_fence_sync is required.
+
+Overview
+
+ This extension enables the creation of EGL fence sync objects that are
+ associated with an Android Sync HAL fence object. These EGL fence sync
+ objects have nearly identical semantics to those defined by the
+ KHR_fence_sync extension, except that they have an additional attribute
+ storing the file descriptor referring to the native Android fence object.
+
+New Types
+
+ None.
+
+New Procedures and Functions
+
+ EGLint eglDupAndroidFenceFDANDROID(
+ EGLDisplay dpy,
+ EGLSyncKHR);
+
+New Tokens
+
+ Accepted by the <type> parameter of eglCreateSyncKHR, and returned
+ in <value> when eglGetSyncAttribKHR is called with <attribute>
+ EGL_SYNC_TYPE_KHR:
+
+ EGL_SYNC_ANDROID_FENCE_ANDROID 0x3144
+
+ Accepted by the <attrib_list> parameter of eglCreateSyncKHR:
+
+ EGL_SYNC_ANDROID_FENCE_FD_ANDROID 0x3145
+
+ Accepted by the <attrib_list> parameter of eglCreateSyncKHR, and returned
+ by eglDupAndroidFenceFDANDROID in the event of an error:
+
+ EGL_NO_ANDROID_FENCE_ANDROID -1
+
+ Returned in <value> when eglGetSyncAttribKHR is called with <attribute>
+ EGL_SYNC_CONDITION_KHR:
+
+ EGL_SYNC_ANDROID_FENCE_SIGNALED_ANDROID 0x3146
+
+Changes to Chapter 3 of the EGL 1.2 Specification (EGL Functions and Errors)
+
+ Add the following after the sixth paragraph of Section 3.8.1 (Sync
+ Objects), added by KHR_fence_sync
+
+ "If <type> is EGL_SYNC_ANDROID_FENCE_ANDROID, an EGL Android fence sync
+ object is created. In this case the EGL_SYNC_ANDROID_FENCE_FD_ANDROID
+ attribute may optionally be specified. If this attribute is specified, it
+ must be set to either a file descriptor that refers to a native Android
+ fence object or to the value EGL_NO_ANDROID_FENCE_ANDROID.
+
+ The default values for the EGL Android fence sync object attributes are as
+ follows:
+
+ Attribute Name Initial Attribute Value(s)
+ --------------- --------------------------
+ EGL_SYNC_TYPE_KHR EGL_SYNC_ANDROID_FENCE_ANDROID
+ EGL_SYNC_STATUS_KHR EGL_UNSIGNALED_KHR
+ EGL_SYNC_CONDITION_KHR EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR
+ EGL_SYNC_ANDROID_FENCE_FD_ANDROID EGL_NO_ANDROID_FENCE_ANDROID
+
+ If the EGL_SYNC_ANDROID_FENCE_FD_ANDROID attribute is not
+ EGL_NO_ANDROID_FENCE_ANDROID then the EGL_SYNC_CONDITION_KHR attribute is
+ set to EGL_SYNC_ANDROID_FENCE_SIGNALED_ANDROID and the EGL_SYNC_STATUS_KHR
+ attribute is set to reflect the signal status of the native Android fence
+ object. Additionally, the EGL implementation assumes ownership of the file
+ descriptor, so the caller must not use it after calling eglCreateSyncKHR."
+
+ Modify Section 3.8.1 (Sync Objects), added by KHR_fence_sync, starting at
+ the seventh paragraph
+
+ "When a fence sync object is created or when an EGL Android fence sync
+ object is created with the EGL_SYNC_ANDROID_FENCE_FD_ANDROID attribute set
+ to EGL_NO_ANDROID_FENCE_ANDROID, eglCreateSyncKHR also inserts a fence
+ command into the command stream of the bound client API's current context
+ (i.e., the context returned by eglGetCurrentContext), and associates it
+ with the newly created sync object.
+
+ After associating the fence command with an EGL Android fence sync object,
+ the next Flush() operation performed by the current client API causes a
+ new native Android fence object to be created, and the
+ EGL_SYNC_ANDROID_FENCE_ANDROID attribute of the EGL Android fence object
+ is set to a file descriptor that refers to the new native Android fence
+ object. This new native Android fence object is signaled when the EGL
+ Android fence sync object is signaled.
+
+ When the condition of the sync object is satisfied by the fence command,
+ the sync is signaled by the associated client API context, causing any
+ eglClientWaitSyncKHR commands (see below) blocking on <sync> to unblock. If
+ the sync object is an EGL Android fence sync object then the native Android
+ fence object is also signaled when the condition is satisfied. The
+ EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR condition is satisfied by completion
+ of the fence command corresponding to the sync object and all preceding
+ commands in the associated client API context's command stream. The sync
+ object will not be signaled until all effects from these commands on the
+ client API's internal and framebuffer state are fully realized. No other
+ state is affected by execution of the fence command.
+
+ The EGL_SYNC_ANDROID_FENCE_SIGNALED_ANDROID condition is satisfied by the
+ signaling of the native Android fence object referred to by the
+ EGL_SYNC_ANDROID_FENCE_FD_ANDROID attribute. When this happens any
+ eglClientWaitSyncKHR commands blocking on <sync> unblock."
+
+ Modify the list of eglCreateSyncKHR errors in Section 3.8.1 (Sync Objects),
+ added by KHR_fence_sync
+
+ "Errors
+ ------
+
+ * If <dpy> is not the name of a valid, initialized EGLDisplay,
+ EGL_NO_SYNC_KHR is returned and an EGL_BAD_DISPLAY error is
+ generated.
+ * If <type> is EGL_SYNC_FENCE_KHR and <attrib_list> is neither NULL nor
+ empty (containing only EGL_NONE), EGL_NO_SYNC_KHR is returned and an
+ EGL_BAD_ATTRIBUTE error is generated.
+ * If <type> is EGL_SYNC_ANDROID_FENCE_ANDROID and <attrib_list> contains
+ an attribute other than EGL_SYNC_ANDROID_FENCE_FD_ANDROID, EGL_NO_SYNC_KHR is
+ returned and an EGL_BAD_ATTRIBUTE error is generated.
+ * If <type> is not a supported type of sync object,
+ EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE error is
+ generated.
+ * If <type> is EGL_SYNC_FENCE_KHR or EGL_SYNC_ANDROID_FENCE_ANDROID and
+ no context is current for the bound API (i.e., eglGetCurrentContext
+ returns EGL_NO_CONTEXT), EGL_NO_SYNC_KHR is returned and an
+ EGL_BAD_MATCH error is generated.
+ * If <type> is EGL_SYNC_FENCE_KHR or EGL_SYNC_ANDROID_FENCE_ANDROID and
+ <dpy> does not match the EGLDisplay of the currently bound context for
+ the currently bound client API (the EGLDisplay returned by
+ eglGetCurrentDisplay()) then EGL_NO_SYNC_KHR is returned and an
+ EGL_BAD_MATCH error is generated.
+ * If <type> is EGL_SYNC_FENCE_KHR or EGL_SYNC_ANDROID_FENCE_ANDROID and
+ the currently bound client API does not support the client API
+ extension indicating it can place fence commands, then EGL_NO_SYNC_KHR
+ is returned and an EGL_BAD_MATCH error is generated."
+
+ Modify table 3.cc in Section 3.8.1 (Sync Objects), added by KHR_fence_sync
+
+ "
+ Attribute Description Supported Sync Objects
+ ----------------- ----------------------- ----------------------
+ EGL_SYNC_TYPE_KHR Type of the sync object All
+ EGL_SYNC_STATUS_KHR Status of the sync object All
+ EGL_SYNC_CONDITION_KHR Signaling condition EGL_SYNC_FENCE_KHR and
+ EGL_SYNC_ANDROID_FENCE_ANDROID only
+ "
+
+ Modify the second paragraph description of eglDestroySyncKHR in Section
+ 3.8.1 (Sync Objects), added by KHR_fence_sync
+
+ "If no errors are generated, EGL_TRUE is returned, and <sync> will no
+ longer be the handle of a valid sync object. Additionally, if <sync> is an
+ EGL Android fence sync object and the EGL_SYNC_ANDROID_FENCE_FD_ANDROID
+ attribute is not EGL_NO_ANDROID_FENCE_ANDROID then that file descriptor is
+ closed."
+
+ Add the following after the last paragraph of Section 3.8.1 (Sync
+ Objects), added by KHR_fence_sync
+
+ The command
+
+ EGLint eglDupAndroidFenceFDANDROID(
+ EGLdisplay dpy,
+ EGLSyncKHR sync);
+
+ duplicates the file descriptor stored in the
+ EGL_SYNC_ANDROID_FENCE_FD_ANDROID attribute of an EGL Android fence sync
+ object and returns the new file descriptor.
+
+ Errors
+ ------
+
+ * If <sync> is not a valid sync object for <dpy>,
+ EGL_NO_ANDROID_FENCE_ANDROID is returned and an EGL_BAD_PARAMETER
+ error is generated.
+ * If the EGL_SYNC_ANDROID_FENCE_FD_ANDROID attribute of <sync> is
+ EGL_NO_ANDROID_FENCE_ANDROID, EGL_NO_ANDROID_FENCE_ANDROID is returned
+ and an EGL_BAD_PARAMETER error is generated.
+ * If <dpy> does not match the display passed to eglCreateSyncKHR
+ when <sync> was created, the behaviour is undefined."
+
+Issues
+
+ 1. Should EGLSyncKHR objects that wrap Android fence objects use the
+ EGL_SYNC_FENCE_KHR type?
+
+ RESOLVED: A new sync object type will be added.
+
+ We don't want to require all EGL fence sync objects to wrap Android fence
+ objects, so we need some way to tell the EGL implementation at sync object
+ creation whether the sync object should support querying the Android fence
+ FD attribute. We could do this with either a new sync object type or with a
+ boolean attribute. It might be nice to pick up future signaling conditions
+ that might be added for fence sync objects, but there may be things that
+ get added that don't make sense in the context of Android fence objects.
+
+ 2. Who is responsible for dup'ing the Android fence file descriptors?
+
+ RESOLVED: Whenever a file descriptor is passed into or returned from an
+ EGL call in this extension, ownership of that file descriptor is
+ transfered. The recipient of the file descriptor must close it when it is
+ no longer needed, and the provider of the file descriptor must dup it
+ before providing it if they require continued use of the native Android
+ fence.
+
+ 3. Can the EGL_SYNC_ANDROID_FENCE_FD_ANDROID attribute be queried?
+
+ RESOLVED: No.
+
+ Returning the file descriptor owned by the EGL implementation would
+ violate the file descriptor ownership rule described in issue #2. Having
+ eglGetSyncAttribKHR return a different (dup'd) file descriptor each time
+ it's called seems wrong, so a new function was added to explicitly dup the
+ file descriptor.
+
+ That said, the attribute is useful both as a way to pass an existing file
+ descriptor to eglCreateSyncKHR and as a way to describe the subsequent
+ behavior of EGL Android fence sync objects, so it is left as an attribute
+ for which the value cannot be queried.
+
+Revision History
+
+#2 (Jamie Gennis, July 23, 2012)
+ - Changed the file descriptor ownership transferring behavior.
+ - Added the eglDupAndroidFenceFDANDROID function.
+ - Removed EGL_SYNC_ANDROID_FENCE_FD_ANDROID from the table of gettable
+ attributes.
+ - Added language specifying that a native Android fence is created at the
+ flush following the creation of an EGL Android fence sync object that is
+ not passed an existing native fence.
+
+#1 (Jamie Gennis, May 29, 2012)
+ - Initial draft.
diff --git a/opengl/specs/README b/opengl/specs/README
index 16b278f..af3f165 100644
--- a/opengl/specs/README
+++ b/opengl/specs/README
@@ -10,4 +10,7 @@ for use by Android extensions.
0x3141 (unused)
0x3142 EGL_ANDROID_recordable
0x3143 EGL_VERSION_HW_ANDROID (internal use)
-0x3144 - 0x314F (unused)
+0x3144 EGL_SYNC_ANDROID_FENCE_ANDROID
+0x3145 EGL_SYNC_FENCE_FD_ANDROID
+0x3146 EGL_SYNC_ANDROID_FENCE_SIGNALED_ANDROID
+0x3147 - 0x314F (unused)
diff --git a/opengl/tests/Android.mk b/opengl/tests/Android.mk
index 071c679..3ae3b4e 100644
--- a/opengl/tests/Android.mk
+++ b/opengl/tests/Android.mk
@@ -20,7 +20,7 @@ dirs := \
textures \
tritex \
-ifneq ($(TARGET_BUILD_PDK), true)
+ifneq (,$(TARGET_BUILD_JAVA_SUPPORT_LEVEL))
dirs += \
gl2_cameraeye \
gl2_java \
@@ -29,11 +29,16 @@ dirs += \
gl_jni \
gl_perfapp \
lighting1709 \
- testFramerate \
testLatency \
testPauseResume \
testViewport \
-endif
+endif # JAVA_SUPPORT
+
+ifeq (platform,$(TARGET_BUILD_JAVA_SUPPORT_LEVEL))
+dirs += \
+ testFramerate
+
+endif # JAVA_SUPPORT platform
include $(call all-named-subdir-makefiles, $(dirs))
diff --git a/opengl/tests/hwc/hwcColorEquiv.cpp b/opengl/tests/hwc/hwcColorEquiv.cpp
index bb305dc..160906d 100644
--- a/opengl/tests/hwc/hwcColorEquiv.cpp
+++ b/opengl/tests/hwc/hwcColorEquiv.cpp
@@ -124,7 +124,7 @@ const float defaultEndDelay = 2.0; // Default delay after rendering graphics
// Globals
static const int texUsage = GraphicBuffer::USAGE_HW_TEXTURE |
GraphicBuffer::USAGE_SW_WRITE_RARELY;
-static hwc_composer_device_t *hwcDevice;
+static hwc_composer_device_1_t *hwcDevice;
static EGLDisplay dpy;
static EGLSurface surface;
static EGLint width, height;
@@ -344,16 +344,16 @@ main(int argc, char *argv[])
hwcTestFillColorHBlend(equivFrame.get(), refFormat->format,
startRefColor, endRefColor);
- hwc_layer_list_t *list;
- size_t size = sizeof(hwc_layer_list) + numFrames * sizeof(hwc_layer_t);
- if ((list = (hwc_layer_list_t *) calloc(1, size)) == NULL) {
+ hwc_display_contents_1_t *list;
+ size_t size = sizeof(hwc_display_contents_1_t) + numFrames * sizeof(hwc_layer_1_t);
+ if ((list = (hwc_display_contents_1_t *) calloc(1, size)) == NULL) {
testPrintE("Allocate list failed");
exit(11);
}
list->flags = HWC_GEOMETRY_CHANGED;
list->numHwLayers = numFrames;
- hwc_layer_t *layer = &list->hwLayers[0];
+ hwc_layer_1_t *layer = &list->hwLayers[0];
layer->handle = refFrame->handle;
layer->blending = HWC_BLENDING_NONE;
layer->sourceCrop.left = 0;
@@ -383,7 +383,7 @@ main(int argc, char *argv[])
// Perform prepare operation
if (verbose) { testPrintI("Prepare:"); hwcTestDisplayList(list); }
- hwcDevice->prepare(hwcDevice, list);
+ hwcDevice->prepare(hwcDevice, 1, &list);
if (verbose) {
testPrintI("Post Prepare:");
hwcTestDisplayListPrepareModifiable(list);
@@ -393,7 +393,9 @@ main(int argc, char *argv[])
list->flags &= ~HWC_GEOMETRY_CHANGED;
if (verbose) {hwcTestDisplayListHandles(list); }
- hwcDevice->set(hwcDevice, dpy, surface, list);
+ list->dpy = dpy;
+ list->sur = surface;
+ hwcDevice->set(hwcDevice, 1, &list);
testDelay(endDelay);
diff --git a/opengl/tests/hwc/hwcCommit.cpp b/opengl/tests/hwc/hwcCommit.cpp
index efa646c..3681fbb 100644
--- a/opengl/tests/hwc/hwcCommit.cpp
+++ b/opengl/tests/hwc/hwcCommit.cpp
@@ -230,7 +230,7 @@ private:
// Globals
static const int texUsage = GraphicBuffer::USAGE_HW_TEXTURE |
GraphicBuffer::USAGE_SW_WRITE_RARELY;
-static hwc_composer_device_t *hwcDevice;
+static hwc_composer_device_1_t *hwcDevice;
static EGLDisplay dpy;
static EGLSurface surface;
static EGLint width, height;
@@ -1397,7 +1397,7 @@ void Rational::double2Rational(double f, Range nRange, Range dRange,
// Given a list of rectangles, determine how many HWC will commit to render
uint32_t numOverlays(list<Rectangle>& rectList)
{
- hwc_layer_list_t *hwcList;
+ hwc_display_contents_1_t *hwcList;
list<sp<GraphicBuffer> > buffers;
hwcList = hwcTestCreateLayerList(rectList.size());
@@ -1406,7 +1406,7 @@ uint32_t numOverlays(list<Rectangle>& rectList)
exit(30);
}
- hwc_layer_t *layer = &hwcList->hwLayers[0];
+ hwc_layer_1_t *layer = &hwcList->hwLayers[0];
for (std::list<Rectangle>::iterator it = rectList.begin();
it != rectList.end(); ++it, ++layer) {
// Allocate the texture for the source frame
@@ -1430,7 +1430,7 @@ uint32_t numOverlays(list<Rectangle>& rectList)
// Perform prepare operation
if (verbose) { testPrintI("Prepare:"); hwcTestDisplayList(hwcList); }
- hwcDevice->prepare(hwcDevice, hwcList);
+ hwcDevice->prepare(hwcDevice, 1, &hwcList);
if (verbose) {
testPrintI("Post Prepare:");
hwcTestDisplayListPrepareModifiable(hwcList);
diff --git a/opengl/tests/hwc/hwcRects.cpp b/opengl/tests/hwc/hwcRects.cpp
index 906c169..ec0403f 100644
--- a/opengl/tests/hwc/hwcRects.cpp
+++ b/opengl/tests/hwc/hwcRects.cpp
@@ -165,7 +165,7 @@ public:
list<Rectangle> rectangle;
static const int texUsage = GraphicBuffer::USAGE_HW_TEXTURE |
GraphicBuffer::USAGE_SW_WRITE_RARELY;
-static hwc_composer_device_t *hwcDevice;
+static hwc_composer_device_1_t *hwcDevice;
static EGLDisplay dpy;
static EGLSurface surface;
static EGLint width, height;
@@ -307,14 +307,14 @@ main(int argc, char *argv[])
}
// Create list of frames
- hwc_layer_list_t *list;
+ hwc_display_contents_1_t *list;
list = hwcTestCreateLayerList(rectangle.size());
if (list == NULL) {
testPrintE("hwcTestCreateLayerList failed");
exit(5);
}
- hwc_layer_t *layer = &list->hwLayers[0];
+ hwc_layer_1_t *layer = &list->hwLayers[0];
for (std::list<Rectangle>::iterator it = rectangle.begin();
it != rectangle.end(); ++it, ++layer) {
layer->handle = it->texture->handle;
@@ -329,7 +329,7 @@ main(int argc, char *argv[])
// Perform prepare operation
if (verbose) { testPrintI("Prepare:"); hwcTestDisplayList(list); }
- hwcDevice->prepare(hwcDevice, list);
+ hwcDevice->prepare(hwcDevice, 1, &list);
if (verbose) {
testPrintI("Post Prepare:");
hwcTestDisplayListPrepareModifiable(list);
@@ -341,7 +341,9 @@ main(int argc, char *argv[])
// Perform the set operation(s)
if (verbose) {testPrintI("Set:"); }
if (verbose) { hwcTestDisplayListHandles(list); }
- hwcDevice->set(hwcDevice, dpy, surface, list);
+ list->dpy = dpy;
+ list->sur = surface;
+ hwcDevice->set(hwcDevice, 1, &list);
testDelay(endDelay);
diff --git a/opengl/tests/hwc/hwcStress.cpp b/opengl/tests/hwc/hwcStress.cpp
index b02a424..3e8ea8d 100644
--- a/opengl/tests/hwc/hwcStress.cpp
+++ b/opengl/tests/hwc/hwcStress.cpp
@@ -192,7 +192,7 @@ const vector<unsigned int> vecTransformFlags(transformFlags,
// File scope globals
static const int texUsage = GraphicBuffer::USAGE_HW_TEXTURE |
GraphicBuffer::USAGE_SW_WRITE_RARELY;
-static hwc_composer_device_t *hwcDevice;
+static hwc_composer_device_1_t *hwcDevice;
static EGLDisplay dpy;
static EGLSurface surface;
static EGLint width, height;
@@ -409,7 +409,7 @@ main(int argc, char *argv[])
// generated for this pass.
srand48(pass);
- hwc_layer_list_t *list;
+ hwc_display_contents_1_t *list;
list = hwcTestCreateLayerList(testRandMod(frames.size()) + 1);
if (list == NULL) {
testPrintE("hwcTestCreateLayerList failed");
@@ -428,7 +428,7 @@ main(int argc, char *argv[])
for (unsigned int n1 = 0; n1 < list->numHwLayers; n1++) {
unsigned int idx = testRandMod(selectedFrames[n1].size());
sp<GraphicBuffer> gBuf = selectedFrames[n1][idx];
- hwc_layer_t *layer = &list->hwLayers[n1];
+ hwc_layer_1_t *layer = &list->hwLayers[n1];
layer->handle = gBuf->handle;
layer->blending = blendingOps[testRandMod(NUMA(blendingOps))];
@@ -478,7 +478,7 @@ main(int argc, char *argv[])
// Perform prepare operation
if (verbose) { testPrintI("Prepare:"); hwcTestDisplayList(list); }
- hwcDevice->prepare(hwcDevice, list);
+ hwcDevice->prepare(hwcDevice, 1, &list);
if (verbose) {
testPrintI("Post Prepare:");
hwcTestDisplayListPrepareModifiable(list);
@@ -491,13 +491,15 @@ main(int argc, char *argv[])
if (verbose) {testPrintI("Set:"); }
for (unsigned int n1 = 0; n1 < numSet; n1++) {
if (verbose) { hwcTestDisplayListHandles(list); }
- hwcDevice->set(hwcDevice, dpy, surface, list);
+ list->dpy = dpy;
+ list->sur = surface;
+ hwcDevice->set(hwcDevice, 1, &list);
// Prandomly select a new set of handles
for (unsigned int n1 = 0; n1 < list->numHwLayers; n1++) {
unsigned int idx = testRandMod(selectedFrames[n1].size());
sp<GraphicBuffer> gBuf = selectedFrames[n1][idx];
- hwc_layer_t *layer = &list->hwLayers[n1];
+ hwc_layer_1_t *layer = &list->hwLayers[n1];
layer->handle = (native_handle_t *) gBuf->handle;
}
diff --git a/opengl/tests/hwc/hwcTestLib.cpp b/opengl/tests/hwc/hwcTestLib.cpp
index 28e0c3f..d567e6e 100644
--- a/opengl/tests/hwc/hwcTestLib.cpp
+++ b/opengl/tests/hwc/hwcTestLib.cpp
@@ -134,7 +134,7 @@ void hwcTestInitDisplay(bool verbose, EGLDisplay *dpy, EGLSurface *surface,
}
// Open Hardware Composer Device
-void hwcTestOpenHwc(hwc_composer_device_t **hwcDevicePtr)
+void hwcTestOpenHwc(hwc_composer_device_1_t **hwcDevicePtr)
{
int rv;
hw_module_t const *hwcModule;
@@ -145,7 +145,7 @@ void hwcTestOpenHwc(hwc_composer_device_t **hwcDevicePtr)
perror(NULL);
exit(77);
}
- if ((rv = hwc_open(hwcModule, hwcDevicePtr)) != 0) {
+ if ((rv = hwc_open_1(hwcModule, hwcDevicePtr)) != 0) {
testPrintE("hwc_open failed, rv: %i", rv);
errno = -rv;
perror(NULL);
@@ -399,12 +399,12 @@ const char *hwcTestGraphicFormat2str(uint32_t format)
* Dynamically creates layer list with numLayers worth
* of hwLayers entries.
*/
-hwc_layer_list_t *hwcTestCreateLayerList(size_t numLayers)
+hwc_display_contents_1_t *hwcTestCreateLayerList(size_t numLayers)
{
- hwc_layer_list_t *list;
+ hwc_display_contents_1_t *list;
- size_t size = sizeof(hwc_layer_list) + numLayers * sizeof(hwc_layer_t);
- if ((list = (hwc_layer_list_t *) calloc(1, size)) == NULL) {
+ size_t size = sizeof(hwc_display_contents_1_t) + numLayers * sizeof(hwc_layer_1_t);
+ if ((list = (hwc_display_contents_1_t *) calloc(1, size)) == NULL) {
return NULL;
}
list->flags = HWC_GEOMETRY_CHANGED;
@@ -417,13 +417,13 @@ hwc_layer_list_t *hwcTestCreateLayerList(size_t numLayers)
* hwcTestFreeLayerList
* Frees memory previous allocated via hwcTestCreateLayerList().
*/
-void hwcTestFreeLayerList(hwc_layer_list_t *list)
+void hwcTestFreeLayerList(hwc_display_contents_1_t *list)
{
free(list);
}
// Display the settings of the layer list pointed to by list
-void hwcTestDisplayList(hwc_layer_list_t *list)
+void hwcTestDisplayList(hwc_display_contents_1_t *list)
{
testPrintI(" flags: %#x%s", list->flags,
(list->flags & HWC_GEOMETRY_CHANGED) ? " GEOMETRY_CHANGED" : "");
@@ -494,7 +494,7 @@ void hwcTestDisplayList(hwc_layer_list_t *list)
* Displays the portions of a list that are meant to be modified by
* a prepare call.
*/
-void hwcTestDisplayListPrepareModifiable(hwc_layer_list_t *list)
+void hwcTestDisplayListPrepareModifiable(hwc_display_contents_1_t *list)
{
uint32_t numOverlays = 0;
for (unsigned int layer = 0; layer < list->numHwLayers; layer++) {
@@ -522,7 +522,7 @@ void hwcTestDisplayListPrepareModifiable(hwc_layer_list_t *list)
*
* Displays the handles of all the graphic buffers in the list.
*/
-void hwcTestDisplayListHandles(hwc_layer_list_t *list)
+void hwcTestDisplayListHandles(hwc_display_contents_1_t *list)
{
const unsigned int maxLayersPerLine = 6;
diff --git a/opengl/tests/hwc/hwcTestLib.h b/opengl/tests/hwc/hwcTestLib.h
index b0c3012..d7d5837 100644
--- a/opengl/tests/hwc/hwcTestLib.h
+++ b/opengl/tests/hwc/hwcTestLib.h
@@ -107,17 +107,17 @@ class HwcTestDim {
// Function Prototypes
void hwcTestInitDisplay(bool verbose, EGLDisplay *dpy, EGLSurface *surface,
EGLint *width, EGLint *height);
-void hwcTestOpenHwc(hwc_composer_device_t **hwcDevicePtr);
+void hwcTestOpenHwc(hwc_composer_device_1_t **hwcDevicePtr);
const struct hwcTestGraphicFormat *hwcTestGraphicFormatLookup(const char *desc);
const struct hwcTestGraphicFormat *hwcTestGraphicFormatLookup(uint32_t id);
const char *hwcTestGraphicFormat2str(uint32_t format);
std::string hwcTestRect2str(const struct hwc_rect& rect);
-hwc_layer_list_t *hwcTestCreateLayerList(size_t numLayers);
-void hwcTestFreeLayerList(hwc_layer_list_t *list);
-void hwcTestDisplayList(hwc_layer_list_t *list);
-void hwcTestDisplayListPrepareModifiable(hwc_layer_list_t *list);
-void hwcTestDisplayListHandles(hwc_layer_list_t *list);
+hwc_display_contents_1_t *hwcTestCreateLayerList(size_t numLayers);
+void hwcTestFreeLayerList(hwc_display_contents_1_t *list);
+void hwcTestDisplayList(hwc_display_contents_1_t *list);
+void hwcTestDisplayListPrepareModifiable(hwc_display_contents_1_t *list);
+void hwcTestDisplayListHandles(hwc_display_contents_1_t *list);
uint32_t hwcTestColor2Pixel(uint32_t format, ColorFract color, float alpha);
void hwcTestColorConvert(uint32_t fromFormat, uint32_t toFormat,
diff --git a/opengl/tools/glgen/gen b/opengl/tools/glgen/gen
index 31f4190..3359a22 100755
--- a/opengl/tools/glgen/gen
+++ b/opengl/tools/glgen/gen
@@ -12,6 +12,7 @@ mkdir -p out/javax/microedition/khronos/opengles
mkdir -p out/com/google/android/gles_jni
mkdir -p out/android/app
mkdir -p out/android/graphics
+mkdir -p out/android/view
mkdir -p out/android/opengl
mkdir -p out/android/content
mkdir -p out/android/content/pm
@@ -24,15 +25,33 @@ echo "public interface Canvas {}" >> out/android/graphics/Canvas.java
echo "package android.app; import android.content.pm.IPackageManager; public class AppGlobals { public static IPackageManager getPackageManager() { return null;} }" > out/android/app/AppGlobals.java
# echo "package android.content; import android.content.pm.PackageManager; public interface Context { public PackageManager getPackageManager(); }" > out/android/content/Context.java
echo "package android.content.pm; public class ApplicationInfo {public int targetSdkVersion;}" > out/android/content/pm/ApplicationInfo.java
-echo "package android.content.pm; public interface IPackageManager {ApplicationInfo getApplicationInfo(java.lang.String packageName, int flags) throws android.os.RemoteException;}" > out/android/content/pm/IPackageManager.java
+echo "package android.content.pm; public interface IPackageManager {ApplicationInfo getApplicationInfo(java.lang.String packageName, int flags, java.lang.String userId) throws android.os.RemoteException;}" > out/android/content/pm/IPackageManager.java
echo "package android.os; public class Build {public static class VERSION_CODES { public static final int CUPCAKE = 3;}; }" > out/android/os/Build.java
+echo "package android.os; public class UserId {public static String myUserId() { return \"\"; } }" > out/android/os/UserId.java
echo "package android.os; public class RemoteException extends Exception {}" > out/android/os/RemoteException.java
echo "package android.util; public class Log {public static void w(String a, String b) {} public static void e(String a, String b) {}}" > out/android/util/Log.java
+echo "package android.opengl; public abstract class EGLObjectHandle { public int getHandle() { return 0; } }" > out/android/opengl/EGLObjectHandle.java
+echo "package android.opengl; public class EGLSurface extends EGLObjectHandle { }" > out/android/opengl/EGLSurface.java
+echo "package android.opengl; public class EGLContext extends EGLObjectHandle { }" > out/android/opengl/EGLContext.java
+echo "package android.opengl; public class EGLDisplay extends EGLObjectHandle { }" > out/android/opengl/EGLDisplay.java
+echo "package android.opengl; public class EGLConfig extends EGLObjectHandle { }" > out/android/opengl/EGLConfig.java
+
+
+echo "package android.graphics;" > out/android/graphics/SurfaceTexture.java
+echo "public interface SurfaceTexture {}" >> out/android/graphics/SurfaceTexture.java
+echo "package android.view;" > out/android/view/SurfaceView.java
+echo "public interface SurfaceView { SurfaceHolder getHolder(); }" >> out/android/view/SurfaceView.java
+echo "package android.view;" > out/android/view/Surface.java
+echo "public interface Surface {}" >> out/android/view/Surface.java
+echo "package android.view;" > out/android/view/SurfaceHolder.java
+echo "public interface SurfaceHolder { Surface getSurface(); }" >> out/android/view/SurfaceHolder.java
+
+
GLFILE=out/javax/microedition/khronos/opengles/GL.java
cp stubs/jsr239/GLHeader.java-if $GLFILE
-GLGEN_FILES="CFunc.java CType.java CodeEmitter.java GenerateGL.java GenerateGLES.java GLESCodeEmitter.java JFunc.java JniCodeEmitter.java JType.java Jsr239CodeEmitter.java ParameterChecker.java"
+GLGEN_FILES="CFunc.java CType.java CodeEmitter.java EGLCodeEmitter.java GenerateEGL.java GenerateGL.java GenerateGLES.java GLESCodeEmitter.java JFunc.java JniCodeEmitter.java JType.java Jsr239CodeEmitter.java ParameterChecker.java"
pushd src > /dev/null
javac ${GLGEN_FILES}
@@ -59,11 +78,19 @@ if [ $JAVA_RESULT -ne 0 ]; then
exit $JAVA_RESULT
fi
+echo "Generating static EGL 1.4 bindings"
+java -classpath src GenerateEGL
+JAVA_RESULT=$?
+if [ $JAVA_RESULT -ne 0 ]; then
+ echo "Could not run GenerateEGL."
+ exit $JAVA_RESULT
+fi
+
rm src/*.class
pushd out > /dev/null
mkdir classes
-javac -d classes com/google/android/gles_jni/GLImpl.java javax/microedition/khronos/opengles/GL10.java javax/microedition/khronos/opengles/GL10Ext.java javax/microedition/khronos/opengles/GL11.java javax/microedition/khronos/opengles/GL11Ext.java javax/microedition/khronos/opengles/GL11ExtensionPack.java android/opengl/GLES10.java android/opengl/GLES10Ext.java android/opengl/GLES11.java android/opengl/GLES11Ext.java android/opengl/GLES20.java
+javac -d classes android/opengl/EGL14.java com/google/android/gles_jni/GLImpl.java javax/microedition/khronos/opengles/GL10.java javax/microedition/khronos/opengles/GL10Ext.java javax/microedition/khronos/opengles/GL11.java javax/microedition/khronos/opengles/GL11Ext.java javax/microedition/khronos/opengles/GL11ExtensionPack.java android/opengl/GLES10.java android/opengl/GLES10Ext.java android/opengl/GLES11.java android/opengl/GLES11Ext.java android/opengl/GLES20.java
popd > /dev/null
JAVA_RESULT=$?
if [ $JAVA_RESULT -ne 0 ]; then
@@ -90,6 +117,7 @@ compareGenerated() {
if cmp -s $1/$3 $2/$3 ; then
echo "# " $3 unchanged
else
+ echo "# " $3 changed
if [ $SAID_PLEASE == "0" ] ; then
echo Please evaluate the following commands:
echo
@@ -101,18 +129,18 @@ compareGenerated() {
fi
}
-compareGenerated ../../../core/jni generated/C com_google_android_gles_jni_GLImpl.cpp
-compareGenerated ../../java/com/google/android/gles_jni generated/com/google/android/gles_jni GLImpl.java
+compareGenerated ../../../../base/core/jni generated/C com_google_android_gles_jni_GLImpl.cpp
+compareGenerated ../../../../base/opengl/java/com/google/android/gles_jni generated/com/google/android/gles_jni GLImpl.java
for x in GL.java GL10.java GL10Ext.java GL11.java GL11Ext.java GL11ExtensionPack.java
do
- compareGenerated ../../java/javax/microedition/khronos/opengles generated/javax/microedition/khronos/opengles $x
+ compareGenerated ../../../../base/opengl/java/javax/microedition/khronos/opengles generated/javax/microedition/khronos/opengles $x
done
-for x in GLES10 GLES10Ext GLES11 GLES11Ext GLES20
+for x in EGL14 GLES10 GLES10Ext GLES11 GLES11Ext GLES20
do
- compareGenerated ../../java/android/opengl generated/android/opengl ${x}.java
- compareGenerated ../../../core/jni generated/C android_opengl_${x}.cpp
+ compareGenerated ../../../../base/opengl/java/android/opengl generated/android/opengl ${x}.java
+ compareGenerated ../../../../base/core/jni generated/C android_opengl_${x}.cpp
done
if [ $KEEP_GENERATED == "0" ] ; then
diff --git a/opengl/tools/glgen/specs/egl/EGL14.spec b/opengl/tools/glgen/specs/egl/EGL14.spec
new file mode 100644
index 0000000..828e114
--- /dev/null
+++ b/opengl/tools/glgen/specs/egl/EGL14.spec
@@ -0,0 +1,33 @@
+EGLint eglGetError ( void )
+EGLDisplay eglGetDisplay ( EGLNativeDisplayType display_id )
+EGLBoolean eglInitialize ( EGLDisplay dpy, EGLint *major, EGLint *minor )
+EGLBoolean eglTerminate ( EGLDisplay dpy )
+const char * eglQueryString ( EGLDisplay dpy, EGLint name )
+EGLBoolean eglGetConfigs ( EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config )
+EGLBoolean eglChooseConfig ( EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config )
+EGLBoolean eglGetConfigAttrib ( EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value )
+EGLSurface eglCreateWindowSurface ( EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list )
+EGLSurface eglCreatePbufferSurface ( EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list )
+EGLSurface eglCreatePixmapSurface ( EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list )
+EGLBoolean eglDestroySurface ( EGLDisplay dpy, EGLSurface surface )
+EGLBoolean eglQuerySurface ( EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value )
+EGLBoolean eglBindAPI ( EGLenum api )
+EGLenum eglQueryAPI ( void )
+EGLBoolean eglWaitClient ( void )
+EGLBoolean eglReleaseThread ( void )
+EGLSurface eglCreatePbufferFromClientBuffer ( EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list )
+EGLBoolean eglSurfaceAttrib ( EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value )
+EGLBoolean eglBindTexImage ( EGLDisplay dpy, EGLSurface surface, EGLint buffer )
+EGLBoolean eglReleaseTexImage ( EGLDisplay dpy, EGLSurface surface, EGLint buffer )
+EGLBoolean eglSwapInterval ( EGLDisplay dpy, EGLint interval )
+EGLContext eglCreateContext ( EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list )
+EGLBoolean eglDestroyContext ( EGLDisplay dpy, EGLContext ctx )
+EGLBoolean eglMakeCurrent ( EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx )
+EGLContext eglGetCurrentContext ( void )
+EGLSurface eglGetCurrentSurface ( EGLint readdraw )
+EGLDisplay eglGetCurrentDisplay ( void )
+EGLBoolean eglQueryContext ( EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value )
+EGLBoolean eglWaitGL ( void )
+EGLBoolean eglWaitNative ( EGLint engine )
+EGLBoolean eglSwapBuffers ( EGLDisplay dpy, EGLSurface surface )
+EGLBoolean eglCopyBuffers ( EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target )
diff --git a/opengl/tools/glgen/specs/egl/checks.spec b/opengl/tools/glgen/specs/egl/checks.spec
new file mode 100644
index 0000000..34fb1ee
--- /dev/null
+++ b/opengl/tools/glgen/specs/egl/checks.spec
@@ -0,0 +1,13 @@
+eglInitialize check major 1 check minor 1
+eglGetConfigs check configs config_size
+eglChooseConfig check configs config_size check num_config 1 sentinel attrib_list EGL_NONE
+eglGetConfigAttrib check value 1
+//STUB function: //eglCreateWindowSurface sentinel attrib_list EGL_NONE
+eglCreatePbufferSurface sentinel attrib_list EGL_NONE
+//unsupported: eglCreatePixmapSurface sentinel attrib_list EGL_NONE
+eglCreatePixmapSurface unsupported
+eglCopyBuffers unsupported
+eglQuerySurface check value 1
+eglCreatePbufferFromClientBuffer sentinel attrib_list EGL_NONE
+eglCreateContext sentinel attrib_list EGL_NONE
+eglQueryContext check value 1
diff --git a/opengl/tools/glgen/src/CFunc.java b/opengl/tools/glgen/src/CFunc.java
index 4847694..a192c00 100644
--- a/opengl/tools/glgen/src/CFunc.java
+++ b/opengl/tools/glgen/src/CFunc.java
@@ -28,6 +28,7 @@ public class CFunc {
boolean hasPointerArg = false;
boolean hasTypedPointerArg = false;
+ boolean hasEGLHandleArg = false;
public CFunc(String original) {
this.original = original;
@@ -63,6 +64,9 @@ public class CFunc {
if (argType.isTypedPointer()) {
hasTypedPointerArg = true;
}
+ if (argType.isEGLHandle()) {
+ hasEGLHandleArg = true;
+ }
}
public int getNumArgs() {
@@ -95,6 +99,10 @@ public class CFunc {
return hasTypedPointerArg;
}
+ public boolean hasEGLHandleArg() {
+ return hasEGLHandleArg;
+ }
+
@Override
public String toString() {
String s = "Function " + fname + " returns " + ftype + ": ";
diff --git a/opengl/tools/glgen/src/CType.java b/opengl/tools/glgen/src/CType.java
index e0f0ca6..92950ea 100644
--- a/opengl/tools/glgen/src/CType.java
+++ b/opengl/tools/glgen/src/CType.java
@@ -53,6 +53,16 @@ public class CType {
return isPointer;
}
+ public boolean isEGLHandle() {
+ if(baseType.equals("EGLContext")
+ || baseType.equals("EGLConfig")
+ || baseType.equals("EGLSurface")
+ || baseType.equals("EGLDisplay")) {
+ return true;
+ }
+ return false;
+ }
+
boolean isVoid() {
String baseType = getBaseType();
return baseType.equals("GLvoid") ||
diff --git a/opengl/tools/glgen/src/EGLCodeEmitter.java b/opengl/tools/glgen/src/EGLCodeEmitter.java
new file mode 100644
index 0000000..300f776
--- /dev/null
+++ b/opengl/tools/glgen/src/EGLCodeEmitter.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2012 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.
+ */
+
+import java.io.PrintStream;
+
+/**
+ * Emits a Java interface and Java & C implementation for a C function.
+ *
+ * <p> The Java interface will have Buffer and array variants for functions that
+ * have a typed pointer argument. The array variant will convert a single "<type> *data"
+ * argument to a pair of arguments "<type>[] data, int offset".
+ */
+public class EGLCodeEmitter extends JniCodeEmitter {
+
+ PrintStream mJavaImplStream;
+ PrintStream mCStream;
+
+ PrintStream mJavaInterfaceStream;
+
+ /**
+ */
+ public EGLCodeEmitter(String classPathName,
+ ParameterChecker checker,
+ PrintStream javaImplStream,
+ PrintStream cStream) {
+ mClassPathName = classPathName;
+ mChecker = checker;
+
+ mJavaImplStream = javaImplStream;
+ mCStream = cStream;
+ mUseContextPointer = false;
+ mUseStaticMethods = true;
+ mUseSimpleMethodNames = true;
+ mUseHideCommentForAPI = false;
+ }
+
+ public void emitCode(CFunc cfunc, String original) {
+ emitCode(cfunc, original, null, mJavaImplStream,
+ mCStream);
+ }
+
+ public void emitNativeRegistration(String nativeRegistrationName) {
+ emitNativeRegistration(nativeRegistrationName, mCStream);
+ }
+}
diff --git a/opengl/tools/glgen/src/GenerateEGL.java b/opengl/tools/glgen/src/GenerateEGL.java
new file mode 100644
index 0000000..aaa748c
--- /dev/null
+++ b/opengl/tools/glgen/src/GenerateEGL.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2012 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.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.PrintStream;
+
+public class GenerateEGL {
+
+ private static void copy(String filename, PrintStream out) throws IOException {
+ BufferedReader br = new BufferedReader(new FileReader(filename));
+ String s;
+ while ((s = br.readLine()) != null) {
+ out.println(s);
+ }
+ }
+
+ private static void emit(EGLCodeEmitter emitter,
+ BufferedReader specReader,
+ PrintStream glStream,
+ PrintStream cStream) throws Exception {
+ String s = null;
+ while ((s = specReader.readLine()) != null) {
+ if (s.trim().startsWith("//")) {
+ continue;
+ }
+
+ CFunc cfunc = CFunc.parseCFunc(s);
+
+ String fname = cfunc.getName();
+ String stubRoot = "stubs/egl/" + fname;
+ String javaPath = stubRoot + ".java";
+ File f = new File(javaPath);
+ if (f.exists()) {
+ System.out.println("Special-casing function " + fname);
+ copy(javaPath, glStream);
+ copy(stubRoot + ".cpp", cStream);
+
+ // Register native function names
+ // This should be improved to require fewer discrete files
+ String filename = stubRoot + ".nativeReg";
+ BufferedReader br =
+ new BufferedReader(new FileReader(filename));
+ String nfunc;
+ while ((nfunc = br.readLine()) != null) {
+ emitter.addNativeRegistration(nfunc);
+ }
+ } else {
+ emitter.emitCode(cfunc, s);
+ }
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ int aidx = 0;
+ while ((aidx < args.length) && (args[aidx].charAt(0) == '-')) {
+ switch (args[aidx].charAt(1)) {
+ default:
+ System.err.println("Unknown flag: " + args[aidx]);
+ System.exit(1);
+ }
+
+ aidx++;
+ }
+
+ BufferedReader checksReader =
+ new BufferedReader(new FileReader("specs/egl/checks.spec"));
+ ParameterChecker checker = new ParameterChecker(checksReader);
+
+
+ BufferedReader specReader =
+ new BufferedReader(new FileReader("specs/egl/EGL14.spec"));
+
+ String egljFilename = "android/opengl/EGL14.java";
+ String eglcFilename = "android_opengl_EGL14.cpp";
+ PrintStream egljStream =
+ new PrintStream(new FileOutputStream("out/" + egljFilename));
+ PrintStream eglcStream =
+ new PrintStream(new FileOutputStream("out/" + eglcFilename));
+ egljStream.println("/*");
+ eglcStream.println("/*");
+ copy("stubs/egl/EGL14Header.java-if", egljStream);
+ copy("stubs/egl/EGL14cHeader.cpp", eglcStream);
+ EGLCodeEmitter emitter = new EGLCodeEmitter(
+ "android/opengl/EGL14",
+ checker, egljStream, eglcStream);
+ emit(emitter, specReader, egljStream, eglcStream);
+ emitter.emitNativeRegistration("register_android_opengl_jni_EGL14");
+ egljStream.println("}");
+ egljStream.close();
+ eglcStream.close();
+ }
+}
diff --git a/opengl/tools/glgen/src/JType.java b/opengl/tools/glgen/src/JType.java
index deb2f01..3f7cb73 100644
--- a/opengl/tools/glgen/src/JType.java
+++ b/opengl/tools/glgen/src/JType.java
@@ -48,6 +48,22 @@ public class JType {
typeMapping.put(new CType("char", true, true), new JType("String", false, false));
typeMapping.put(new CType("int"), new JType("int"));
+ // EGL primitive types
+ typeMapping.put(new CType("EGLint"), new JType("int"));
+ typeMapping.put(new CType("EGLBoolean"), new JType("boolean"));
+ typeMapping.put(new CType("EGLenum"), new JType("int"));
+ typeMapping.put(new CType("EGLNativePixmapType"), new JType("int"));
+ typeMapping.put(new CType("EGLNativeWindowType"), new JType("int"));
+ typeMapping.put(new CType("EGLNativeDisplayType"), new JType("int"));
+ typeMapping.put(new CType("EGLClientBuffer"), new JType("int"));
+
+ // EGL nonprimitive types
+ typeMapping.put(new CType("EGLConfig"), new JType("EGLConfig", true, false));
+ typeMapping.put(new CType("EGLContext"), new JType("EGLContext", true, false));
+ typeMapping.put(new CType("EGLDisplay"), new JType("EGLDisplay", true, false));
+ typeMapping.put(new CType("EGLSurface"), new JType("EGLSurface", true, false));
+
+
// Untyped pointers map to untyped Buffers
typeMapping.put(new CType("GLvoid", true, true),
new JType("java.nio.Buffer", true, false));
@@ -88,7 +104,7 @@ public class JType {
arrayTypeMapping.put(new CType("char", false, true),
new JType("byte", false, true));
arrayTypeMapping.put(new CType("GLboolean", false, true),
- new JType("boolean", false, true));
+ new JType("boolean", false, true));
arrayTypeMapping.put(new CType("GLenum", false, true), new JType("int", false, true));
arrayTypeMapping.put(new CType("GLfixed", true, true), new JType("int", false, true));
arrayTypeMapping.put(new CType("GLfixed", false, true), new JType("int", false, true));
@@ -103,6 +119,13 @@ public class JType {
arrayTypeMapping.put(new CType("GLuint", true, true), new JType("int", false, true));
arrayTypeMapping.put(new CType("GLintptr"), new JType("int", false, true));
arrayTypeMapping.put(new CType("GLsizeiptr"), new JType("int", false, true));
+
+ //EGL typed pointers map to arrays + offsets
+ arrayTypeMapping.put(new CType("EGLint", false, true), new JType("int", false, true));
+ arrayTypeMapping.put(new CType("EGLint", true, true), new JType("int", false, true));
+ arrayTypeMapping.put(new CType("EGLConfig", false, true), new JType("EGLConfig", true, true));
+ arrayTypeMapping.put(new CType("EGLConfig", true, true), new JType("EGLConfig", true, true));
+
}
public JType() {
@@ -158,6 +181,11 @@ public class JType {
(baseType.indexOf("Buffer") != -1);
}
+ public boolean isEGLHandle() {
+ return !isPrimitive() &&
+ (baseType.startsWith("EGL"));
+ }
+
public static JType convert(CType ctype, boolean useArray) {
JType javaType = null;
if (useArray) {
diff --git a/opengl/tools/glgen/src/JniCodeEmitter.java b/opengl/tools/glgen/src/JniCodeEmitter.java
index 9fa2b74..774f40c 100644
--- a/opengl/tools/glgen/src/JniCodeEmitter.java
+++ b/opengl/tools/glgen/src/JniCodeEmitter.java
@@ -25,6 +25,8 @@ public class JniCodeEmitter {
static final boolean mUseCPlusPlus = true;
protected boolean mUseContextPointer = true;
protected boolean mUseStaticMethods = false;
+ protected boolean mUseSimpleMethodNames = false;
+ protected boolean mUseHideCommentForAPI = false;
protected String mClassPathName;
protected ParameterChecker mChecker;
protected List<String> nativeRegistrations = new ArrayList<String>();
@@ -34,7 +36,9 @@ public class JniCodeEmitter {
public static String getJniName(JType jType) {
String jniName = "";
- if (jType.isClass()) {
+ if (jType.isEGLHandle()) {
+ return (jType.isArray() ? "[" : "" ) + "Landroid/opengl/" + jType.getBaseType() + ";";
+ } else if (jType.isClass()) {
return "L" + jType.getBaseType() + ";";
} else if (jType.isArray()) {
jniName = "[";
@@ -63,7 +67,6 @@ public class JniCodeEmitter {
return jniName;
}
-
public void emitCode(CFunc cfunc, String original,
PrintStream javaInterfaceStream,
PrintStream javaImplStream,
@@ -96,6 +99,10 @@ public class JniCodeEmitter {
if (!duplicate) {
emitJniCode(jfunc, cStream);
}
+ // Don't create IOBuffer versions of the EGL functions
+ if (cfunc.hasEGLHandleArg()) {
+ return;
+ }
}
jfunc = JFunc.convert(cfunc, false);
@@ -121,8 +128,13 @@ public class JniCodeEmitter {
}
public void emitNativeDeclaration(JFunc jfunc, PrintStream out) {
- out.println(" // C function " + jfunc.getCFunc().getOriginal());
- out.println();
+ if (mUseHideCommentForAPI) {
+ out.println(" /* @hide C function " + jfunc.getCFunc().getOriginal() + " */");
+ out.println();
+ } else {
+ out.println(" // C function " + jfunc.getCFunc().getOriginal());
+ out.println();
+ }
emitFunction(jfunc, out, true, false);
}
@@ -197,15 +209,17 @@ public class JniCodeEmitter {
out.println(iii + "}");
out.println(iii + "if (" + remaining + " < _needed) {");
- if (emitExceptionCheck) {
- out.println(iii + indent + "_exception = 1;");
- }
- out.println(iii + indent + "jniThrowException(_env, " +
- "\"java/lang/IllegalArgumentException\", " +
- "\"" + (isBuffer ? "remaining()" : "length - " + offset) + " < needed\");");
+ out.println(iii + indent + "_exception = 1;");
+ out.println(iii + indent +
+ "_exceptionType = \"java/lang/IllegalArgumentException\";");
+ out.println(iii + indent +
+ "_exceptionMessage = \"" +
+ (isBuffer ? "remaining()" : "length - " + offset) +
+ " < needed\";");
out.println(iii + indent + "goto exit;");
- needsExit = true;
out.println(iii + "}");
+
+ needsExit = true;
}
boolean isNullAllowed(CFunc cfunc) {
@@ -213,28 +227,70 @@ public class JniCodeEmitter {
int index = 1;
if (checks != null) {
while (index < checks.length) {
- if (checks[index].equals("return")) {
- index += 2;
- } else if (checks[index].startsWith("check")) {
- index += 3;
- } else if (checks[index].equals("ifcheck")) {
- index += 5;
- } else if (checks[index].equals("unsupported")) {
- index += 1;
- } else if (checks[index].equals("requires")) {
- index += 2;
- } else if (checks[index].equals("nullAllowed")) {
+ if (checks[index].equals("nullAllowed")) {
return true;
} else {
- System.out.println("Error: unknown keyword \"" +
- checks[index] + "\"");
- System.exit(0);
+ index = skipOneCheck(checks, index);
}
}
}
return false;
}
+ boolean hasCheckTest(CFunc cfunc) {
+ String[] checks = mChecker.getChecks(cfunc.getName());
+ int index = 1;
+ if (checks != null) {
+ while (index < checks.length) {
+ if (checks[index].startsWith("check")) {
+ return true;
+ } else {
+ index = skipOneCheck(checks, index);
+ }
+ }
+ }
+ return false;
+ }
+
+ boolean hasIfTest(CFunc cfunc) {
+ String[] checks = mChecker.getChecks(cfunc.getName());
+ int index = 1;
+ if (checks != null) {
+ while (index < checks.length) {
+ if (checks[index].startsWith("ifcheck")) {
+ return true;
+ } else {
+ index = skipOneCheck(checks, index);
+ }
+ }
+ }
+ return false;
+ }
+
+ int skipOneCheck(String[] checks, int index) {
+ if (checks[index].equals("return")) {
+ index += 2;
+ } else if (checks[index].startsWith("check")) {
+ index += 3;
+ } else if (checks[index].startsWith("sentinel")) {
+ index += 3;
+ } else if (checks[index].equals("ifcheck")) {
+ index += 5;
+ } else if (checks[index].equals("unsupported")) {
+ index += 1;
+ } else if (checks[index].equals("requires")) {
+ index += 2;
+ } else if (checks[index].equals("nullAllowed")) {
+ index += 1;
+ } else {
+ System.out.println("Error: unknown keyword \"" +
+ checks[index] + "\"");
+ System.exit(0);
+ }
+
+ return index;
+ }
+
String getErrorReturnValue(CFunc cfunc) {
CType returnType = cfunc.getType();
boolean isVoid = returnType.isVoid();
@@ -242,6 +298,10 @@ public class JniCodeEmitter {
return null;
}
+ if (returnType.getBaseType().startsWith("EGL")) {
+ return "(" + returnType.getDeclaration() + ") 0";
+ }
+
String[] checks = mChecker.getChecks(cfunc.getName());
int index = 1;
@@ -249,20 +309,8 @@ public class JniCodeEmitter {
while (index < checks.length) {
if (checks[index].equals("return")) {
return checks[index + 1];
- } else if (checks[index].startsWith("check")) {
- index += 3;
- } else if (checks[index].equals("ifcheck")) {
- index += 5;
- } else if (checks[index].equals("unsupported")) {
- index += 1;
- } else if (checks[index].equals("requires")) {
- index += 2;
- } else if (checks[index].equals("nullAllowed")) {
- index += 1;
} else {
- System.out.println("Error: unknown keyword \"" +
- checks[index] + "\"");
- System.exit(0);
+ index = skipOneCheck(checks, index);
}
}
}
@@ -277,20 +325,8 @@ public class JniCodeEmitter {
while (index < checks.length) {
if (checks[index].equals("unsupported")) {
return true;
- } else if (checks[index].equals("requires")) {
- index += 2;
- } else if (checks[index].equals("return")) {
- index += 2;
- } else if (checks[index].startsWith("check")) {
- index += 3;
- } else if (checks[index].equals("ifcheck")) {
- index += 5;
- } else if (checks[index].equals("nullAllowed")) {
- index += 1;
} else {
- System.out.println("Error: unknown keyword \"" +
- checks[index] + "\"");
- System.exit(0);
+ index = skipOneCheck(checks, index);
}
}
}
@@ -302,22 +338,10 @@ public class JniCodeEmitter {
int index = 1;
if (checks != null) {
while (index < checks.length) {
- if (checks[index].equals("unsupported")) {
- index += 1;
- } else if (checks[index].equals("requires")) {
+ if (checks[index].equals("requires")) {
return checks[index+1];
- } else if (checks[index].equals("return")) {
- index += 2;
- } else if (checks[index].startsWith("check")) {
- index += 3;
- } else if (checks[index].equals("ifcheck")) {
- index += 5;
- } else if (checks[index].equals("nullAllowed")) {
- index += 1;
} else {
- System.out.println("Error: unknown keyword \"" +
- checks[index] + "\"");
- System.exit(0);
+ index = skipOneCheck(checks, index);
}
}
}
@@ -345,9 +369,7 @@ public class JniCodeEmitter {
continue;
}
out.println(iii + "if (" + remaining + " < " + checks[index + 2] + ") {");
- if (emitExceptionCheck) {
- out.println(iii + indent + "_exception = 1;");
- }
+ out.println(iii + indent + "_exception = 1;");
String exceptionClassName = "java/lang/IllegalArgumentException";
// If the "check" keyword was of the form
// "check_<class name>", use the class name in the
@@ -361,14 +383,19 @@ public class JniCodeEmitter {
throw new RuntimeException("unknown exception abbreviation: " + abbr);
}
}
- out.println(iii + indent + "jniThrowException(_env, " +
- "\"" + exceptionClassName + "\", " +
- "\"" + (isBuffer ? "remaining()" : "length - " + offset) + " < " + checks[index + 2] + "\");");
+ out.println(iii + indent +
+ "_exceptionType = \""+exceptionClassName+"\";");
+ out.println(iii + indent +
+ "_exceptionMessage = \"" +
+ (isBuffer ? "remaining()" : "length - " +
+ offset) + " < " + checks[index + 2] +
+ " < needed\";");
out.println(iii + indent + "goto exit;");
- needsExit = true;
out.println(iii + "}");
+ needsExit = true;
+
index += 3;
} else if (checks[index].equals("ifcheck")) {
String[] matches = checks[index + 4].split(",");
@@ -388,21 +415,8 @@ public class JniCodeEmitter {
lastWasIfcheck = true;
index += 5;
- } else if (checks[index].equals("return")) {
- // ignore
- index += 2;
- } else if (checks[index].equals("unsupported")) {
- // ignore
- index += 1;
- } else if (checks[index].equals("requires")) {
- // ignore
- index += 2;
- } else if (checks[index].equals("nullAllowed")) {
- // ignore
- index += 1;
} else {
- System.out.println("Error: unknown keyword \"" + checks[index] + "\"");
- System.exit(0);
+ index = skipOneCheck(checks, index);
}
}
}
@@ -412,6 +426,69 @@ public class JniCodeEmitter {
}
}
+ void emitSentinelCheck(CFunc cfunc, String cname, PrintStream out,
+ boolean isBuffer, boolean emitExceptionCheck, String offset, String remaining, String iii) {
+
+ String[] checks = mChecker.getChecks(cfunc.getName());
+
+ int index = 1;
+ if (checks != null) {
+ while (index < checks.length) {
+ if (checks[index].startsWith("sentinel")) {
+ if (cname != null && !cname.equals(checks[index + 1])) {
+ index += 3;
+ continue;
+ }
+
+ out.println(iii + cname + "_sentinel = false;");
+ out.println(iii + "for (int i = " + remaining +
+ " - 1; i >= 0; i--) {");
+ out.println(iii + indent + "if (" + cname +
+ "[i] == " + checks[index + 2] + "){");
+ out.println(iii + indent + indent +
+ cname + "_sentinel = true;");
+ out.println(iii + indent + indent + "break;");
+ out.println(iii + indent + "}");
+ out.println(iii + "}");
+ out.println(iii +
+ "if (" + cname + "_sentinel == false) {");
+ out.println(iii + indent + "_exception = 1;");
+ out.println(iii + indent +
+ "_exceptionType = \"java/lang/IllegalArgumentException\";");
+ out.println(iii + indent + "_exceptionMessage = \"" + cname +
+ " must contain " + checks[index + 2] + "!\";");
+ out.println(iii + indent + "goto exit;");
+ out.println(iii + "}");
+
+ needsExit = true;
+ index += 3;
+ } else {
+ index = skipOneCheck(checks, index);
+ }
+ }
+ }
+ }
+
+ void emitLocalVariablesForSentinel(CFunc cfunc, PrintStream out) {
+
+ String[] checks = mChecker.getChecks(cfunc.getName());
+
+ int index = 1;
+ if (checks != null) {
+ while (index < checks.length) {
+ if (checks[index].startsWith("sentinel")) {
+ String cname = checks[index + 1];
+ out.println(indent + "bool " + cname + "_sentinel = false;");
+
+ index += 3;
+
+ } else {
+ index = skipOneCheck(checks, index);
+ }
+ }
+ }
+ }
+
boolean hasNonConstArg(JFunc jfunc, CFunc cfunc, List<Integer> nonPrimitiveArgs) {
if (nonPrimitiveArgs.size() > 0) {
for (int i = nonPrimitiveArgs.size() - 1; i >= 0; i--) {
@@ -638,7 +715,7 @@ public class JniCodeEmitter {
return "j" + baseType;
}
} else if (jType.isArray()) {
- return "j" + baseType + "Array";
+ return jType.isClass() ? "jobjectArray" : "j" + baseType + "Array";
} else {
return "jobject";
}
@@ -698,8 +775,10 @@ public class JniCodeEmitter {
// Append signature to function name
String sig = getJniMangledName(signature).replace('.', '_').replace('/', '_');
- out.print("__" + sig);
- outName += "__" + sig;
+ if (!mUseSimpleMethodNames) {
+ out.print("__" + sig);
+ outName += "__" + sig;
+ }
signature = signature.replace('.', '/');
rsignature = rsignature.replace('.', '/');
@@ -734,11 +813,11 @@ public class JniCodeEmitter {
for (int i = 0; i < numArgs; i++) {
out.print(", ");
JType argType = jfunc.getArgType(i);
- String suffix;
+ String suffix = "";
if (!argType.isPrimitive()) {
if (argType.isArray()) {
suffix = "_ref";
- } else {
+ } else if (argType.isBuffer()) {
suffix = "_buf";
}
nonPrimitiveArgs.add(new Integer(i));
@@ -748,9 +827,8 @@ public class JniCodeEmitter {
bufferArgNames.add(cname);
numBufferArgs++;
}
- } else {
- suffix = "";
}
+
if (argType.isString()) {
stringArgs.add(new Integer(i));
}
@@ -801,7 +879,14 @@ public class JniCodeEmitter {
" \"" + cfunc.getName() + "\");");
if (!isVoid) {
String retval = getErrorReturnValue(cfunc);
- out.println(indent + "return " + retval + ";");
+ if (cfunc.getType().isEGLHandle()) {
+ String baseType = cfunc.getType().getBaseType().toLowerCase();
+ out.println(indent +
+ "return toEGLHandle(_env, " + baseType + "Class, " +
+ baseType + "Constructor, " + retval + ");");
+ } else {
+ out.println(indent + "return " + retval + ";");
+ }
}
out.println("}");
out.println();
@@ -820,7 +905,14 @@ public class JniCodeEmitter {
out.println(indent + indent + " return;");
} else {
String retval = getErrorReturnValue(cfunc);
- out.println(indent + indent + " return " + retval + ";");
+ if (cfunc.getType().isEGLHandle()) {
+ String baseType = cfunc.getType().getBaseType().toLowerCase();
+ out.println(indent +
+ "return toEGLHandle(_env, " + baseType + "Class, " +
+ baseType + "Constructor, " + retval + ");");
+ } else {
+ out.println(indent + "return " + retval + ";");
+ }
}
out.println(indent + "}");
}
@@ -830,23 +922,30 @@ public class JniCodeEmitter {
}
boolean initializeReturnValue = stringArgs.size() > 0;
-
- boolean emitExceptionCheck = (numArrays > 0 || numBuffers > 0 || numStrings > 0) &&
- hasNonConstArg(jfunc, cfunc, nonPrimitiveArgs);
+ boolean emitExceptionCheck = ((numArrays > 0 || numStrings > 0)
+ && (hasNonConstArg(jfunc, cfunc, nonPrimitiveArgs)
+ || (cfunc.hasPointerArg() && numArrays > 0))
+ || hasCheckTest(cfunc)
+ || hasIfTest(cfunc))
+ || (stringArgs.size() > 0);
// mChecker.getChecks(cfunc.getName()) != null
-
// Emit an _exeption variable if there will be error checks
if (emitExceptionCheck) {
out.println(indent + "jint _exception = 0;");
+ out.println(indent + "const char * _exceptionType;");
+ out.println(indent + "const char * _exceptionMessage;");
}
// Emit a single _array or multiple _XXXArray variables
if (numBufferArgs == 1) {
out.println(indent + "jarray _array = (jarray) 0;");
+ out.println(indent + "jint _bufferOffset = (jint) 0;");
} else {
for (int i = 0; i < numBufferArgs; i++) {
out.println(indent + "jarray _" + bufferArgNames.get(i) +
"Array = (jarray) 0;");
+ out.println(indent + "jint _" + bufferArgNames.get(i) +
+ "BufferOffset = (jint) 0;");
}
}
if (!isVoid) {
@@ -856,13 +955,49 @@ public class JniCodeEmitter {
" _returnValue = " + retval + ";");
} else if (initializeReturnValue) {
out.println(indent + returnType.getDeclaration() +
- " _returnValue = 0;");
+ " _returnValue = 0;");
} else {
out.println(indent + returnType.getDeclaration() +
" _returnValue;");
}
}
+ // Emit local variable declarations for EGL Handles
+ //
+ // Example:
+ //
+ // EGLSurface surface_native = (EGLHandle)fromEGLHandle(_env, surfaceClass, surfaceConstructor, surface);
+ //
+ if (nonPrimitiveArgs.size() > 0) {
+ for (int i = 0; i < nonPrimitiveArgs.size(); i++) {
+ int idx = nonPrimitiveArgs.get(i).intValue();
+ int cIndex = jfunc.getArgCIndex(idx);
+ String cname = cfunc.getArgName(cIndex);
+
+ if (jfunc.getArgType(idx).isBuffer()
+ || jfunc.getArgType(idx).isArray()
+ || !jfunc.getArgType(idx).isEGLHandle())
+ continue;
+
+ CType type = cfunc.getArgType(jfunc.getArgCIndex(idx));
+ String decl = type.getDeclaration();
+ out.println(indent +
+ decl + " " + cname + "_native = (" +
+ decl + ") fromEGLHandle(_env, " +
+ type.getBaseType().toLowerCase() +
+ "GetHandleID, " + jfunc.getArgName(idx) +
+ ");");
+ }
+ }
+
+ // Emit local variable declarations for element/sentinel checks
+ //
+ // Example:
+ //
+ // bool attrib_list_sentinel_found = false;
+ //
+ emitLocalVariablesForSentinel(cfunc, out);
+
// Emit local variable declarations for pointer arguments
//
// Example:
@@ -878,9 +1013,12 @@ public class JniCodeEmitter {
int cIndex = jfunc.getArgCIndex(idx);
String cname = cfunc.getArgName(cIndex);
+ if (!jfunc.getArgType(idx).isBuffer() && !jfunc.getArgType(idx).isArray())
+ continue;
+
CType type = cfunc.getArgType(jfunc.getArgCIndex(idx));
String decl = type.getDeclaration();
- if (jfunc.getArgType(idx).isArray()) {
+ if (jfunc.getArgType(idx).isArray() && !jfunc.getArgType(idx).isClass()) {
out.println(indent +
decl +
(decl.endsWith("*") ? "" : " ") +
@@ -892,10 +1030,10 @@ public class JniCodeEmitter {
out.println(indent +
"jint " + remaining + ";");
out.println(indent +
- decl +
- (decl.endsWith("*") ? "" : " ") +
- jfunc.getArgName(idx) +
- " = (" + decl + ") 0;");
+ decl +
+ (decl.endsWith("*") ? "" : " ") +
+ jfunc.getArgName(idx) +
+ " = (" + decl + ") 0;");
}
out.println();
@@ -923,11 +1061,13 @@ public class JniCodeEmitter {
CType type = cfunc.getArgType(jfunc.getArgCIndex(idx));
String decl = type.getDeclaration();
- out.println(indent + "if (!" + cname + ") {");
- out.println(indent + " jniThrowException(_env, " +
- "\"java/lang/IllegalArgumentException\", \"" + cname + " == null\");");
- out.println(indent + " goto exit;");
needsExit = true;
+ out.println(indent + "if (!" + cname + ") {");
+ out.println(indent + indent +
+ "_exceptionType = \"java/lang/IllegalArgumentException\";");
+ out.println(indent + indent +
+ "_exceptionMessage = \"" + cname + " == null\";");
+ out.println(indent + indent + "goto exit;");
out.println(indent + "}");
out.println(indent + "_native" + cname + " = _env->GetStringUTFChars(" + cname + ", 0);");
@@ -936,9 +1076,8 @@ public class JniCodeEmitter {
out.println();
}
- // Emit 'GetPrimitiveArrayCritical' for arrays
+ // Emit 'GetPrimitiveArrayCritical' for non-object arrays
// Emit 'GetPointer' calls for Buffer pointers
- int bufArgIdx = 0;
if (nonPrimitiveArgs.size() > 0) {
for (int i = 0; i < nonPrimitiveArgs.size(); i++) {
int idx = nonPrimitiveArgs.get(i).intValue();
@@ -950,29 +1089,24 @@ public class JniCodeEmitter {
remaining = ((numArrays + numBuffers) <= 1) ? "_remaining" :
"_" + cname + "Remaining";
- if (jfunc.getArgType(idx).isArray()) {
- out.println(indent +
- "if (!" +
- cname +
- "_ref) {");
- if (emitExceptionCheck) {
- out.println(indent + indent + "_exception = 1;");
- }
- out.println(indent + " jniThrowException(_env, " +
- "\"java/lang/IllegalArgumentException\", " +
- "\"" + cname + " == null\");");
- out.println(indent + " goto exit;");
+ if (jfunc.getArgType(idx).isArray()
+ && !jfunc.getArgType(idx).isEGLHandle()) {
needsExit = true;
+ out.println(indent + "if (!" + cname + "_ref) {");
+ out.println(indent + indent + "_exception = 1;");
+ out.println(indent + indent +
+ "_exceptionType = \"java/lang/IllegalArgumentException\";");
+ out.println(indent + indent +
+ "_exceptionMessage = \"" + cname +" == null\";");
+ out.println(indent + indent + "goto exit;");
out.println(indent + "}");
-
out.println(indent + "if (" + offset + " < 0) {");
- if (emitExceptionCheck) {
- out.println(indent + indent + "_exception = 1;");
- }
- out.println(indent + " jniThrowException(_env, " +
- "\"java/lang/IllegalArgumentException\", \"" + offset + " < 0\");");
- out.println(indent + " goto exit;");
- needsExit = true;
+ out.println(indent + indent + "_exception = 1;");
+ out.println(indent + indent +
+ "_exceptionType = \"java/lang/IllegalArgumentException\";");
+ out.println(indent + indent +
+ "_exceptionMessage = \"" + offset +" < 0\";");
+ out.println(indent + indent + "goto exit;");
out.println(indent + "}");
out.println(indent + remaining + " = " +
@@ -997,12 +1131,48 @@ public class JniCodeEmitter {
jfunc.getArgName(idx) +
"_ref, (jboolean *)0);");
out.println(indent +
- cname + " = " + cname + "_base + " + offset +
- ";");
+ cname + " = " + cname + "_base + " + offset + ";");
+
+ emitSentinelCheck(cfunc, cname, out, false,
+ emitExceptionCheck, offset,
+ remaining, indent);
out.println();
- } else {
+ } else if (jfunc.getArgType(idx).isArray()
+ && jfunc.getArgType(idx).isEGLHandle()) {
+ needsExit = true;
+ out.println(indent + "if (!" + cname + "_ref) {");
+ out.println(indent + indent + "_exception = 1;");
+ out.println(indent + indent +
+ "_exceptionType = \"java/lang/IllegalArgumentException\";");
+ out.println(indent + indent + "_exceptionMessage = \"" + cname +" == null\";");
+ out.println(indent + indent + "goto exit;");
+ out.println(indent + "}");
+ out.println(indent + "if (" + offset + " < 0) {");
+ out.println(indent + indent + "_exception = 1;");
+ out.println(indent + indent +
+ "_exceptionType = \"java/lang/IllegalArgumentException\";");
+ out.println(indent + indent + "_exceptionMessage = \"" + offset +" < 0\";");
+ out.println(indent + indent + "goto exit;");
+ out.println(indent + "}");
+
+ out.println(indent + remaining + " = " +
+ (mUseCPlusPlus ? "_env" : "(*_env)") +
+ "->GetArrayLength(" +
+ (mUseCPlusPlus ? "" : "_env, ") +
+ cname + "_ref) - " + offset + ";");
+ emitNativeBoundsChecks(cfunc, cname, out, false,
+ emitExceptionCheck,
+ offset, remaining, " ");
+ out.println(indent +
+ jfunc.getArgName(idx) + " = new " +
+ cfunc.getArgType(cIndex).getBaseType() +
+ "["+ remaining + "];");
+ out.println();
+ } else if (jfunc.getArgType(idx).isBuffer()) {
String array = numBufferArgs <= 1 ? "_array" :
- "_" + bufferArgNames.get(bufArgIdx++) + "Array";
+ "_" + cfunc.getArgName(cIndex) + "Array";
+ String bufferOffset = numBufferArgs <= 1 ? "_bufferOffset" :
+ "_" + cfunc.getArgName(cIndex) + "BufferOffset";
boolean nullAllowed = isNullAllowed(cfunc) || isPointerFunc;
if (nullAllowed) {
@@ -1019,7 +1189,7 @@ public class JniCodeEmitter {
cname + "_buf);");
String iii = " ";
out.println(iii + indent + "if ( ! " + cname + " ) {");
- out.println(iii + iii + indent + "return;");
+ out.println(iii + indent + indent + "return;");
out.println(iii + indent + "}");
} else {
out.println(indent +
@@ -1028,7 +1198,7 @@ public class JniCodeEmitter {
cfunc.getArgType(cIndex).getDeclaration() +
")getPointer(_env, " +
cname +
- "_buf, &" + array + ", &" + remaining +
+ "_buf, &" + array + ", &" + remaining + ", &" + bufferOffset +
");");
}
@@ -1043,6 +1213,33 @@ public class JniCodeEmitter {
}
}
+ // Emit 'GetPrimitiveArrayCritical' for pointers if needed
+ if (nonPrimitiveArgs.size() > 0) {
+ for (int i = 0; i < nonPrimitiveArgs.size(); i++) {
+ int idx = nonPrimitiveArgs.get(i).intValue();
+ int cIndex = jfunc.getArgCIndex(idx);
+
+ if(!jfunc.getArgType(idx).isBuffer() || isPointerFunc) continue;
+
+ String cname = cfunc.getArgName(cIndex);
+ String bufferOffset = numBufferArgs <= 1 ? "_bufferOffset" :
+ "_" + cname + "BufferOffset";
+ String array = numBufferArgs <= 1 ? "_array" :
+ "_" + cfunc.getArgName(cIndex) + "Array";
+
+ boolean nullAllowed = isNullAllowed(cfunc) || isPointerFunc;
+ if (nullAllowed) {
+ out.println(indent + "if (" + cname + "_buf && " + cname +" == NULL) {");
+ } else {
+ out.println(indent + "if (" + cname +" == NULL) {");
+ }
+ out.println(indent + indent + "char * _" + cname + "Base = (char *)_env->GetPrimitiveArrayCritical(" + array + ", (jboolean *) 0);");
+ out.println(indent + indent + cname + " = (" +cfunc.getArgType(cIndex).getDeclaration() +") (_" + cname + "Base + " + bufferOffset + ");");
+ out.println(indent + "}");
+ }
+ }
+
+
if (!isVoid) {
out.print(indent + "_returnValue = ");
} else {
@@ -1075,18 +1272,23 @@ public class JniCodeEmitter {
for (int i = 0; i < numArgs; i++) {
String typecast;
if (i == numArgs - 1 && isVBOPointerFunc) {
- typecast = "const GLvoid *";
+ typecast = "(const GLvoid *)";
} else {
- typecast = cfunc.getArgType(i).getDeclaration();
+ typecast = "(" + cfunc.getArgType(i).getDeclaration() + ")";
}
out.print(indent + indent +
- "(" +
- typecast +
- ")");
+ typecast);
+
if (cfunc.getArgType(i).isConstCharPointer()) {
out.print("_native");
}
- out.print(cfunc.getArgName(i));
+
+ if (cfunc.getArgType(i).isEGLHandle() &&
+ !cfunc.getArgType(i).isPointer()){
+ out.print(cfunc.getArgName(i)+"_native");
+ } else {
+ out.print(cfunc.getArgName(i));
+ }
if (i == numArgs - 1) {
if (isPointerFunc) {
@@ -1108,13 +1310,13 @@ public class JniCodeEmitter {
needsExit = false;
}
- bufArgIdx = 0;
+
if (nonPrimitiveArgs.size() > 0) {
for (int i = nonPrimitiveArgs.size() - 1; i >= 0; i--) {
int idx = nonPrimitiveArgs.get(i).intValue();
int cIndex = jfunc.getArgCIndex(idx);
- if (jfunc.getArgType(idx).isArray()) {
+ if (jfunc.getArgType(idx).isArray() && !jfunc.getArgType(idx).isClass()) {
// If the argument is 'const', GL will not write to it.
// In this case, we can use the 'JNI_ABORT' flag to avoid
@@ -1130,22 +1332,21 @@ public class JniCodeEmitter {
"_base,");
out.println(indent + indent + indent +
(cfunc.getArgType(cIndex).isConst() ?
- "JNI_ABORT" :
- "_exception ? JNI_ABORT: 0") +
+ "JNI_ABORT" : "_exception ? JNI_ABORT: 0" ) +
");");
out.println(indent + "}");
} else if (jfunc.getArgType(idx).isBuffer()) {
if (! isPointerFunc) {
String array = numBufferArgs <= 1 ? "_array" :
- "_" + bufferArgNames.get(bufArgIdx++) + "Array";
+ "_" + cfunc.getArgName(cIndex) + "Array";
out.println(indent + "if (" + array + ") {");
out.println(indent + indent +
"releasePointer(_env, " + array + ", " +
cfunc.getArgName(cIndex) +
", " +
(cfunc.getArgType(cIndex).isConst() ?
- "JNI_FALSE" : "_exception ? JNI_FALSE :" +
- " JNI_TRUE") +
+ "JNI_FALSE" : (emitExceptionCheck ?
+ "_exception ? JNI_FALSE : JNI_TRUE" : "JNI_TRUE")) +
");");
out.println(indent + "}");
}
@@ -1168,9 +1369,60 @@ public class JniCodeEmitter {
out.println();
}
+ // Copy results back to java arrays
+ if (nonPrimitiveArgs.size() > 0) {
+ for (int i = nonPrimitiveArgs.size() - 1; i >= 0; i--) {
+ int idx = nonPrimitiveArgs.get(i).intValue();
+ int cIndex = jfunc.getArgCIndex(idx);
+ String baseType = cfunc.getArgType(cIndex).getBaseType().toLowerCase();
+ if (jfunc.getArgType(idx).isArray() && jfunc.getArgType(idx).isClass()) {
+ remaining = ((numArrays + numBuffers) <= 1) ? "_remaining" :
+ "_" + cfunc.getArgName(cIndex) + "Remaining";
+ offset = numArrays <= 1 ? "offset" : cfunc.getArgName(cIndex) + "Offset";
+ out.println(indent +
+ "if (" + jfunc.getArgName(idx) + ") {");
+ out.println(indent + indent +
+ "for (int i = 0; i < " + remaining + "; i++) {");
+ out.println(indent + indent + indent +
+ "jobject " + cfunc.getArgName(cIndex) +
+ "_new = toEGLHandle(_env, " + baseType +
+ "Class, " + baseType + "Constructor, " +
+ cfunc.getArgName(cIndex) + "[i]);");
+ out.println(indent + indent + indent +
+ (mUseCPlusPlus ? "_env" : "(*_env)") +
+ "->SetObjectArrayElement(" +
+ (mUseCPlusPlus ? "" : "_env, ") +
+ cfunc.getArgName(cIndex) +
+ "_ref, i + " + offset + ", " +
+ cfunc.getArgName(cIndex) + "_new);");
+ out.println(indent + indent + "}");
+ out.println(indent + indent +
+ "delete[] " + jfunc.getArgName(idx) + ";");
+ out.println(indent + "}");
+ }
+ }
+ }
+
+
+ // Throw exception if there is one
+ if (emitExceptionCheck) {
+ out.println(indent + "if (_exception) {");
+ out.println(indent + indent +
+ "jniThrowException(_env, _exceptionType, _exceptionMessage);");
+ out.println(indent + "}");
+
+ }
+
if (!isVoid) {
- out.println(indent + "return _returnValue;");
+ if (cfunc.getType().isEGLHandle()) {
+ String baseType = cfunc.getType().getBaseType().toLowerCase();
+ out.println(indent +
+ "return toEGLHandle(_env, " + baseType + "Class, " +
+ baseType + "Constructor, _returnValue);");
+ } else {
+ out.println(indent + "return _returnValue;");
+ }
}
out.println("}");
diff --git a/opengl/tools/glgen/static/egl/EGLConfig.java b/opengl/tools/glgen/static/egl/EGLConfig.java
new file mode 100644
index 0000000..d457c9f
--- /dev/null
+++ b/opengl/tools/glgen/static/egl/EGLConfig.java
@@ -0,0 +1,37 @@
+/*
+**
+** Copyright 2012, 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.opengl;
+
+/**
+ * Wrapper class for native EGLConfig objects.
+ *
+ */
+public class EGLConfig extends EGLObjectHandle {
+ private EGLConfig(int handle) {
+ super(handle);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ EGLConfig that = (EGLConfig) o;
+ return getHandle() == that.getHandle();
+ }
+}
diff --git a/opengl/tools/glgen/static/egl/EGLContext.java b/opengl/tools/glgen/static/egl/EGLContext.java
new file mode 100644
index 0000000..41b8ef1
--- /dev/null
+++ b/opengl/tools/glgen/static/egl/EGLContext.java
@@ -0,0 +1,37 @@
+/*
+**
+** Copyright 2012, 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.opengl;
+
+/**
+ * Wrapper class for native EGLContext objects.
+ *
+ */
+public class EGLContext extends EGLObjectHandle {
+ private EGLContext(int handle) {
+ super(handle);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ EGLContext that = (EGLContext) o;
+ return getHandle() == that.getHandle();
+ }
+}
diff --git a/opengl/tools/glgen/static/egl/EGLDisplay.java b/opengl/tools/glgen/static/egl/EGLDisplay.java
new file mode 100644
index 0000000..17d1a64
--- /dev/null
+++ b/opengl/tools/glgen/static/egl/EGLDisplay.java
@@ -0,0 +1,37 @@
+/*
+**
+** Copyright 2012, 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.opengl;
+
+/**
+ * Wrapper class for native EGLDisplay objects.
+ *
+ */
+public class EGLDisplay extends EGLObjectHandle {
+ private EGLDisplay(int handle) {
+ super(handle);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ EGLDisplay that = (EGLDisplay) o;
+ return getHandle() == that.getHandle();
+ }
+}
diff --git a/opengl/tools/glgen/static/egl/EGLObjectHandle.java b/opengl/tools/glgen/static/egl/EGLObjectHandle.java
new file mode 100644
index 0000000..d2710de
--- /dev/null
+++ b/opengl/tools/glgen/static/egl/EGLObjectHandle.java
@@ -0,0 +1,47 @@
+/*
+**
+** Copyright 2012, 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.opengl;
+
+/**
+ * Base class for wrapped EGL objects.
+ *
+ */
+public abstract class EGLObjectHandle {
+ private final int mHandle;
+
+ protected EGLObjectHandle(int handle) {
+ mHandle = handle;
+ }
+
+ /**
+ * Returns the native handle of the wrapped EGL object. This handle can be
+ * cast to the corresponding native type on the native side.
+ *
+ * For example, EGLDisplay dpy = (EGLDisplay)handle;
+ *
+ * @return the native handle of the wrapped EGL object.
+ */
+ public int getHandle() {
+ return mHandle;
+ }
+
+ @Override
+ public int hashCode() {
+ return getHandle();
+ }
+}
diff --git a/opengl/tools/glgen/static/egl/EGLSurface.java b/opengl/tools/glgen/static/egl/EGLSurface.java
new file mode 100644
index 0000000..65bec4f
--- /dev/null
+++ b/opengl/tools/glgen/static/egl/EGLSurface.java
@@ -0,0 +1,37 @@
+/*
+**
+** Copyright 2012, 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.opengl;
+
+/**
+ * Wrapper class for native EGLSurface objects.
+ *
+ */
+public class EGLSurface extends EGLObjectHandle {
+ private EGLSurface(int handle) {
+ super(handle);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ EGLSurface that = (EGLSurface) o;
+ return getHandle() == that.getHandle();
+ }
+}
diff --git a/opengl/tools/glgen/stubs/egl/EGL14Header.java-if b/opengl/tools/glgen/stubs/egl/EGL14Header.java-if
new file mode 100644
index 0000000..0c29d5c
--- /dev/null
+++ b/opengl/tools/glgen/stubs/egl/EGL14Header.java-if
@@ -0,0 +1,151 @@
+**
+** Copyright 2012, 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.
+*/
+
+// This source file is automatically generated
+
+package android.opengl;
+
+import android.graphics.SurfaceTexture;
+import android.view.Surface;
+import android.view.SurfaceView;
+import android.view.SurfaceHolder;
+
+/**
+ * EGL 1.4
+ *
+ */
+public class EGL14 {
+
+public static final int EGL_DEFAULT_DISPLAY = 0;
+public static EGLContext EGL_NO_CONTEXT = null;
+public static EGLDisplay EGL_NO_DISPLAY = null;
+public static EGLSurface EGL_NO_SURFACE = null;
+
+public static final int EGL_FALSE = 0;
+public static final int EGL_TRUE = 1;
+public static final int EGL_SUCCESS = 0x3000;
+public static final int EGL_NOT_INITIALIZED = 0x3001;
+public static final int EGL_BAD_ACCESS = 0x3002;
+public static final int EGL_BAD_ALLOC = 0x3003;
+public static final int EGL_BAD_ATTRIBUTE = 0x3004;
+public static final int EGL_BAD_CONFIG = 0x3005;
+public static final int EGL_BAD_CONTEXT = 0x3006;
+public static final int EGL_BAD_CURRENT_SURFACE = 0x3007;
+public static final int EGL_BAD_DISPLAY = 0x3008;
+public static final int EGL_BAD_MATCH = 0x3009;
+public static final int EGL_BAD_NATIVE_PIXMAP = 0x300A;
+public static final int EGL_BAD_NATIVE_WINDOW = 0x300B;
+public static final int EGL_BAD_PARAMETER = 0x300C;
+public static final int EGL_BAD_SURFACE = 0x300D;
+public static final int EGL_CONTEXT_LOST = 0x300E;
+public static final int EGL_BUFFER_SIZE = 0x3020;
+public static final int EGL_ALPHA_SIZE = 0x3021;
+public static final int EGL_BLUE_SIZE = 0x3022;
+public static final int EGL_GREEN_SIZE = 0x3023;
+public static final int EGL_RED_SIZE = 0x3024;
+public static final int EGL_DEPTH_SIZE = 0x3025;
+public static final int EGL_STENCIL_SIZE = 0x3026;
+public static final int EGL_CONFIG_CAVEAT = 0x3027;
+public static final int EGL_CONFIG_ID = 0x3028;
+public static final int EGL_LEVEL = 0x3029;
+public static final int EGL_MAX_PBUFFER_HEIGHT = 0x302A;
+public static final int EGL_MAX_PBUFFER_PIXELS = 0x302B;
+public static final int EGL_MAX_PBUFFER_WIDTH = 0x302C;
+public static final int EGL_NATIVE_RENDERABLE = 0x302D;
+public static final int EGL_NATIVE_VISUAL_ID = 0x302E;
+public static final int EGL_NATIVE_VISUAL_TYPE = 0x302F;
+public static final int EGL_SAMPLES = 0x3031;
+public static final int EGL_SAMPLE_BUFFERS = 0x3032;
+public static final int EGL_SURFACE_TYPE = 0x3033;
+public static final int EGL_TRANSPARENT_TYPE = 0x3034;
+public static final int EGL_TRANSPARENT_BLUE_VALUE = 0x3035;
+public static final int EGL_TRANSPARENT_GREEN_VALUE = 0x3036;
+public static final int EGL_TRANSPARENT_RED_VALUE = 0x3037;
+public static final int EGL_NONE = 0x3038;
+public static final int EGL_BIND_TO_TEXTURE_RGB = 0x3039;
+public static final int EGL_BIND_TO_TEXTURE_RGBA = 0x303A;
+public static final int EGL_MIN_SWAP_INTERVAL = 0x303B;
+public static final int EGL_MAX_SWAP_INTERVAL = 0x303C;
+public static final int EGL_LUMINANCE_SIZE = 0x303D;
+public static final int EGL_ALPHA_MASK_SIZE = 0x303E;
+public static final int EGL_COLOR_BUFFER_TYPE = 0x303F;
+public static final int EGL_RENDERABLE_TYPE = 0x3040;
+public static final int EGL_MATCH_NATIVE_PIXMAP = 0x3041;
+public static final int EGL_CONFORMANT = 0x3042;
+public static final int EGL_SLOW_CONFIG = 0x3050;
+public static final int EGL_NON_CONFORMANT_CONFIG = 0x3051;
+public static final int EGL_TRANSPARENT_RGB = 0x3052;
+public static final int EGL_RGB_BUFFER = 0x308E;
+public static final int EGL_LUMINANCE_BUFFER = 0x308F;
+public static final int EGL_NO_TEXTURE = 0x305C;
+public static final int EGL_TEXTURE_RGB = 0x305D;
+public static final int EGL_TEXTURE_RGBA = 0x305E;
+public static final int EGL_TEXTURE_2D = 0x305F;
+public static final int EGL_PBUFFER_BIT = 0x0001;
+public static final int EGL_PIXMAP_BIT = 0x0002;
+public static final int EGL_WINDOW_BIT = 0x0004;
+public static final int EGL_VG_COLORSPACE_LINEAR_BIT = 0x0020;
+public static final int EGL_VG_ALPHA_FORMAT_PRE_BIT = 0x0040;
+public static final int EGL_MULTISAMPLE_RESOLVE_BOX_BIT = 0x0200;
+public static final int EGL_SWAP_BEHAVIOR_PRESERVED_BIT = 0x0400;
+public static final int EGL_OPENGL_ES_BIT = 0x0001;
+public static final int EGL_OPENVG_BIT = 0x0002;
+public static final int EGL_OPENGL_ES2_BIT = 0x0004;
+public static final int EGL_OPENGL_BIT = 0x0008;
+public static final int EGL_VENDOR = 0x3053;
+public static final int EGL_VERSION = 0x3054;
+public static final int EGL_EXTENSIONS = 0x3055;
+public static final int EGL_CLIENT_APIS = 0x308D;
+public static final int EGL_HEIGHT = 0x3056;
+public static final int EGL_WIDTH = 0x3057;
+public static final int EGL_LARGEST_PBUFFER = 0x3058;
+public static final int EGL_TEXTURE_FORMAT = 0x3080;
+public static final int EGL_TEXTURE_TARGET = 0x3081;
+public static final int EGL_MIPMAP_TEXTURE = 0x3082;
+public static final int EGL_MIPMAP_LEVEL = 0x3083;
+public static final int EGL_RENDER_BUFFER = 0x3086;
+public static final int EGL_VG_COLORSPACE = 0x3087;
+public static final int EGL_VG_ALPHA_FORMAT = 0x3088;
+public static final int EGL_HORIZONTAL_RESOLUTION = 0x3090;
+public static final int EGL_VERTICAL_RESOLUTION = 0x3091;
+public static final int EGL_PIXEL_ASPECT_RATIO = 0x3092;
+public static final int EGL_SWAP_BEHAVIOR = 0x3093;
+public static final int EGL_MULTISAMPLE_RESOLVE = 0x3099;
+public static final int EGL_BACK_BUFFER = 0x3084;
+public static final int EGL_SINGLE_BUFFER = 0x3085;
+public static final int EGL_VG_COLORSPACE_sRGB = 0x3089;
+public static final int EGL_VG_COLORSPACE_LINEAR = 0x308A;
+public static final int EGL_VG_ALPHA_FORMAT_NONPRE = 0x308B;
+public static final int EGL_VG_ALPHA_FORMAT_PRE = 0x308C;
+public static final int EGL_DISPLAY_SCALING = 10000;
+public static final int EGL_BUFFER_PRESERVED = 0x3094;
+public static final int EGL_BUFFER_DESTROYED = 0x3095;
+public static final int EGL_OPENVG_IMAGE = 0x3096;
+public static final int EGL_CONTEXT_CLIENT_TYPE = 0x3097;
+public static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
+public static final int EGL_MULTISAMPLE_RESOLVE_DEFAULT = 0x309A;
+public static final int EGL_MULTISAMPLE_RESOLVE_BOX = 0x309B;
+public static final int EGL_OPENGL_ES_API = 0x30A0;
+public static final int EGL_OPENVG_API = 0x30A1;
+public static final int EGL_OPENGL_API = 0x30A2;
+public static final int EGL_DRAW = 0x3059;
+public static final int EGL_READ = 0x305A;
+public static final int EGL_CORE_NATIVE_ENGINE = 0x305B;
+
+ native private static void _nativeClassInit();
+ static {
+ _nativeClassInit();
+ }
diff --git a/opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp b/opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp
new file mode 100644
index 0000000..7904ac7
--- /dev/null
+++ b/opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp
@@ -0,0 +1,132 @@
+**
+** Copyright 2012, 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.
+*/
+
+// This source file is automatically generated
+
+#include "jni.h"
+#include "JNIHelp.h"
+#include <android_runtime/AndroidRuntime.h>
+#include <android_runtime/android_view_Surface.h>
+#include <android_runtime/android_graphics_SurfaceTexture.h>
+#include <utils/misc.h>
+
+#include <assert.h>
+#include <EGL/egl.h>
+
+#include <gui/Surface.h>
+#include <gui/SurfaceTexture.h>
+#include <gui/SurfaceTextureClient.h>
+
+#include <ui/ANativeObjectBase.h>
+
+static int initialized = 0;
+
+static jclass egldisplayClass;
+static jclass eglcontextClass;
+static jclass eglsurfaceClass;
+static jclass eglconfigClass;
+
+static jmethodID egldisplayGetHandleID;
+static jmethodID eglcontextGetHandleID;
+static jmethodID eglsurfaceGetHandleID;
+static jmethodID eglconfigGetHandleID;
+
+static jmethodID egldisplayConstructor;
+static jmethodID eglcontextConstructor;
+static jmethodID eglsurfaceConstructor;
+static jmethodID eglconfigConstructor;
+
+static jobject eglNoContextObject;
+static jobject eglNoDisplayObject;
+static jobject eglNoSurfaceObject;
+
+
+
+/* Cache method IDs each time the class is loaded. */
+
+static void
+nativeClassInit(JNIEnv *_env, jclass glImplClass)
+{
+ jclass egldisplayClassLocal = _env->FindClass("android/opengl/EGLDisplay");
+ egldisplayClass = (jclass) _env->NewGlobalRef(egldisplayClassLocal);
+ jclass eglcontextClassLocal = _env->FindClass("android/opengl/EGLContext");
+ eglcontextClass = (jclass) _env->NewGlobalRef(eglcontextClassLocal);
+ jclass eglsurfaceClassLocal = _env->FindClass("android/opengl/EGLSurface");
+ eglsurfaceClass = (jclass) _env->NewGlobalRef(eglsurfaceClassLocal);
+ jclass eglconfigClassLocal = _env->FindClass("android/opengl/EGLConfig");
+ eglconfigClass = (jclass) _env->NewGlobalRef(eglconfigClassLocal);
+
+ egldisplayGetHandleID = _env->GetMethodID(egldisplayClass, "getHandle", "()I");
+ eglcontextGetHandleID = _env->GetMethodID(eglcontextClass, "getHandle", "()I");
+ eglsurfaceGetHandleID = _env->GetMethodID(eglsurfaceClass, "getHandle", "()I");
+ eglconfigGetHandleID = _env->GetMethodID(eglconfigClass, "getHandle", "()I");
+
+
+ egldisplayConstructor = _env->GetMethodID(egldisplayClass, "<init>", "(I)V");
+ eglcontextConstructor = _env->GetMethodID(eglcontextClass, "<init>", "(I)V");
+ eglsurfaceConstructor = _env->GetMethodID(eglsurfaceClass, "<init>", "(I)V");
+ eglconfigConstructor = _env->GetMethodID(eglconfigClass, "<init>", "(I)V");
+
+ jobject localeglNoContextObject = _env->NewObject(eglcontextClass, eglcontextConstructor, (jint)EGL_NO_CONTEXT);
+ eglNoContextObject = _env->NewGlobalRef(localeglNoContextObject);
+ jobject localeglNoDisplayObject = _env->NewObject(egldisplayClass, egldisplayConstructor, (jint)EGL_NO_DISPLAY);
+ eglNoDisplayObject = _env->NewGlobalRef(localeglNoDisplayObject);
+ jobject localeglNoSurfaceObject = _env->NewObject(eglsurfaceClass, eglsurfaceConstructor, (jint)EGL_NO_SURFACE);
+ eglNoSurfaceObject = _env->NewGlobalRef(localeglNoSurfaceObject);
+
+
+ jclass eglClass = _env->FindClass("android/opengl/EGL14");
+ jfieldID noContextFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_CONTEXT", "Landroid/opengl/EGLContext;");
+ _env->SetStaticObjectField(eglClass, noContextFieldID, eglNoContextObject);
+
+ jfieldID noDisplayFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_DISPLAY", "Landroid/opengl/EGLDisplay;");
+ _env->SetStaticObjectField(eglClass, noDisplayFieldID, eglNoDisplayObject);
+
+ jfieldID noSurfaceFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_SURFACE", "Landroid/opengl/EGLSurface;");
+ _env->SetStaticObjectField(eglClass, noSurfaceFieldID, eglNoSurfaceObject);
+}
+
+static void *
+fromEGLHandle(JNIEnv *_env, jmethodID mid, jobject obj) {
+ if (obj == NULL){
+ jniThrowException(_env, "java/lang/IllegalArgumentException",
+ "Object is set to null.");
+ }
+
+ return (void*) (_env->CallIntMethod(obj, mid));
+}
+
+static jobject
+toEGLHandle(JNIEnv *_env, jclass cls, jmethodID con, void * handle) {
+ if (cls == eglcontextClass &&
+ (EGLContext)handle == EGL_NO_CONTEXT) {
+ return eglNoContextObject;
+ }
+
+ if (cls == egldisplayClass &&
+ (EGLDisplay)handle == EGL_NO_DISPLAY) {
+ return eglNoDisplayObject;
+ }
+
+ if (cls == eglsurfaceClass &&
+ (EGLSurface)handle == EGL_NO_SURFACE) {
+ return eglNoSurfaceObject;
+ }
+
+ return _env->NewObject(cls, con, (jint)handle);
+}
+
+// --------------------------------------------------------------------------
diff --git a/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.cpp b/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.cpp
new file mode 100644
index 0000000..610cde5
--- /dev/null
+++ b/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.cpp
@@ -0,0 +1,154 @@
+/* EGLSurface eglCreateWindowSurface ( EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list ) */
+static jobject
+android_eglCreateWindowSurface
+ (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jobject win, jintArray attrib_list_ref, jint offset) {
+ jint _exception = 0;
+ const char * _exceptionType = "";
+ const char * _exceptionMessage = "";
+ EGLSurface _returnValue = (EGLSurface) 0;
+ EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
+ EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
+ int attrib_list_sentinel = 0;
+ EGLint *attrib_list_base = (EGLint *) 0;
+ jint _remaining;
+ EGLint *attrib_list = (EGLint *) 0;
+ android::sp<ANativeWindow> window;
+
+ if (!attrib_list_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "attrib_list == null";
+ goto exit;
+ }
+ if (offset < 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "offset < 0";
+ goto exit;
+ }
+ if (win == NULL) {
+not_valid_surface:
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface";
+ goto exit;
+ }
+
+ window = android::android_Surface_getNativeWindow(_env, win);
+
+ if (window == NULL)
+ goto not_valid_surface;
+
+ _remaining = _env->GetArrayLength(attrib_list_ref) - offset;
+ attrib_list_base = (EGLint *)
+ _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0);
+ attrib_list = attrib_list_base + offset;
+ attrib_list_sentinel = 0;
+ for (int i = _remaining - 1; i >= 0; i--) {
+ if (*((EGLint*)(attrib_list + i)) == EGL_NONE){
+ attrib_list_sentinel = 1;
+ break;
+ }
+ }
+ if (attrib_list_sentinel == 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "attrib_list must contain EGL_NONE!";
+ goto exit;
+ }
+
+ _returnValue = eglCreateWindowSurface(
+ (EGLDisplay)dpy_native,
+ (EGLConfig)config_native,
+ (EGLNativeWindowType)window.get(),
+ (EGLint *)attrib_list
+ );
+
+exit:
+ if (attrib_list_base) {
+ _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base,
+ JNI_ABORT);
+ }
+ if (_exception) {
+ jniThrowException(_env, _exceptionType, _exceptionMessage);
+ }
+ return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
+}
+
+/* EGLSurface eglCreateWindowSurface ( EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list ) */
+static jobject
+android_eglCreateWindowSurfaceTexture
+ (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jobject win, jintArray attrib_list_ref, jint offset) {
+ jint _exception = 0;
+ const char * _exceptionType = "";
+ const char * _exceptionMessage = "";
+ EGLSurface _returnValue = (EGLSurface) 0;
+ EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
+ EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
+ int attrib_list_sentinel = 0;
+ EGLint *attrib_list_base = (EGLint *) 0;
+ jint _remaining;
+ EGLint *attrib_list = (EGLint *) 0;
+ android::sp<ANativeWindow> window;
+ android::sp<android::SurfaceTexture> surfaceTexture;
+
+ if (!attrib_list_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "attrib_list == null";
+ goto exit;
+ }
+ if (offset < 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "offset < 0";
+ goto exit;
+ }
+ if (win == NULL) {
+not_valid_surface:
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface";
+ goto exit;
+ }
+ surfaceTexture = android::SurfaceTexture_getSurfaceTexture(_env, win);
+ window = new android::SurfaceTextureClient(surfaceTexture);
+
+ if (window == NULL)
+ goto not_valid_surface;
+
+ _remaining = _env->GetArrayLength(attrib_list_ref) - offset;
+ attrib_list_base = (EGLint *)
+ _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0);
+ attrib_list = attrib_list_base + offset;
+ attrib_list_sentinel = 0;
+ for (int i = _remaining - 1; i >= 0; i--) {
+ if (*((EGLint*)(attrib_list + i)) == EGL_NONE){
+ attrib_list_sentinel = 1;
+ break;
+ }
+ }
+ if (attrib_list_sentinel == 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "attrib_list must contain EGL_NONE!";
+ goto exit;
+ }
+
+ _returnValue = eglCreateWindowSurface(
+ (EGLDisplay)dpy_native,
+ (EGLConfig)config_native,
+ (EGLNativeWindowType)window.get(),
+ (EGLint *)attrib_list
+ );
+
+exit:
+ if (attrib_list_base) {
+ _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base,
+ JNI_ABORT);
+ }
+ if (_exception) {
+ jniThrowException(_env, _exceptionType, _exceptionMessage);
+ }
+ return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
+}
diff --git a/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.java b/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.java
new file mode 100644
index 0000000..e42334e
--- /dev/null
+++ b/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.java
@@ -0,0 +1,48 @@
+ // C function EGLSurface eglCreateWindowSurface ( EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list )
+
+ private static native EGLSurface _eglCreateWindowSurface(
+ EGLDisplay dpy,
+ EGLConfig config,
+ Object win,
+ int[] attrib_list,
+ int offset
+ );
+
+ private static native EGLSurface _eglCreateWindowSurfaceTexture(
+ EGLDisplay dpy,
+ EGLConfig config,
+ Object win,
+ int[] attrib_list,
+ int offset
+ );
+
+ public static EGLSurface eglCreateWindowSurface(EGLDisplay dpy,
+ EGLConfig config,
+ Object win,
+ int[] attrib_list,
+ int offset
+ ){
+ Surface sur = null;
+ if (win instanceof SurfaceView) {
+ SurfaceView surfaceView = (SurfaceView)win;
+ sur = surfaceView.getHolder().getSurface();
+ } else if (win instanceof SurfaceHolder) {
+ SurfaceHolder holder = (SurfaceHolder)win;
+ sur = holder.getSurface();
+ }
+
+ EGLSurface surface;
+ if (sur != null) {
+ surface = _eglCreateWindowSurface(dpy, config, sur, attrib_list, offset);
+ } else if (win instanceof SurfaceTexture) {
+ surface = _eglCreateWindowSurfaceTexture(dpy, config,
+ win, attrib_list, offset);
+ } else {
+ throw new java.lang.UnsupportedOperationException(
+ "eglCreateWindowSurface() can only be called with an instance of " +
+ "SurfaceView, SurfaceTexture or SurfaceHolder at the moment, " +
+ "this will be fixed later.");
+ }
+
+ return surface;
+ }
diff --git a/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.nativeReg b/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.nativeReg
new file mode 100644
index 0000000..c37d05b
--- /dev/null
+++ b/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.nativeReg
@@ -0,0 +1,2 @@
+{"_eglCreateWindowSurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;Ljava/lang/Object;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreateWindowSurface },
+{"_eglCreateWindowSurfaceTexture", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;Ljava/lang/Object;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreateWindowSurfaceTexture },
diff --git a/opengl/tools/glgen/stubs/egl/eglQueryString.cpp b/opengl/tools/glgen/stubs/egl/eglQueryString.cpp
new file mode 100644
index 0000000..625dad7
--- /dev/null
+++ b/opengl/tools/glgen/stubs/egl/eglQueryString.cpp
@@ -0,0 +1,10 @@
+/* const char * eglQueryString ( EGLDisplay dpy, EGLint name ) */
+static jstring
+android_eglQueryString__Landroind_opengl_EGLDisplay_2I
+ (JNIEnv *_env, jobject _this, jobject dpy, jint name) {
+ const char* chars = (const char*) eglQueryString(
+ (EGLDisplay)fromEGLHandle(_env, egldisplayGetHandleID, dpy),
+ (EGLint)name
+ );
+ return _env->NewStringUTF(chars);
+}
diff --git a/opengl/tools/glgen/stubs/egl/eglQueryString.java b/opengl/tools/glgen/stubs/egl/eglQueryString.java
new file mode 100644
index 0000000..f5d5a38
--- /dev/null
+++ b/opengl/tools/glgen/stubs/egl/eglQueryString.java
@@ -0,0 +1,6 @@
+ // C function const char * eglQueryString ( EGLDisplay dpy, EGLint name )
+
+ public static native String eglQueryString(
+ EGLDisplay dpy,
+ int name
+ );
diff --git a/opengl/tools/glgen/stubs/egl/eglQueryString.nativeReg b/opengl/tools/glgen/stubs/egl/eglQueryString.nativeReg
new file mode 100644
index 0000000..8276cdb
--- /dev/null
+++ b/opengl/tools/glgen/stubs/egl/eglQueryString.nativeReg
@@ -0,0 +1 @@
+{"eglQueryString", "(Landroid/opengl/EGLDisplay;I)Ljava/lang/String;", (void *) android_eglQueryString__Landroind_opengl_EGLDisplay_2I },
diff --git a/opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp
index 5d418d7..172c0e7 100644
--- a/opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp
+++ b/opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp
@@ -62,14 +62,12 @@ nativeClassInit(JNIEnv *_env, jclass glImplClass)
static void *
-getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
+getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining, jint *offset)
{
jint position;
jint limit;
jint elementSizeShift;
jlong pointer;
- jint offset;
- void *data;
position = _env->GetIntField(buffer, positionID);
limit = _env->GetIntField(buffer, limitID);
@@ -84,11 +82,10 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
getBaseArrayID, buffer);
- offset = _env->CallStaticIntMethod(nioAccessClass,
+ *offset = _env->CallStaticIntMethod(nioAccessClass,
getBaseArrayOffsetID, buffer);
- data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0);
- return (void *) ((char *) data + offset);
+ return NULL;
}
diff --git a/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp
index 35a3c33..4ef815b 100644
--- a/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp
+++ b/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp
@@ -74,14 +74,12 @@ nativeClassInit(JNIEnv *_env, jclass glImplClass)
}
static void *
-getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
+getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining, jint *offset)
{
jint position;
jint limit;
jint elementSizeShift;
jlong pointer;
- jint offset;
- void *data;
position = _env->GetIntField(buffer, positionID);
limit = _env->GetIntField(buffer, limitID);
@@ -96,11 +94,10 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
getBaseArrayID, buffer);
- offset = _env->CallStaticIntMethod(nioAccessClass,
+ *offset = _env->CallStaticIntMethod(nioAccessClass,
getBaseArrayOffsetID, buffer);
- data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0);
- return (void *) ((char *) data + offset);
+ return NULL;
}
static void
diff --git a/opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp
index 9b29a44..0df95f4 100644
--- a/opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp
+++ b/opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp
@@ -71,14 +71,12 @@ nativeClassInit(JNIEnv *_env, jclass glImplClass)
static void *
-getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
+getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining, jint *offset)
{
jint position;
jint limit;
jint elementSizeShift;
jlong pointer;
- jint offset;
- void *data;
position = _env->GetIntField(buffer, positionID);
limit = _env->GetIntField(buffer, limitID);
@@ -93,11 +91,9 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
getBaseArrayID, buffer);
- offset = _env->CallStaticIntMethod(nioAccessClass,
+ *offset = _env->CallStaticIntMethod(nioAccessClass,
getBaseArrayOffsetID, buffer);
- data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0);
-
- return (void *) ((char *) data + offset);
+ return NULL;
}
diff --git a/opengl/tools/glgen/stubs/gles11/GLES11cHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES11cHeader.cpp
index 823079f..dd860d5 100644
--- a/opengl/tools/glgen/stubs/gles11/GLES11cHeader.cpp
+++ b/opengl/tools/glgen/stubs/gles11/GLES11cHeader.cpp
@@ -69,14 +69,12 @@ nativeClassInit(JNIEnv *_env, jclass glImplClass)
static void *
-getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
+getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining, jint *offset)
{
jint position;
jint limit;
jint elementSizeShift;
jlong pointer;
- jint offset;
- void *data;
position = _env->GetIntField(buffer, positionID);
limit = _env->GetIntField(buffer, limitID);
@@ -91,11 +89,10 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
getBaseArrayID, buffer);
- offset = _env->CallStaticIntMethod(nioAccessClass,
+ *offset = _env->CallStaticIntMethod(nioAccessClass,
getBaseArrayOffsetID, buffer);
- data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0);
- return (void *) ((char *) data + offset);
+ return NULL;
}
diff --git a/opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp
index 13a2577..996f441 100644
--- a/opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp
+++ b/opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp
@@ -62,14 +62,12 @@ nativeClassInit(JNIEnv *_env, jclass glImplClass)
static void *
-getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
+getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining, jint *offset)
{
jint position;
jint limit;
jint elementSizeShift;
jlong pointer;
- jint offset;
- void *data;
position = _env->GetIntField(buffer, positionID);
limit = _env->GetIntField(buffer, limitID);
@@ -84,11 +82,10 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
getBaseArrayID, buffer);
- offset = _env->CallStaticIntMethod(nioAccessClass,
+ *offset = _env->CallStaticIntMethod(nioAccessClass,
getBaseArrayOffsetID, buffer);
- data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0);
- return (void *) ((char *) data + offset);
+ return NULL;
}
diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.cpp b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.cpp
new file mode 100644
index 0000000..27b91fc
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.cpp
@@ -0,0 +1,328 @@
+/* void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */
+static void
+android_glGetActiveAttrib__III_3II_3II_3II_3BI
+ (JNIEnv *_env, jobject _this, jint program, jint index, jint bufsize, jintArray length_ref, jint lengthOffset, jintArray size_ref, jint sizeOffset, jintArray type_ref, jint typeOffset, jbyteArray name_ref, jint nameOffset) {
+ jint _exception = 0;
+ const char * _exceptionType;
+ const char * _exceptionMessage;
+ GLsizei *length_base = (GLsizei *) 0;
+ jint _lengthRemaining;
+ GLsizei *length = (GLsizei *) 0;
+ GLint *size_base = (GLint *) 0;
+ jint _sizeRemaining;
+ GLint *size = (GLint *) 0;
+ GLenum *type_base = (GLenum *) 0;
+ jint _typeRemaining;
+ GLenum *type = (GLenum *) 0;
+ char *name_base = (char *) 0;
+ jint _nameRemaining;
+ char *name = (char *) 0;
+
+ if (!length_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "length == null";
+ goto exit;
+ }
+ if (lengthOffset < 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "lengthOffset < 0";
+ goto exit;
+ }
+ _lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset;
+ length_base = (GLsizei *)
+ _env->GetPrimitiveArrayCritical(length_ref, (jboolean *)0);
+ length = length_base + lengthOffset;
+
+ if (!size_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "size == null";
+ goto exit;
+ }
+ if (sizeOffset < 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "sizeOffset < 0";
+ goto exit;
+ }
+ _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset;
+ size_base = (GLint *)
+ _env->GetPrimitiveArrayCritical(size_ref, (jboolean *)0);
+ size = size_base + sizeOffset;
+
+ if (!type_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "type == null";
+ goto exit;
+ }
+ if (typeOffset < 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "typeOffset < 0";
+ goto exit;
+ }
+ _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset;
+ type_base = (GLenum *)
+ _env->GetPrimitiveArrayCritical(type_ref, (jboolean *)0);
+ type = type_base + typeOffset;
+
+ if (!name_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "name == null";
+ goto exit;
+ }
+ if (nameOffset < 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "nameOffset < 0";
+ goto exit;
+ }
+ _nameRemaining = _env->GetArrayLength(name_ref) - nameOffset;
+ name_base = (char *)
+ _env->GetPrimitiveArrayCritical(name_ref, (jboolean *)0);
+ name = name_base + nameOffset;
+
+ glGetActiveAttrib(
+ (GLuint)program,
+ (GLuint)index,
+ (GLsizei)bufsize,
+ (GLsizei *)length,
+ (GLint *)size,
+ (GLenum *)type,
+ (char *)name
+ );
+
+exit:
+ if (name_base) {
+ _env->ReleasePrimitiveArrayCritical(name_ref, name_base,
+ _exception ? JNI_ABORT: 0);
+ }
+ if (type_base) {
+ _env->ReleasePrimitiveArrayCritical(type_ref, type_base,
+ _exception ? JNI_ABORT: 0);
+ }
+ if (size_base) {
+ _env->ReleasePrimitiveArrayCritical(size_ref, size_base,
+ _exception ? JNI_ABORT: 0);
+ }
+ if (length_base) {
+ _env->ReleasePrimitiveArrayCritical(length_ref, length_base,
+ _exception ? JNI_ABORT: 0);
+ }
+ if (_exception) {
+ jniThrowException(_env, _exceptionType, _exceptionMessage);
+ }
+}
+
+/* void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */
+static void
+android_glGetActiveAttrib__IIILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2B
+ (JNIEnv *_env, jobject _this, jint program, jint index, jint bufsize, jobject length_buf, jobject size_buf, jobject type_buf, jbyte name) {
+ jarray _lengthArray = (jarray) 0;
+ jint _lengthBufferOffset = (jint) 0;
+ jarray _sizeArray = (jarray) 0;
+ jint _sizeBufferOffset = (jint) 0;
+ jarray _typeArray = (jarray) 0;
+ jint _typeBufferOffset = (jint) 0;
+ jint _lengthRemaining;
+ GLsizei *length = (GLsizei *) 0;
+ jint _sizeRemaining;
+ GLint *size = (GLint *) 0;
+ jint _typeRemaining;
+ GLenum *type = (GLenum *) 0;
+
+ length = (GLsizei *)getPointer(_env, length_buf, &_lengthArray, &_lengthRemaining, &_lengthBufferOffset);
+ size = (GLint *)getPointer(_env, size_buf, &_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
+ type = (GLenum *)getPointer(_env, type_buf, &_typeArray, &_typeRemaining, &_typeBufferOffset);
+ if (length == NULL) {
+ char * _lengthBase = (char *)_env->GetPrimitiveArrayCritical(_lengthArray, (jboolean *) 0);
+ length = (GLsizei *) (_lengthBase + _lengthBufferOffset);
+ }
+ if (size == NULL) {
+ char * _sizeBase = (char *)_env->GetPrimitiveArrayCritical(_sizeArray, (jboolean *) 0);
+ size = (GLint *) (_sizeBase + _sizeBufferOffset);
+ }
+ if (type == NULL) {
+ char * _typeBase = (char *)_env->GetPrimitiveArrayCritical(_typeArray, (jboolean *) 0);
+ type = (GLenum *) (_typeBase + _typeBufferOffset);
+ }
+ glGetActiveAttrib(
+ (GLuint)program,
+ (GLuint)index,
+ (GLsizei)bufsize,
+ (GLsizei *)length,
+ (GLint *)size,
+ (GLenum *)type,
+ (char *)name
+ );
+ if (_typeArray) {
+ releasePointer(_env, _typeArray, type, JNI_TRUE);
+ }
+ if (_sizeArray) {
+ releasePointer(_env, _sizeArray, size, JNI_TRUE);
+ }
+ if (_lengthArray) {
+ releasePointer(_env, _lengthArray, length, JNI_TRUE);
+ }
+}
+
+/* void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */
+static jstring
+android_glGetActiveAttrib1
+ (JNIEnv *_env, jobject _this, jint program, jint index, jintArray size_ref, jint sizeOffset, jintArray type_ref, jint typeOffset) {
+ jint _exception = 0;
+ const char * _exceptionType;
+ const char * _exceptionMessage;
+ GLint *size_base = (GLint *) 0;
+ jint _sizeRemaining;
+ GLint *size = (GLint *) 0;
+ GLenum *type_base = (GLenum *) 0;
+ jint _typeRemaining;
+ GLenum *type = (GLenum *) 0;
+
+ jstring result = 0;
+
+ GLint len = 0;
+ glGetProgramiv((GLuint)program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &len);
+ if (!len) {
+ return _env->NewStringUTF("");
+ }
+ char* buf = (char*) malloc(len);
+
+ if (buf == NULL) {
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory");
+ return NULL;
+ }
+ if (!size_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "size == null";
+ goto exit;
+ }
+ if (sizeOffset < 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "sizeOffset < 0";
+ goto exit;
+ }
+ _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset;
+ size_base = (GLint *)
+ _env->GetPrimitiveArrayCritical(size_ref, (jboolean *)0);
+ size = size_base + sizeOffset;
+
+ if (!type_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "type == null";
+ goto exit;
+ }
+ if (typeOffset < 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "typeOffset < 0";
+ goto exit;
+ }
+ _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset;
+ type_base = (GLenum *)
+ _env->GetPrimitiveArrayCritical(type_ref, (jboolean *)0);
+ type = type_base + typeOffset;
+
+ glGetActiveAttrib(
+ (GLuint)program,
+ (GLuint)index,
+ (GLsizei)len,
+ NULL,
+ (GLint *)size,
+ (GLenum *)type,
+ (char *)buf
+ );
+exit:
+ if (type_base) {
+ _env->ReleasePrimitiveArrayCritical(type_ref, type_base,
+ _exception ? JNI_ABORT: 0);
+ }
+ if (size_base) {
+ _env->ReleasePrimitiveArrayCritical(size_ref, size_base,
+ _exception ? JNI_ABORT: 0);
+ }
+ if (_exception != 1) {
+ result = _env->NewStringUTF(buf);
+ }
+ if (buf) {
+ free(buf);
+ }
+ if (_exception) {
+ jniThrowException(_env, _exceptionType, _exceptionMessage);
+ }
+ if (result == 0) {
+ result = _env->NewStringUTF("");
+ }
+
+ return result;
+}
+
+/* void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */
+static jstring
+android_glGetActiveAttrib2
+ (JNIEnv *_env, jobject _this, jint program, jint index, jobject size_buf, jobject type_buf) {
+ jarray _sizeArray = (jarray) 0;
+ jint _sizeBufferOffset = (jint) 0;
+ jarray _typeArray = (jarray) 0;
+ jint _typeBufferOffset = (jint) 0;
+ jint _lengthRemaining;
+ GLsizei *length = (GLsizei *) 0;
+ jint _sizeRemaining;
+ GLint *size = (GLint *) 0;
+ jint _typeRemaining;
+ GLenum *type = (GLenum *) 0;
+
+ jstring result = 0;
+
+ GLint len = 0;
+ glGetProgramiv((GLuint)program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &len);
+ if (!len) {
+ return _env->NewStringUTF("");
+ }
+ char* buf = (char*) malloc(len);
+
+ if (buf == NULL) {
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory");
+ return NULL;
+ }
+
+ size = (GLint *)getPointer(_env, size_buf, &_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
+ type = (GLenum *)getPointer(_env, type_buf, &_typeArray, &_typeRemaining, &_typeBufferOffset);
+ if (size == NULL) {
+ char * _sizeBase = (char *)_env->GetPrimitiveArrayCritical(_sizeArray, (jboolean *) 0);
+ size = (GLint *) (_sizeBase + _sizeBufferOffset);
+ }
+ if (type == NULL) {
+ char * _typeBase = (char *)_env->GetPrimitiveArrayCritical(_typeArray, (jboolean *) 0);
+ type = (GLenum *) (_typeBase + _typeBufferOffset);
+ }
+ glGetActiveAttrib(
+ (GLuint)program,
+ (GLuint)index,
+ (GLsizei)len,
+ NULL,
+ (GLint *)size,
+ (GLenum *)type,
+ (char *)buf
+ );
+
+ if (_typeArray) {
+ releasePointer(_env, _typeArray, type, JNI_TRUE);
+ }
+ if (_sizeArray) {
+ releasePointer(_env, _sizeArray, size, JNI_TRUE);
+ }
+ result = _env->NewStringUTF(buf);
+ if (buf) {
+ free(buf);
+ }
+ return result;
+}
diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.java b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.java
new file mode 100644
index 0000000..bad2137
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.java
@@ -0,0 +1,47 @@
+ // C function void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name )
+
+ public static native void glGetActiveAttrib(
+ int program,
+ int index,
+ int bufsize,
+ int[] length,
+ int lengthOffset,
+ int[] size,
+ int sizeOffset,
+ int[] type,
+ int typeOffset,
+ byte[] name,
+ int nameOffset
+ );
+
+ // C function void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name )
+
+ public static native void glGetActiveAttrib(
+ int program,
+ int index,
+ int bufsize,
+ java.nio.IntBuffer length,
+ java.nio.IntBuffer size,
+ java.nio.IntBuffer type,
+ byte name
+ );
+
+ // C function void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name )
+
+ public static native String glGetActiveAttrib(
+ int program,
+ int index,
+ int[] size,
+ int sizeOffset,
+ int[] type,
+ int typeOffset
+ );
+
+ // C function void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name )
+
+ public static native String glGetActiveAttrib(
+ int program,
+ int index,
+ java.nio.IntBuffer size,
+ java.nio.IntBuffer type
+ );
diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.nativeReg b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.nativeReg
new file mode 100644
index 0000000..f54c0a0
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.nativeReg
@@ -0,0 +1,4 @@
+{"glGetActiveAttrib", "(III[II[II[II[BI)V", (void *) android_glGetActiveAttrib__III_3II_3II_3II_3BI },
+{"glGetActiveAttrib", "(IIILjava/nio/IntBuffer;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;B)V", (void *) android_glGetActiveAttrib__IIILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2B },
+{"glGetActiveAttrib", "(II[II[II)Ljava/lang/String;", (void *) android_glGetActiveAttrib1 },
+{"glGetActiveAttrib", "(IILjava/nio/IntBuffer;Ljava/nio/IntBuffer;)Ljava/lang/String;", (void *) android_glGetActiveAttrib2 },
diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.cpp b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.cpp
new file mode 100644
index 0000000..58f704c
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.cpp
@@ -0,0 +1,329 @@
+/* void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */
+static void
+android_glGetActiveUniform__III_3II_3II_3II_3BI
+ (JNIEnv *_env, jobject _this, jint program, jint index, jint bufsize, jintArray length_ref, jint lengthOffset, jintArray size_ref, jint sizeOffset, jintArray type_ref, jint typeOffset, jbyteArray name_ref, jint nameOffset) {
+ jint _exception = 0;
+ const char * _exceptionType;
+ const char * _exceptionMessage;
+ GLsizei *length_base = (GLsizei *) 0;
+ jint _lengthRemaining;
+ GLsizei *length = (GLsizei *) 0;
+ GLint *size_base = (GLint *) 0;
+ jint _sizeRemaining;
+ GLint *size = (GLint *) 0;
+ GLenum *type_base = (GLenum *) 0;
+ jint _typeRemaining;
+ GLenum *type = (GLenum *) 0;
+ char *name_base = (char *) 0;
+ jint _nameRemaining;
+ char *name = (char *) 0;
+
+ if (!length_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "length == null";
+ goto exit;
+ }
+ if (lengthOffset < 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "lengthOffset < 0";
+ goto exit;
+ }
+ _lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset;
+ length_base = (GLsizei *)
+ _env->GetPrimitiveArrayCritical(length_ref, (jboolean *)0);
+ length = length_base + lengthOffset;
+
+ if (!size_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "size == null";
+ goto exit;
+ }
+ if (sizeOffset < 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "sizeOffset < 0";
+ goto exit;
+ }
+ _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset;
+ size_base = (GLint *)
+ _env->GetPrimitiveArrayCritical(size_ref, (jboolean *)0);
+ size = size_base + sizeOffset;
+
+ if (!type_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "type == null";
+ goto exit;
+ }
+ if (typeOffset < 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "typeOffset < 0";
+ goto exit;
+ }
+ _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset;
+ type_base = (GLenum *)
+ _env->GetPrimitiveArrayCritical(type_ref, (jboolean *)0);
+ type = type_base + typeOffset;
+
+ if (!name_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "name == null";
+ goto exit;
+ }
+ if (nameOffset < 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "nameOffset < 0";
+ goto exit;
+ }
+ _nameRemaining = _env->GetArrayLength(name_ref) - nameOffset;
+ name_base = (char *)
+ _env->GetPrimitiveArrayCritical(name_ref, (jboolean *)0);
+ name = name_base + nameOffset;
+
+ glGetActiveUniform(
+ (GLuint)program,
+ (GLuint)index,
+ (GLsizei)bufsize,
+ (GLsizei *)length,
+ (GLint *)size,
+ (GLenum *)type,
+ (char *)name
+ );
+
+exit:
+ if (name_base) {
+ _env->ReleasePrimitiveArrayCritical(name_ref, name_base,
+ _exception ? JNI_ABORT: 0);
+ }
+ if (type_base) {
+ _env->ReleasePrimitiveArrayCritical(type_ref, type_base,
+ _exception ? JNI_ABORT: 0);
+ }
+ if (size_base) {
+ _env->ReleasePrimitiveArrayCritical(size_ref, size_base,
+ _exception ? JNI_ABORT: 0);
+ }
+ if (length_base) {
+ _env->ReleasePrimitiveArrayCritical(length_ref, length_base,
+ _exception ? JNI_ABORT: 0);
+ }
+ if (_exception) {
+ jniThrowException(_env, _exceptionType, _exceptionMessage);
+ }
+}
+
+/* void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */
+static void
+android_glGetActiveUniform__IIILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2B
+ (JNIEnv *_env, jobject _this, jint program, jint index, jint bufsize, jobject length_buf, jobject size_buf, jobject type_buf, jbyte name) {
+ jarray _lengthArray = (jarray) 0;
+ jint _lengthBufferOffset = (jint) 0;
+ jarray _sizeArray = (jarray) 0;
+ jint _sizeBufferOffset = (jint) 0;
+ jarray _typeArray = (jarray) 0;
+ jint _typeBufferOffset = (jint) 0;
+ jint _lengthRemaining;
+ GLsizei *length = (GLsizei *) 0;
+ jint _sizeRemaining;
+ GLint *size = (GLint *) 0;
+ jint _typeRemaining;
+ GLenum *type = (GLenum *) 0;
+
+ length = (GLsizei *)getPointer(_env, length_buf, &_lengthArray, &_lengthRemaining, &_lengthBufferOffset);
+ size = (GLint *)getPointer(_env, size_buf, &_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
+ type = (GLenum *)getPointer(_env, type_buf, &_typeArray, &_typeRemaining, &_typeBufferOffset);
+ if (length == NULL) {
+ char * _lengthBase = (char *)_env->GetPrimitiveArrayCritical(_lengthArray, (jboolean *) 0);
+ length = (GLsizei *) (_lengthBase + _lengthBufferOffset);
+ }
+ if (size == NULL) {
+ char * _sizeBase = (char *)_env->GetPrimitiveArrayCritical(_sizeArray, (jboolean *) 0);
+ size = (GLint *) (_sizeBase + _sizeBufferOffset);
+ }
+ if (type == NULL) {
+ char * _typeBase = (char *)_env->GetPrimitiveArrayCritical(_typeArray, (jboolean *) 0);
+ type = (GLenum *) (_typeBase + _typeBufferOffset);
+ }
+ glGetActiveUniform(
+ (GLuint)program,
+ (GLuint)index,
+ (GLsizei)bufsize,
+ (GLsizei *)length,
+ (GLint *)size,
+ (GLenum *)type,
+ (char *)name
+ );
+ if (_typeArray) {
+ releasePointer(_env, _typeArray, type, JNI_TRUE);
+ }
+ if (_sizeArray) {
+ releasePointer(_env, _sizeArray, size, JNI_TRUE);
+ }
+ if (_lengthArray) {
+ releasePointer(_env, _lengthArray, length, JNI_TRUE);
+ }
+}
+
+/* void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */
+static jstring
+android_glGetActiveUniform1
+ (JNIEnv *_env, jobject _this, jint program, jint index, jintArray size_ref, jint sizeOffset, jintArray type_ref, jint typeOffset) {
+ jint _exception = 0;
+ const char * _exceptionType;
+ const char * _exceptionMessage;
+
+ GLint *size_base = (GLint *) 0;
+ jint _sizeRemaining;
+ GLint *size = (GLint *) 0;
+
+ GLenum *type_base = (GLenum *) 0;
+ jint _typeRemaining;
+ GLenum *type = (GLenum *) 0;
+
+ jstring result = 0;
+
+ GLint len = 0;
+ glGetProgramiv((GLuint)program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &len);
+ if (!len) {
+ return _env->NewStringUTF("");
+ }
+ char* buf = (char*) malloc(len);
+
+ if (buf == NULL) {
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory");
+ return NULL;
+ }
+
+ if (!size_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "size == null";
+ goto exit;
+ }
+ if (sizeOffset < 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "sizeOffset < 0";
+ goto exit;
+ }
+ _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset;
+ size_base = (GLint *)
+ _env->GetPrimitiveArrayCritical(size_ref, (jboolean *)0);
+ size = size_base + sizeOffset;
+
+ if (!type_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "type == null";
+ goto exit;
+ }
+ if (typeOffset < 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "typeOffset < 0";
+ goto exit;
+ }
+ _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset;
+ type_base = (GLenum *)
+ _env->GetPrimitiveArrayCritical(type_ref, (jboolean *)0);
+ type = type_base + typeOffset;
+
+ glGetActiveUniform(
+ (GLuint)program,
+ (GLuint)index,
+ (GLsizei)len,
+ NULL,
+ (GLint *)size,
+ (GLenum *)type,
+ (char *)buf
+ );
+
+exit:
+ if (type_base) {
+ _env->ReleasePrimitiveArrayCritical(type_ref, type_base,
+ _exception ? JNI_ABORT: 0);
+ }
+ if (size_base) {
+ _env->ReleasePrimitiveArrayCritical(size_ref, size_base,
+ _exception ? JNI_ABORT: 0);
+ }
+ if (_exception != 1) {
+ result = _env->NewStringUTF(buf);
+ }
+ if (buf) {
+ free(buf);
+ }
+ if (_exception) {
+ jniThrowException(_env, _exceptionType, _exceptionMessage);
+ }
+ if (result == 0) {
+ result = _env->NewStringUTF("");
+ }
+ return result;
+}
+
+/* void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */
+static jstring
+android_glGetActiveUniform2
+ (JNIEnv *_env, jobject _this, jint program, jint index, jobject size_buf, jobject type_buf) {
+ jarray _sizeArray = (jarray) 0;
+ jint _sizeBufferOffset = (jint) 0;
+ jarray _typeArray = (jarray) 0;
+ jint _typeBufferOffset = (jint) 0;
+ jint _sizeRemaining;
+ GLint *size = (GLint *) 0;
+ jint _typeRemaining;
+ GLenum *type = (GLenum *) 0;
+
+ jstring result = 0;
+ GLint len = 0;
+ glGetProgramiv((GLuint)program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &len);
+ if (!len) {
+ return _env->NewStringUTF("");
+ }
+ char* buf = (char*) malloc(len);
+
+ if (buf == NULL) {
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory");
+ return NULL;
+ }
+
+ size = (GLint *)getPointer(_env, size_buf, &_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
+ type = (GLenum *)getPointer(_env, type_buf, &_typeArray, &_typeRemaining, &_typeBufferOffset);
+
+ if (size == NULL) {
+ char * _sizeBase = (char *)_env->GetPrimitiveArrayCritical(_sizeArray, (jboolean *) 0);
+ size = (GLint *) (_sizeBase + _sizeBufferOffset);
+ }
+ if (type == NULL) {
+ char * _typeBase = (char *)_env->GetPrimitiveArrayCritical(_typeArray, (jboolean *) 0);
+ type = (GLenum *) (_typeBase + _typeBufferOffset);
+ }
+ glGetActiveUniform(
+ (GLuint)program,
+ (GLuint)index,
+ len,
+ NULL,
+ (GLint *)size,
+ (GLenum *)type,
+ (char *)buf
+ );
+
+ if (_typeArray) {
+ releasePointer(_env, _typeArray, type, JNI_TRUE);
+ }
+ if (_sizeArray) {
+ releasePointer(_env, _sizeArray, size, JNI_TRUE);
+ }
+ result = _env->NewStringUTF(buf);
+ if (buf) {
+ free(buf);
+ }
+ return result;
+}
diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.java b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.java
new file mode 100644
index 0000000..28aaa78
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.java
@@ -0,0 +1,46 @@
+ // C function void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name )
+
+ public static native void glGetActiveUniform(
+ int program,
+ int index,
+ int bufsize,
+ int[] length,
+ int lengthOffset,
+ int[] size,
+ int sizeOffset,
+ int[] type,
+ int typeOffset,
+ byte[] name,
+ int nameOffset
+ );
+
+ // C function void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name )
+
+ public static native void glGetActiveUniform(
+ int program,
+ int index,
+ int bufsize,
+ java.nio.IntBuffer length,
+ java.nio.IntBuffer size,
+ java.nio.IntBuffer type,
+ byte name
+ );
+ // C function void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name )
+
+ public static native String glGetActiveUniform(
+ int program,
+ int index,
+ int[] size,
+ int sizeOffset,
+ int[] type,
+ int typeOffset
+ );
+
+ // C function void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name )
+
+ public static native String glGetActiveUniform(
+ int program,
+ int index,
+ java.nio.IntBuffer size,
+ java.nio.IntBuffer type
+ );
diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.nativeReg b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.nativeReg
new file mode 100644
index 0000000..f0b5fd9
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.nativeReg
@@ -0,0 +1,4 @@
+{"glGetActiveUniform", "(III[II[II[II[BI)V", (void *) android_glGetActiveUniform__III_3II_3II_3II_3BI },
+{"glGetActiveUniform", "(II[II[II)Ljava/lang/String;", (void *) android_glGetActiveUniform1 },
+{"glGetActiveUniform", "(IIILjava/nio/IntBuffer;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;B)V", (void *) android_glGetActiveUniform__IIILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2B },
+{"glGetActiveUniform", "(IILjava/nio/IntBuffer;Ljava/nio/IntBuffer;)Ljava/lang/String;", (void *) android_glGetActiveUniform2 },
diff --git a/opengl/tools/glgen/stubs/gles11/glGetShaderSource.cpp b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.cpp
new file mode 100644
index 0000000..a7e1cd2
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.cpp
@@ -0,0 +1,111 @@
+/* void glGetShaderSource ( GLuint shader, GLsizei bufsize, GLsizei *length, char *source ) */
+static void
+android_glGetShaderSource__II_3II_3BI
+ (JNIEnv *_env, jobject _this, jint shader, jint bufsize, jintArray length_ref, jint lengthOffset, jbyteArray source_ref, jint sourceOffset) {
+ jint _exception = 0;
+ const char * _exceptionType;
+ const char * _exceptionMessage;
+ GLsizei *length_base = (GLsizei *) 0;
+ jint _lengthRemaining;
+ GLsizei *length = (GLsizei *) 0;
+ char *source_base = (char *) 0;
+ jint _sourceRemaining;
+ char *source = (char *) 0;
+
+ if (!length_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "length == null";
+ goto exit;
+ }
+ if (lengthOffset < 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "lengthOffset < 0";
+ goto exit;
+ }
+ _lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset;
+ length_base = (GLsizei *)
+ _env->GetPrimitiveArrayCritical(length_ref, (jboolean *)0);
+ length = length_base + lengthOffset;
+
+ if (!source_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "source == null";
+ goto exit;
+ }
+ if (sourceOffset < 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "sourceOffset < 0";
+ goto exit;
+ }
+ _sourceRemaining = _env->GetArrayLength(source_ref) - sourceOffset;
+ source_base = (char *)
+ _env->GetPrimitiveArrayCritical(source_ref, (jboolean *)0);
+ source = source_base + sourceOffset;
+
+ glGetShaderSource(
+ (GLuint)shader,
+ (GLsizei)bufsize,
+ (GLsizei *)length,
+ (char *)source
+ );
+
+exit:
+ if (source_base) {
+ _env->ReleasePrimitiveArrayCritical(source_ref, source_base,
+ _exception ? JNI_ABORT: 0);
+ }
+ if (length_base) {
+ _env->ReleasePrimitiveArrayCritical(length_ref, length_base,
+ _exception ? JNI_ABORT: 0);
+ }
+ if (_exception) {
+ jniThrowException(_env, _exceptionType, _exceptionMessage);
+ }
+}
+
+/* void glGetShaderSource ( GLuint shader, GLsizei bufsize, GLsizei *length, char *source ) */
+static void
+android_glGetShaderSource__IILjava_nio_IntBuffer_2B
+ (JNIEnv *_env, jobject _this, jint shader, jint bufsize, jobject length_buf, jbyte source) {
+ jarray _array = (jarray) 0;
+ jint _bufferOffset = (jint) 0;
+ jint _remaining;
+ GLsizei *length = (GLsizei *) 0;
+
+ length = (GLsizei *)getPointer(_env, length_buf, &_array, &_remaining, &_bufferOffset);
+ if (length == NULL) {
+ char * _lengthBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
+ length = (GLsizei *) (_lengthBase + _bufferOffset);
+ }
+ glGetShaderSource(
+ (GLuint)shader,
+ (GLsizei)bufsize,
+ (GLsizei *)length,
+ (char *)source
+ );
+ if (_array) {
+ releasePointer(_env, _array, length, JNI_TRUE);
+ }
+}
+
+/* void glGetShaderSource ( GLuint shader, GLsizei bufsize, GLsizei *length, char *source ) */
+static jstring android_glGetShaderSource(JNIEnv *_env, jobject, jint shader) {
+ GLint shaderLen = 0;
+ glGetShaderiv((GLuint)shader, GL_SHADER_SOURCE_LENGTH, &shaderLen);
+ if (!shaderLen) {
+ return _env->NewStringUTF("");
+ }
+ char* buf = (char*) malloc(shaderLen);
+ if (buf == NULL) {
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory");
+ return NULL;
+ }
+ glGetShaderSource(shader, shaderLen, NULL, buf);
+ jstring result = _env->NewStringUTF(buf);
+ free(buf);
+ return result;
+}
diff --git a/opengl/tools/glgen/stubs/gles11/glGetShaderSource.java b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.java
new file mode 100644
index 0000000..199d93a
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.java
@@ -0,0 +1,25 @@
+ // C function void glGetShaderSource ( GLuint shader, GLsizei bufsize, GLsizei *length, char *source )
+
+ public static native void glGetShaderSource(
+ int shader,
+ int bufsize,
+ int[] length,
+ int lengthOffset,
+ byte[] source,
+ int sourceOffset
+ );
+
+ // C function void glGetShaderSource ( GLuint shader, GLsizei bufsize, GLsizei *length, char *source )
+
+ public static native void glGetShaderSource(
+ int shader,
+ int bufsize,
+ java.nio.IntBuffer length,
+ byte source
+ );
+
+ // C function void glGetShaderSource ( GLuint shader, GLsizei bufsize, GLsizei *length, char *source )
+
+ public static native String glGetShaderSource(
+ int shader
+ );
diff --git a/opengl/tools/glgen/stubs/gles11/glGetShaderSource.nativeReg b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.nativeReg
new file mode 100644
index 0000000..acb47a5
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.nativeReg
@@ -0,0 +1,3 @@
+{"glGetShaderSource", "(II[II[BI)V", (void *) android_glGetShaderSource__II_3II_3BI },
+{"glGetShaderSource", "(IILjava/nio/IntBuffer;B)V", (void *) android_glGetShaderSource__IILjava_nio_IntBuffer_2B },
+{"glGetShaderSource", "(I)Ljava/lang/String;", (void *) android_glGetShaderSource },
diff --git a/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp b/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp
index f7315ee..cc10336 100644
--- a/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp
+++ b/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp
@@ -113,14 +113,12 @@ nativeClassInit(JNIEnv *_env, jclass glImplClass)
}
static void *
-getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
+getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining, jint *offset)
{
jint position;
jint limit;
jint elementSizeShift;
jlong pointer;
- jint offset;
- void *data;
position = _env->GetIntField(buffer, positionID);
limit = _env->GetIntField(buffer, limitID);
@@ -138,11 +136,10 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
if (*array == NULL) {
return (void*) NULL;
}
- offset = _env->CallStaticIntMethod(nioAccessClass,
+ *offset = _env->CallStaticIntMethod(nioAccessClass,
getBaseArrayOffsetID, buffer);
- data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0);
- return (void *) ((char *) data + offset);
+ return NULL;
}
static void
@@ -180,10 +177,12 @@ getDirectBufferPointer(JNIEnv *_env, jobject buffer) {
if (allowIndirectBuffers(_env)) {
jarray array = 0;
jint remaining;
- buf = getPointer(_env, buffer, &array, &remaining);
+ jint offset;
+ buf = getPointer(_env, buffer, &array, &remaining, &offset);
if (array) {
releasePointer(_env, array, buf, 0);
}
+ buf = buf + offset;
} else {
jniThrowException(_env, "java/lang/IllegalArgumentException",
"Must use a native order direct Buffer");
diff --git a/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl b/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl
index cd730aa..e3aea76 100644
--- a/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl
+++ b/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl
@@ -22,6 +22,7 @@ import android.app.AppGlobals;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.os.Build;
+import android.os.UserId;
import android.util.Log;
import java.nio.Buffer;
@@ -66,7 +67,7 @@ public class GLImpl implements GL10, GL10Ext, GL11, GL11Ext, GL11ExtensionPack {
int version = 0;
IPackageManager pm = AppGlobals.getPackageManager();
try {
- ApplicationInfo applicationInfo = pm.getApplicationInfo(appName, 0);
+ ApplicationInfo applicationInfo = pm.getApplicationInfo(appName, 0, UserId.myUserId());
if (applicationInfo != null) {
version = applicationInfo.targetSdkVersion;
}