• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 **
3 ** Copyright 2009, The Android Open Source Project
4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
8 **
9 **     http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17 
18 // This source file is automatically generated
19 
20 #pragma GCC diagnostic ignored "-Wunused-variable"
21 #pragma GCC diagnostic ignored "-Wunused-function"
22 
23 #include <GLES/gl.h>
24 #include <GLES/glext.h>
25 
26 #include <jni.h>
27 #include <nativehelper/JNIPlatformHelp.h>
28 #include <android_runtime/AndroidRuntime.h>
29 #include <utils/misc.h>
30 #include <assert.h>
31 
32 
33 /* special calls implemented in Android's GLES wrapper used to more
34  * efficiently bound-check passed arrays */
35 extern "C" {
36 #ifdef GL_VERSION_ES_CM_1_1
37 GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
38         const GLvoid *ptr, GLsizei count);
39 GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride,
40         const GLvoid *pointer, GLsizei count);
41 GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type,
42         GLsizei stride, const GLvoid *pointer, GLsizei count);
43 GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type,
44         GLsizei stride, const GLvoid *pointer, GLsizei count);
45 GL_API void GL_APIENTRY glPointSizePointerOESBounds(GLenum type,
46         GLsizei stride, const GLvoid *pointer, GLsizei count);
47 GL_API void GL_APIENTRY glMatrixIndexPointerOESBounds(GLint size, GLenum type,
48         GLsizei stride, const GLvoid *pointer, GLsizei count);
49 GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type,
50         GLsizei stride, const GLvoid *pointer, GLsizei count);
51 #endif
52 #ifdef GL_ES_VERSION_2_0
glVertexAttribPointerBounds(GLuint indx,GLint size,GLenum type,GLboolean normalized,GLsizei stride,const GLvoid * pointer,GLsizei count)53 static void glVertexAttribPointerBounds(GLuint indx, GLint size, GLenum type,
54         GLboolean normalized, GLsizei stride, const GLvoid *pointer, GLsizei count) {
55     glVertexAttribPointer(indx, size, type, normalized, stride, pointer);
56 }
57 #endif
58 #ifdef GL_ES_VERSION_3_0
glVertexAttribIPointerBounds(GLuint indx,GLint size,GLenum type,GLsizei stride,const GLvoid * pointer,GLsizei count)59 static void glVertexAttribIPointerBounds(GLuint indx, GLint size, GLenum type,
60         GLsizei stride, const GLvoid *pointer, GLsizei count) {
61     glVertexAttribIPointer(indx, size, type, stride, pointer);
62 }
63 #endif
64 }
65 
66 static void
nativeClassInit(JNIEnv * _env,jclass glImplClass)67 nativeClassInit(JNIEnv *_env, jclass glImplClass)
68 {
69 }
70 
71 static void *
getPointer(JNIEnv * _env,jobject buffer,jarray * array,jint * remaining,jint * offset)72 getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining, jint *offset)
73 {
74     jint position;
75     jint limit;
76     jint elementSizeShift;
77     jlong pointer;
78 
79     pointer = jniGetNioBufferFields(_env, buffer, &position, &limit, &elementSizeShift);
80     *remaining = (limit - position) << elementSizeShift;
81     if (pointer != 0L) {
82         *array = nullptr;
83         pointer += position << elementSizeShift;
84         return reinterpret_cast<void*>(pointer);
85     }
86 
87     *array = jniGetNioBufferBaseArray(_env, buffer);
88     *offset = jniGetNioBufferBaseArrayOffset(_env, buffer);
89     return nullptr;
90 }
91 
92 class ByteArrayGetter {
93 public:
Get(JNIEnv * _env,jbyteArray array,jboolean * is_copy)94     static void* Get(JNIEnv* _env, jbyteArray array, jboolean* is_copy) {
95         return _env->GetByteArrayElements(array, is_copy);
96     }
97 };
98 class BooleanArrayGetter {
99 public:
Get(JNIEnv * _env,jbooleanArray array,jboolean * is_copy)100     static void* Get(JNIEnv* _env, jbooleanArray array, jboolean* is_copy) {
101         return _env->GetBooleanArrayElements(array, is_copy);
102     }
103 };
104 class CharArrayGetter {
105 public:
Get(JNIEnv * _env,jcharArray array,jboolean * is_copy)106     static void* Get(JNIEnv* _env, jcharArray array, jboolean* is_copy) {
107         return _env->GetCharArrayElements(array, is_copy);
108     }
109 };
110 class ShortArrayGetter {
111 public:
Get(JNIEnv * _env,jshortArray array,jboolean * is_copy)112     static void* Get(JNIEnv* _env, jshortArray array, jboolean* is_copy) {
113         return _env->GetShortArrayElements(array, is_copy);
114     }
115 };
116 class IntArrayGetter {
117 public:
Get(JNIEnv * _env,jintArray array,jboolean * is_copy)118     static void* Get(JNIEnv* _env, jintArray array, jboolean* is_copy) {
119         return _env->GetIntArrayElements(array, is_copy);
120     }
121 };
122 class LongArrayGetter {
123 public:
Get(JNIEnv * _env,jlongArray array,jboolean * is_copy)124     static void* Get(JNIEnv* _env, jlongArray array, jboolean* is_copy) {
125         return _env->GetLongArrayElements(array, is_copy);
126     }
127 };
128 class FloatArrayGetter {
129 public:
Get(JNIEnv * _env,jfloatArray array,jboolean * is_copy)130     static void* Get(JNIEnv* _env, jfloatArray array, jboolean* is_copy) {
131         return _env->GetFloatArrayElements(array, is_copy);
132     }
133 };
134 class DoubleArrayGetter {
135 public:
Get(JNIEnv * _env,jdoubleArray array,jboolean * is_copy)136     static void* Get(JNIEnv* _env, jdoubleArray array, jboolean* is_copy) {
137         return _env->GetDoubleArrayElements(array, is_copy);
138     }
139 };
140 
141 template<typename JTYPEARRAY, typename ARRAYGETTER>
142 static void*
getArrayPointer(JNIEnv * _env,JTYPEARRAY array,jboolean * is_copy)143 getArrayPointer(JNIEnv *_env, JTYPEARRAY array, jboolean* is_copy) {
144     return ARRAYGETTER::Get(_env, array, is_copy);
145 }
146 
147 class ByteArrayReleaser {
148 public:
Release(JNIEnv * _env,jbyteArray array,jbyte * data,jboolean commit)149     static void Release(JNIEnv* _env, jbyteArray array, jbyte* data, jboolean commit) {
150         _env->ReleaseByteArrayElements(array, data, commit ? 0 : JNI_ABORT);
151     }
152 };
153 class BooleanArrayReleaser {
154 public:
Release(JNIEnv * _env,jbooleanArray array,jboolean * data,jboolean commit)155     static void Release(JNIEnv* _env, jbooleanArray array, jboolean* data, jboolean commit) {
156         _env->ReleaseBooleanArrayElements(array, data, commit ? 0 : JNI_ABORT);
157     }
158 };
159 class CharArrayReleaser {
160 public:
Release(JNIEnv * _env,jcharArray array,jchar * data,jboolean commit)161     static void Release(JNIEnv* _env, jcharArray array, jchar* data, jboolean commit) {
162         _env->ReleaseCharArrayElements(array, data, commit ? 0 : JNI_ABORT);
163     }
164 };
165 class ShortArrayReleaser {
166 public:
Release(JNIEnv * _env,jshortArray array,jshort * data,jboolean commit)167     static void Release(JNIEnv* _env, jshortArray array, jshort* data, jboolean commit) {
168         _env->ReleaseShortArrayElements(array, data, commit ? 0 : JNI_ABORT);
169     }
170 };
171 class IntArrayReleaser {
172 public:
Release(JNIEnv * _env,jintArray array,jint * data,jboolean commit)173     static void Release(JNIEnv* _env, jintArray array, jint* data, jboolean commit) {
174         _env->ReleaseIntArrayElements(array, data, commit ? 0 : JNI_ABORT);
175     }
176 };
177 class LongArrayReleaser {
178 public:
Release(JNIEnv * _env,jlongArray array,jlong * data,jboolean commit)179     static void Release(JNIEnv* _env, jlongArray array, jlong* data, jboolean commit) {
180         _env->ReleaseLongArrayElements(array, data, commit ? 0 : JNI_ABORT);
181     }
182 };
183 class FloatArrayReleaser {
184 public:
Release(JNIEnv * _env,jfloatArray array,jfloat * data,jboolean commit)185     static void Release(JNIEnv* _env, jfloatArray array, jfloat* data, jboolean commit) {
186         _env->ReleaseFloatArrayElements(array, data, commit ? 0 : JNI_ABORT);
187     }
188 };
189 class DoubleArrayReleaser {
190 public:
Release(JNIEnv * _env,jdoubleArray array,jdouble * data,jboolean commit)191     static void Release(JNIEnv* _env, jdoubleArray array, jdouble* data, jboolean commit) {
192         _env->ReleaseDoubleArrayElements(array, data, commit ? 0 : JNI_ABORT);
193     }
194 };
195 
196 template<typename JTYPEARRAY, typename NTYPEARRAY, typename ARRAYRELEASER>
197 static void
releaseArrayPointer(JNIEnv * _env,JTYPEARRAY array,NTYPEARRAY data,jboolean commit)198 releaseArrayPointer(JNIEnv *_env, JTYPEARRAY array, NTYPEARRAY data, jboolean commit) {
199     ARRAYRELEASER::Release(_env, array, data, commit);
200 }
201 
202 static void
releasePointer(JNIEnv * _env,jarray array,void * data,jboolean commit)203 releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit)
204 {
205     _env->ReleasePrimitiveArrayCritical(array, data,
206                        commit ? 0 : JNI_ABORT);
207 }
208 
209 static void *
getDirectBufferPointer(JNIEnv * _env,jobject buffer)210 getDirectBufferPointer(JNIEnv *_env, jobject buffer) {
211     jint position;
212     jint limit;
213     jint elementSizeShift;
214     jlong pointer;
215     pointer = jniGetNioBufferFields(_env, buffer, &position, &limit, &elementSizeShift);
216     if (pointer == 0) {
217         jniThrowException(_env, "java/lang/IllegalArgumentException",
218                           "Must use a native order direct Buffer");
219         return nullptr;
220     }
221     pointer += position << elementSizeShift;
222     return reinterpret_cast<void*>(pointer);
223 }
224 
225 // --------------------------------------------------------------------------
226 
227 /*
228  * returns the number of values glGet returns for a given pname.
229  *
230  * The code below is written such that pnames requiring only one values
231  * are the default (and are not explicitely tested for). This makes the
232  * checking code much shorter/readable/efficient.
233  *
234  * This means that unknown pnames (e.g.: extensions) will default to 1. If
235  * that unknown pname needs more than 1 value, then the validation check
236  * is incomplete and the app may crash if it passed the wrong number params.
237  */
getNeededCount(GLint pname)238 static int getNeededCount(GLint pname) {
239     int needed = 1;
240 #ifdef GL_ES_VERSION_3_0
241     // GLES 3.x pnames
242     switch (pname) {
243         case GL_MAX_VIEWPORT_DIMS:
244             needed = 2;
245             break;
246 
247         case GL_PROGRAM_BINARY_FORMATS:
248             glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &needed);
249             break;
250     }
251 #endif
252 
253 #ifdef GL_ES_VERSION_2_0
254     // GLES 2.x pnames
255     switch (pname) {
256         case GL_ALIASED_LINE_WIDTH_RANGE:
257         case GL_ALIASED_POINT_SIZE_RANGE:
258             needed = 2;
259             break;
260 
261         case GL_BLEND_COLOR:
262         case GL_COLOR_CLEAR_VALUE:
263         case GL_COLOR_WRITEMASK:
264         case GL_SCISSOR_BOX:
265         case GL_VIEWPORT:
266             needed = 4;
267             break;
268 
269         case GL_COMPRESSED_TEXTURE_FORMATS:
270             glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
271             break;
272 
273         case GL_SHADER_BINARY_FORMATS:
274             glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &needed);
275             break;
276     }
277 #endif
278 
279 #ifdef GL_VERSION_ES_CM_1_1
280     // GLES 1.x pnames
281     switch (pname) {
282         case GL_ALIASED_LINE_WIDTH_RANGE:
283         case GL_ALIASED_POINT_SIZE_RANGE:
284         case GL_DEPTH_RANGE:
285         case GL_SMOOTH_LINE_WIDTH_RANGE:
286         case GL_SMOOTH_POINT_SIZE_RANGE:
287             needed = 2;
288             break;
289 
290         case GL_CURRENT_NORMAL:
291         case GL_POINT_DISTANCE_ATTENUATION:
292             needed = 3;
293             break;
294 
295         case GL_COLOR_CLEAR_VALUE:
296         case GL_COLOR_WRITEMASK:
297         case GL_CURRENT_COLOR:
298         case GL_CURRENT_TEXTURE_COORDS:
299         case GL_FOG_COLOR:
300         case GL_LIGHT_MODEL_AMBIENT:
301         case GL_SCISSOR_BOX:
302         case GL_VIEWPORT:
303             needed = 4;
304             break;
305 
306         case GL_MODELVIEW_MATRIX:
307         case GL_PROJECTION_MATRIX:
308         case GL_TEXTURE_MATRIX:
309             needed = 16;
310             break;
311 
312         case GL_COMPRESSED_TEXTURE_FORMATS:
313             glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
314             break;
315     }
316 #endif
317     return needed;
318 }
319 
320 template <typename JTYPEARRAY, typename ARRAYGETTER, typename NTYPEARRAY,
321           typename ARRAYRELEASER, typename CTYPE, void GET(GLenum, CTYPE*)>
322 static void
get(JNIEnv * _env,jobject _this,jint pname,JTYPEARRAY params_ref,jint offset)323 get
324   (JNIEnv *_env, jobject _this, jint pname, JTYPEARRAY params_ref, jint offset) {
325     jint _exception = 0;
326     const char * _exceptionType;
327     const char * _exceptionMessage;
328     CTYPE *params_base = (CTYPE *) 0;
329     jint _remaining;
330     CTYPE *params = (CTYPE *) 0;
331     int _needed = 0;
332 
333     if (!params_ref) {
334         _exception = 1;
335         _exceptionType = "java/lang/IllegalArgumentException";
336         _exceptionMessage = "params == null";
337         goto exit;
338     }
339     if (offset < 0) {
340         _exception = 1;
341         _exceptionType = "java/lang/IllegalArgumentException";
342         _exceptionMessage = "offset < 0";
343         goto exit;
344     }
345     _remaining = _env->GetArrayLength(params_ref) - offset;
346     _needed = getNeededCount(pname);
347     // if we didn't find this pname, we just assume the user passed
348     // an array of the right size -- this might happen with extensions
349     // or if we forget an enum here.
350     if (_remaining < _needed) {
351         _exception = 1;
352         _exceptionType = "java/lang/IllegalArgumentException";
353         _exceptionMessage = "length - offset < needed";
354         goto exit;
355     }
356     params_base = (CTYPE *) getArrayPointer<JTYPEARRAY, ARRAYGETTER>(
357         _env, params_ref, (jboolean *)0);
358     params = params_base + offset;
359 
360     GET(
361         (GLenum)pname,
362         (CTYPE *)params
363     );
364 
365 exit:
366     if (params_base) {
367         releaseArrayPointer<JTYPEARRAY, NTYPEARRAY, ARRAYRELEASER>(
368             _env, params_ref, params_base, !_exception);
369     }
370     if (_exception) {
371         jniThrowException(_env, _exceptionType, _exceptionMessage);
372     }
373 }
374 
375 
376 template <typename CTYPE, typename JTYPEARRAY, typename ARRAYGETTER, typename NTYPEARRAY,
377           typename ARRAYRELEASER, void GET(GLenum, CTYPE*)>
378 static void
getarray(JNIEnv * _env,jobject _this,jint pname,jobject params_buf)379 getarray
380   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
381     jint _exception = 0;
382     const char * _exceptionType;
383     const char * _exceptionMessage;
384     JTYPEARRAY _array = (JTYPEARRAY) 0;
385     jint _bufferOffset = (jint) 0;
386     jint _remaining;
387     CTYPE *params = (CTYPE *) 0;
388     int _needed = 0;
389 
390     params = (CTYPE *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
391     _remaining /= sizeof(CTYPE);    // convert from bytes to item count
392     _needed = getNeededCount(pname);
393     // if we didn't find this pname, we just assume the user passed
394     // an array of the right size -- this might happen with extensions
395     // or if we forget an enum here.
396     if (_needed>0 && _remaining < _needed) {
397         _exception = 1;
398         _exceptionType = "java/lang/IllegalArgumentException";
399         _exceptionMessage = "remaining() < needed";
400         goto exit;
401     }
402     if (params == NULL) {
403         char * _paramsBase = (char *) getArrayPointer<JTYPEARRAY, ARRAYGETTER>(
404             _env, _array, (jboolean *) 0);
405         params = (CTYPE *) (_paramsBase + _bufferOffset);
406     }
407     GET(
408         (GLenum)pname,
409         (CTYPE *)params
410     );
411 
412 exit:
413     if (_array) {
414         releaseArrayPointer<JTYPEARRAY, NTYPEARRAY, ARRAYRELEASER>(
415             _env, _array, (NTYPEARRAY)params, _exception ? JNI_FALSE : JNI_TRUE);
416     }
417     if (_exception) {
418         jniThrowException(_env, _exceptionType, _exceptionMessage);
419     }
420 }
421 
422 // --------------------------------------------------------------------------
423 /* GLbitfield glQueryMatrixxOES ( GLfixed *mantissa, GLint *exponent ) */
424 static jint
android_glQueryMatrixxOES___3II_3II(JNIEnv * _env,jobject _this,jintArray mantissa_ref,jint mantissaOffset,jintArray exponent_ref,jint exponentOffset)425 android_glQueryMatrixxOES___3II_3II
426   (JNIEnv *_env, jobject _this, jintArray mantissa_ref, jint mantissaOffset, jintArray exponent_ref, jint exponentOffset) {
427     jint _exception = 0;
428     const char * _exceptionType = NULL;
429     const char * _exceptionMessage = NULL;
430     GLbitfield _returnValue = -1;
431     GLfixed *mantissa_base = (GLfixed *) 0;
432     jint _mantissaRemaining;
433     GLfixed *mantissa = (GLfixed *) 0;
434     GLint *exponent_base = (GLint *) 0;
435     jint _exponentRemaining;
436     GLint *exponent = (GLint *) 0;
437 
438     if (!mantissa_ref) {
439         _exception = 1;
440         _exceptionType = "java/lang/IllegalArgumentException";
441         _exceptionMessage = "mantissa == null";
442         goto exit;
443     }
444     if (mantissaOffset < 0) {
445         _exception = 1;
446         _exceptionType = "java/lang/IllegalArgumentException";
447         _exceptionMessage = "mantissaOffset < 0";
448         goto exit;
449     }
450     _mantissaRemaining = _env->GetArrayLength(mantissa_ref) - mantissaOffset;
451     if (_mantissaRemaining < 16) {
452         _exception = 1;
453         _exceptionType = "java/lang/IllegalArgumentException";
454         _exceptionMessage = "length - mantissaOffset < 16 < needed";
455         goto exit;
456     }
457     mantissa_base = (GLfixed *)
458         _env->GetIntArrayElements(mantissa_ref, (jboolean *)0);
459     mantissa = mantissa_base + mantissaOffset;
460 
461     if (!exponent_ref) {
462         _exception = 1;
463         _exceptionType = "java/lang/IllegalArgumentException";
464         _exceptionMessage = "exponent == null";
465         goto exit;
466     }
467     if (exponentOffset < 0) {
468         _exception = 1;
469         _exceptionType = "java/lang/IllegalArgumentException";
470         _exceptionMessage = "exponentOffset < 0";
471         goto exit;
472     }
473     _exponentRemaining = _env->GetArrayLength(exponent_ref) - exponentOffset;
474     if (_exponentRemaining < 16) {
475         _exception = 1;
476         _exceptionType = "java/lang/IllegalArgumentException";
477         _exceptionMessage = "length - exponentOffset < 16 < needed";
478         goto exit;
479     }
480     exponent_base = (GLint *)
481         _env->GetIntArrayElements(exponent_ref, (jboolean *)0);
482     exponent = exponent_base + exponentOffset;
483 
484     _returnValue = glQueryMatrixxOES(
485         (GLfixed *)mantissa,
486         (GLint *)exponent
487     );
488 
489 exit:
490     if (exponent_base) {
491         _env->ReleaseIntArrayElements(exponent_ref, (jint*)exponent_base,
492             _exception ? JNI_ABORT: 0);
493     }
494     if (mantissa_base) {
495         _env->ReleaseIntArrayElements(mantissa_ref, (jint*)mantissa_base,
496             _exception ? JNI_ABORT: 0);
497     }
498     if (_exception) {
499         jniThrowException(_env, _exceptionType, _exceptionMessage);
500         return (jint)0;
501     }
502     return (jint)_returnValue;
503 }
504 
505 /* GLbitfield glQueryMatrixxOES ( GLfixed *mantissa, GLint *exponent ) */
506 static jint
android_glQueryMatrixxOES__Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2(JNIEnv * _env,jobject _this,jobject mantissa_buf,jobject exponent_buf)507 android_glQueryMatrixxOES__Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2
508   (JNIEnv *_env, jobject _this, jobject mantissa_buf, jobject exponent_buf) {
509     jint _exception = 0;
510     const char * _exceptionType = NULL;
511     const char * _exceptionMessage = NULL;
512     jintArray _mantissaArray = (jintArray) 0;
513     jint _mantissaBufferOffset = (jint) 0;
514     jintArray _exponentArray = (jintArray) 0;
515     jint _exponentBufferOffset = (jint) 0;
516     GLbitfield _returnValue = -1;
517     jint _mantissaRemaining;
518     GLfixed *mantissa = (GLfixed *) 0;
519     jint _exponentRemaining;
520     GLint *exponent = (GLint *) 0;
521 
522     if (!mantissa_buf) {
523         _exception = 1;
524         _exceptionType = "java/lang/IllegalArgumentException";
525         _exceptionMessage = "mantissa == null";
526         goto exit;
527     }
528     mantissa = (GLfixed *)getPointer(_env, mantissa_buf, (jarray*)&_mantissaArray, &_mantissaRemaining, &_mantissaBufferOffset);
529     if (_mantissaRemaining < 16) {
530         _exception = 1;
531         _exceptionType = "java/lang/IllegalArgumentException";
532         _exceptionMessage = "remaining() < 16 < needed";
533         goto exit;
534     }
535     if (!exponent_buf) {
536         _exception = 1;
537         _exceptionType = "java/lang/IllegalArgumentException";
538         _exceptionMessage = "exponent == null";
539         goto exit;
540     }
541     exponent = (GLint *)getPointer(_env, exponent_buf, (jarray*)&_exponentArray, &_exponentRemaining, &_exponentBufferOffset);
542     if (_exponentRemaining < 16) {
543         _exception = 1;
544         _exceptionType = "java/lang/IllegalArgumentException";
545         _exceptionMessage = "remaining() < 16 < needed";
546         goto exit;
547     }
548     if (mantissa == NULL) {
549         char * _mantissaBase = (char *)_env->GetIntArrayElements(_mantissaArray, (jboolean *) 0);
550         mantissa = (GLfixed *) (_mantissaBase + _mantissaBufferOffset);
551     }
552     if (exponent == NULL) {
553         char * _exponentBase = (char *)_env->GetIntArrayElements(_exponentArray, (jboolean *) 0);
554         exponent = (GLint *) (_exponentBase + _exponentBufferOffset);
555     }
556     _returnValue = glQueryMatrixxOES(
557         (GLfixed *)mantissa,
558         (GLint *)exponent
559     );
560 
561 exit:
562     if (_exponentArray) {
563         _env->ReleaseIntArrayElements(_exponentArray, (jint*)exponent, _exception ? JNI_ABORT : 0);
564     }
565     if (_mantissaArray) {
566         _env->ReleaseIntArrayElements(_mantissaArray, (jint*)mantissa, _exception ? JNI_ABORT : 0);
567     }
568     if (_exception) {
569         jniThrowException(_env, _exceptionType, _exceptionMessage);
570         return (jint)0;
571     }
572     return (jint)_returnValue;
573 }
574 
575 static const char *classPathName = "android/opengl/GLES10Ext";
576 
577 static const JNINativeMethod methods[] = {
578 {"_nativeClassInit", "()V", (void*)nativeClassInit },
579 {"glQueryMatrixxOES", "([II[II)I", (void *) android_glQueryMatrixxOES___3II_3II },
580 {"glQueryMatrixxOES", "(Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;)I", (void *) android_glQueryMatrixxOES__Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2 },
581 };
582 
register_android_opengl_jni_GLES10Ext(JNIEnv * _env)583 int register_android_opengl_jni_GLES10Ext(JNIEnv *_env)
584 {
585     int err;
586     err = android::AndroidRuntime::registerNativeMethods(_env, classPathName, methods, NELEM(methods));
587     return err;
588 }
589