blob: 6d7f41e5b3b281f62dd0ec9fcf161d0b97dbd454 [file] [log] [blame]
Jack Palevich27f80022009-04-15 19:13:17 -07001/*
2**
3** Copyright 2009, The Android Open Source Project
4**
Elliott Hughes24ce5fb2011-04-08 20:01:01 -07005** 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
Jack Palevich27f80022009-04-15 19:13:17 -07008**
Elliott Hughes24ce5fb2011-04-08 20:01:01 -07009** http://www.apache.org/licenses/LICENSE-2.0
Jack Palevich27f80022009-04-15 19:13:17 -070010**
Elliott Hughes24ce5fb2011-04-08 20:01:01 -070011** 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
Jack Palevich27f80022009-04-15 19:13:17 -070015** limitations under the License.
16*/
17
18// This source file is automatically generated
19
Andreas Gampebfe63332014-11-12 14:12:45 -080020#pragma GCC diagnostic ignored "-Wunused-variable"
Andreas Gampebfe63332014-11-12 14:12:45 -080021#pragma GCC diagnostic ignored "-Wunused-function"
22
Mathias Agopian2ad04772013-02-23 03:12:30 -080023#include <GLES/gl.h>
24#include <GLES/glext.h>
25
Jesse Hall9626f822014-05-19 20:57:49 -070026#include <jni.h>
Steven Moreland2279b252017-07-19 09:50:45 -070027#include <nativehelper/JNIHelp.h>
Jack Palevich27f80022009-04-15 19:13:17 -070028#include <android_runtime/AndroidRuntime.h>
29#include <utils/misc.h>
Jack Palevich27f80022009-04-15 19:13:17 -070030#include <assert.h>
Jack Palevich27f80022009-04-15 19:13:17 -070031
Mathias Agopian2ad04772013-02-23 03:12:30 -080032
33/* special calls implemented in Android's GLES wrapper used to more
34 * efficiently bound-check passed arrays */
35extern "C" {
36#ifdef GL_VERSION_ES_CM_1_1
37GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
38 const GLvoid *ptr, GLsizei count);
39GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride,
40 const GLvoid *pointer, GLsizei count);
41GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type,
42 GLsizei stride, const GLvoid *pointer, GLsizei count);
43GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type,
44 GLsizei stride, const GLvoid *pointer, GLsizei count);
45GL_API void GL_APIENTRY glPointSizePointerOESBounds(GLenum type,
46 GLsizei stride, const GLvoid *pointer, GLsizei count);
47GL_API void GL_APIENTRY glMatrixIndexPointerOESBounds(GLint size, GLenum type,
48 GLsizei stride, const GLvoid *pointer, GLsizei count);
49GL_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
53static 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
Andy McFaddencee51982013-04-25 16:08:31 -070058#ifdef GL_ES_VERSION_3_0
59static 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
Mathias Agopian2ad04772013-02-23 03:12:30 -080064}
65
Jack Palevich27f80022009-04-15 19:13:17 -070066static void
Elliott Hughes24ce5fb2011-04-08 20:01:01 -070067nativeClassInit(JNIEnv *_env, jclass glImplClass)
Jack Palevich27f80022009-04-15 19:13:17 -070068{
Jack Palevich27f80022009-04-15 19:13:17 -070069}
70
Jack Palevich27f80022009-04-15 19:13:17 -070071static void *
Thomas Tafertshofer17045a12012-07-12 13:55:55 -070072getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining, jint *offset)
Jack Palevich27f80022009-04-15 19:13:17 -070073{
74 jint position;
75 jint limit;
76 jint elementSizeShift;
77 jlong pointer;
Jack Palevich27f80022009-04-15 19:13:17 -070078
Orion Hodson617835922019-02-28 15:15:34 +000079 pointer = jniGetNioBufferFields(_env, buffer, &position, &limit, &elementSizeShift);
Jack Palevich27f80022009-04-15 19:13:17 -070080 *remaining = (limit - position) << elementSizeShift;
Jack Palevich27f80022009-04-15 19:13:17 -070081 if (pointer != 0L) {
Orion Hodson617835922019-02-28 15:15:34 +000082 *array = nullptr;
83 pointer += position << elementSizeShift;
Ashok Bhat01c26ea2014-02-24 09:49:07 +000084 return reinterpret_cast<void*>(pointer);
Jack Palevich27f80022009-04-15 19:13:17 -070085 }
Elliott Hughes24ce5fb2011-04-08 20:01:01 -070086
Orion Hodson617835922019-02-28 15:15:34 +000087 *array = jniGetNioBufferBaseArray(_env, buffer);
88 *offset = jniGetNioBufferBaseArrayOffset(_env, buffer);
89 return nullptr;
Jack Palevich27f80022009-04-15 19:13:17 -070090}
91
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -070092class ByteArrayGetter {
93public:
94 static void* Get(JNIEnv* _env, jbyteArray array, jboolean* is_copy) {
95 return _env->GetByteArrayElements(array, is_copy);
96 }
97};
98class BooleanArrayGetter {
99public:
100 static void* Get(JNIEnv* _env, jbooleanArray array, jboolean* is_copy) {
101 return _env->GetBooleanArrayElements(array, is_copy);
102 }
103};
104class CharArrayGetter {
105public:
106 static void* Get(JNIEnv* _env, jcharArray array, jboolean* is_copy) {
107 return _env->GetCharArrayElements(array, is_copy);
108 }
109};
110class ShortArrayGetter {
111public:
112 static void* Get(JNIEnv* _env, jshortArray array, jboolean* is_copy) {
113 return _env->GetShortArrayElements(array, is_copy);
114 }
115};
116class IntArrayGetter {
117public:
118 static void* Get(JNIEnv* _env, jintArray array, jboolean* is_copy) {
119 return _env->GetIntArrayElements(array, is_copy);
120 }
121};
122class LongArrayGetter {
123public:
124 static void* Get(JNIEnv* _env, jlongArray array, jboolean* is_copy) {
125 return _env->GetLongArrayElements(array, is_copy);
126 }
127};
128class FloatArrayGetter {
129public:
130 static void* Get(JNIEnv* _env, jfloatArray array, jboolean* is_copy) {
131 return _env->GetFloatArrayElements(array, is_copy);
132 }
133};
134class DoubleArrayGetter {
135public:
136 static void* Get(JNIEnv* _env, jdoubleArray array, jboolean* is_copy) {
137 return _env->GetDoubleArrayElements(array, is_copy);
138 }
139};
140
141template<typename JTYPEARRAY, typename ARRAYGETTER>
142static void*
143getArrayPointer(JNIEnv *_env, JTYPEARRAY array, jboolean* is_copy) {
144 return ARRAYGETTER::Get(_env, array, is_copy);
145}
146
147class ByteArrayReleaser {
148public:
149 static void Release(JNIEnv* _env, jbyteArray array, jbyte* data, jboolean commit) {
150 _env->ReleaseByteArrayElements(array, data, commit ? 0 : JNI_ABORT);
151 }
152};
153class BooleanArrayReleaser {
154public:
155 static void Release(JNIEnv* _env, jbooleanArray array, jboolean* data, jboolean commit) {
156 _env->ReleaseBooleanArrayElements(array, data, commit ? 0 : JNI_ABORT);
157 }
158};
159class CharArrayReleaser {
160public:
161 static void Release(JNIEnv* _env, jcharArray array, jchar* data, jboolean commit) {
162 _env->ReleaseCharArrayElements(array, data, commit ? 0 : JNI_ABORT);
163 }
164};
165class ShortArrayReleaser {
166public:
167 static void Release(JNIEnv* _env, jshortArray array, jshort* data, jboolean commit) {
168 _env->ReleaseShortArrayElements(array, data, commit ? 0 : JNI_ABORT);
169 }
170};
171class IntArrayReleaser {
172public:
173 static void Release(JNIEnv* _env, jintArray array, jint* data, jboolean commit) {
174 _env->ReleaseIntArrayElements(array, data, commit ? 0 : JNI_ABORT);
175 }
176};
177class LongArrayReleaser {
178public:
179 static void Release(JNIEnv* _env, jlongArray array, jlong* data, jboolean commit) {
180 _env->ReleaseLongArrayElements(array, data, commit ? 0 : JNI_ABORT);
181 }
182};
183class FloatArrayReleaser {
184public:
185 static void Release(JNIEnv* _env, jfloatArray array, jfloat* data, jboolean commit) {
186 _env->ReleaseFloatArrayElements(array, data, commit ? 0 : JNI_ABORT);
187 }
188};
189class DoubleArrayReleaser {
190public:
191 static void Release(JNIEnv* _env, jdoubleArray array, jdouble* data, jboolean commit) {
192 _env->ReleaseDoubleArrayElements(array, data, commit ? 0 : JNI_ABORT);
193 }
194};
195
196template<typename JTYPEARRAY, typename NTYPEARRAY, typename ARRAYRELEASER>
197static void
198releaseArrayPointer(JNIEnv *_env, JTYPEARRAY array, NTYPEARRAY data, jboolean commit) {
199 ARRAYRELEASER::Release(_env, array, data, commit);
200}
201
Jack Palevich27f80022009-04-15 19:13:17 -0700202static void
203releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit)
204{
205 _env->ReleasePrimitiveArrayCritical(array, data,
Mathias Agopian2ad04772013-02-23 03:12:30 -0800206 commit ? 0 : JNI_ABORT);
207}
208
209static void *
210getDirectBufferPointer(JNIEnv *_env, jobject buffer) {
Orion Hodson617835922019-02-28 15:15:34 +0000211 jint position;
212 jint limit;
213 jint elementSizeShift;
214 jlong pointer;
215 pointer = jniGetNioBufferFields(_env, buffer, &position, &limit, &elementSizeShift);
216 if (pointer == 0) {
Mathias Agopian2ad04772013-02-23 03:12:30 -0800217 jniThrowException(_env, "java/lang/IllegalArgumentException",
218 "Must use a native order direct Buffer");
Orion Hodson617835922019-02-28 15:15:34 +0000219 return nullptr;
Mathias Agopian2ad04772013-02-23 03:12:30 -0800220 }
Orion Hodson617835922019-02-28 15:15:34 +0000221 pointer += position << elementSizeShift;
222 return reinterpret_cast<void*>(pointer);
Mathias Agopian2ad04772013-02-23 03:12:30 -0800223}
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 */
238static int getNeededCount(GLint pname) {
239 int needed = 1;
Romain Guydc43a6c2017-02-17 19:54:25 -0800240#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
Mathias Agopian2ad04772013-02-23 03:12:30 -0800253#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
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700320template <typename JTYPEARRAY, typename ARRAYGETTER, typename NTYPEARRAY,
321 typename ARRAYRELEASER, typename CTYPE, void GET(GLenum, CTYPE*)>
Mathias Agopian2ad04772013-02-23 03:12:30 -0800322static void
323get
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 }
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700356 params_base = (CTYPE *) getArrayPointer<JTYPEARRAY, ARRAYGETTER>(
357 _env, params_ref, (jboolean *)0);
Mathias Agopian2ad04772013-02-23 03:12:30 -0800358 params = params_base + offset;
359
360 GET(
361 (GLenum)pname,
362 (CTYPE *)params
363 );
364
365exit:
366 if (params_base) {
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700367 releaseArrayPointer<JTYPEARRAY, NTYPEARRAY, ARRAYRELEASER>(
368 _env, params_ref, params_base, !_exception);
Mathias Agopian2ad04772013-02-23 03:12:30 -0800369 }
370 if (_exception) {
371 jniThrowException(_env, _exceptionType, _exceptionMessage);
372 }
373}
374
375
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700376template <typename CTYPE, typename JTYPEARRAY, typename ARRAYGETTER, typename NTYPEARRAY,
377 typename ARRAYRELEASER, void GET(GLenum, CTYPE*)>
Mathias Agopian2ad04772013-02-23 03:12:30 -0800378static void
379getarray
380 (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
381 jint _exception = 0;
382 const char * _exceptionType;
383 const char * _exceptionMessage;
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700384 JTYPEARRAY _array = (JTYPEARRAY) 0;
Mathias Agopian2ad04772013-02-23 03:12:30 -0800385 jint _bufferOffset = (jint) 0;
386 jint _remaining;
387 CTYPE *params = (CTYPE *) 0;
388 int _needed = 0;
389
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700390 params = (CTYPE *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
Andy McFaddencee51982013-04-25 16:08:31 -0700391 _remaining /= sizeof(CTYPE); // convert from bytes to item count
Mathias Agopian2ad04772013-02-23 03:12:30 -0800392 _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) {
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700403 char * _paramsBase = (char *) getArrayPointer<JTYPEARRAY, ARRAYGETTER>(
404 _env, _array, (jboolean *) 0);
Mathias Agopian2ad04772013-02-23 03:12:30 -0800405 params = (CTYPE *) (_paramsBase + _bufferOffset);
406 }
407 GET(
408 (GLenum)pname,
409 (CTYPE *)params
410 );
411
412exit:
413 if (_array) {
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700414 releaseArrayPointer<JTYPEARRAY, NTYPEARRAY, ARRAYRELEASER>(
415 _env, _array, (NTYPEARRAY)params, _exception ? JNI_FALSE : JNI_TRUE);
Mathias Agopian2ad04772013-02-23 03:12:30 -0800416 }
417 if (_exception) {
418 jniThrowException(_env, _exceptionType, _exceptionMessage);
419 }
Jack Palevich27f80022009-04-15 19:13:17 -0700420}
421
422// --------------------------------------------------------------------------
Jack Palevich27f80022009-04-15 19:13:17 -0700423/* GLbitfield glQueryMatrixxOES ( GLfixed *mantissa, GLint *exponent ) */
424static jint
425android_glQueryMatrixxOES___3II_3II
426 (JNIEnv *_env, jobject _this, jintArray mantissa_ref, jint mantissaOffset, jintArray exponent_ref, jint exponentOffset) {
427 jint _exception = 0;
Mathias Agopian2ad04772013-02-23 03:12:30 -0800428 const char * _exceptionType = NULL;
429 const char * _exceptionMessage = NULL;
Jack Palevich27f80022009-04-15 19:13:17 -0700430 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;
Thomas Tafertshofer2545b322012-06-27 16:33:26 -0700440 _exceptionType = "java/lang/IllegalArgumentException";
441 _exceptionMessage = "mantissa == null";
Jack Palevich27f80022009-04-15 19:13:17 -0700442 goto exit;
443 }
444 if (mantissaOffset < 0) {
445 _exception = 1;
Thomas Tafertshofer2545b322012-06-27 16:33:26 -0700446 _exceptionType = "java/lang/IllegalArgumentException";
447 _exceptionMessage = "mantissaOffset < 0";
Jack Palevich27f80022009-04-15 19:13:17 -0700448 goto exit;
449 }
450 _mantissaRemaining = _env->GetArrayLength(mantissa_ref) - mantissaOffset;
451 if (_mantissaRemaining < 16) {
452 _exception = 1;
Thomas Tafertshofer2545b322012-06-27 16:33:26 -0700453 _exceptionType = "java/lang/IllegalArgumentException";
454 _exceptionMessage = "length - mantissaOffset < 16 < needed";
Jack Palevich27f80022009-04-15 19:13:17 -0700455 goto exit;
456 }
457 mantissa_base = (GLfixed *)
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700458 _env->GetIntArrayElements(mantissa_ref, (jboolean *)0);
Jack Palevich27f80022009-04-15 19:13:17 -0700459 mantissa = mantissa_base + mantissaOffset;
460
461 if (!exponent_ref) {
462 _exception = 1;
Thomas Tafertshofer2545b322012-06-27 16:33:26 -0700463 _exceptionType = "java/lang/IllegalArgumentException";
464 _exceptionMessage = "exponent == null";
Jack Palevich27f80022009-04-15 19:13:17 -0700465 goto exit;
466 }
467 if (exponentOffset < 0) {
468 _exception = 1;
Thomas Tafertshofer2545b322012-06-27 16:33:26 -0700469 _exceptionType = "java/lang/IllegalArgumentException";
470 _exceptionMessage = "exponentOffset < 0";
Jack Palevich27f80022009-04-15 19:13:17 -0700471 goto exit;
472 }
473 _exponentRemaining = _env->GetArrayLength(exponent_ref) - exponentOffset;
474 if (_exponentRemaining < 16) {
475 _exception = 1;
Thomas Tafertshofer2545b322012-06-27 16:33:26 -0700476 _exceptionType = "java/lang/IllegalArgumentException";
477 _exceptionMessage = "length - exponentOffset < 16 < needed";
Jack Palevich27f80022009-04-15 19:13:17 -0700478 goto exit;
479 }
480 exponent_base = (GLint *)
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700481 _env->GetIntArrayElements(exponent_ref, (jboolean *)0);
Jack Palevich27f80022009-04-15 19:13:17 -0700482 exponent = exponent_base + exponentOffset;
483
484 _returnValue = glQueryMatrixxOES(
485 (GLfixed *)mantissa,
486 (GLint *)exponent
487 );
488
489exit:
490 if (exponent_base) {
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700491 _env->ReleaseIntArrayElements(exponent_ref, (jint*)exponent_base,
Jack Palevich27f80022009-04-15 19:13:17 -0700492 _exception ? JNI_ABORT: 0);
493 }
494 if (mantissa_base) {
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700495 _env->ReleaseIntArrayElements(mantissa_ref, (jint*)mantissa_base,
Jack Palevich27f80022009-04-15 19:13:17 -0700496 _exception ? JNI_ABORT: 0);
497 }
Thomas Tafertshofer2545b322012-06-27 16:33:26 -0700498 if (_exception) {
499 jniThrowException(_env, _exceptionType, _exceptionMessage);
Orion Hodsonc240f222019-02-26 18:05:03 +0000500 return (jint)0;
Thomas Tafertshofer2545b322012-06-27 16:33:26 -0700501 }
Andy McFaddencee51982013-04-25 16:08:31 -0700502 return (jint)_returnValue;
Jack Palevich27f80022009-04-15 19:13:17 -0700503}
504
505/* GLbitfield glQueryMatrixxOES ( GLfixed *mantissa, GLint *exponent ) */
506static jint
507android_glQueryMatrixxOES__Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2
508 (JNIEnv *_env, jobject _this, jobject mantissa_buf, jobject exponent_buf) {
509 jint _exception = 0;
Mathias Agopian2ad04772013-02-23 03:12:30 -0800510 const char * _exceptionType = NULL;
511 const char * _exceptionMessage = NULL;
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700512 jintArray _mantissaArray = (jintArray) 0;
Thomas Tafertshofer17045a12012-07-12 13:55:55 -0700513 jint _mantissaBufferOffset = (jint) 0;
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700514 jintArray _exponentArray = (jintArray) 0;
Thomas Tafertshofer17045a12012-07-12 13:55:55 -0700515 jint _exponentBufferOffset = (jint) 0;
Jack Palevich27f80022009-04-15 19:13:17 -0700516 GLbitfield _returnValue = -1;
517 jint _mantissaRemaining;
518 GLfixed *mantissa = (GLfixed *) 0;
519 jint _exponentRemaining;
520 GLint *exponent = (GLint *) 0;
521
Romain Guy84cac202016-12-05 12:26:02 -0800522 if (!mantissa_buf) {
523 _exception = 1;
524 _exceptionType = "java/lang/IllegalArgumentException";
525 _exceptionMessage = "mantissa == null";
526 goto exit;
527 }
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700528 mantissa = (GLfixed *)getPointer(_env, mantissa_buf, (jarray*)&_mantissaArray, &_mantissaRemaining, &_mantissaBufferOffset);
Jack Palevich27f80022009-04-15 19:13:17 -0700529 if (_mantissaRemaining < 16) {
530 _exception = 1;
Thomas Tafertshofer2545b322012-06-27 16:33:26 -0700531 _exceptionType = "java/lang/IllegalArgumentException";
532 _exceptionMessage = "remaining() < 16 < needed";
Jack Palevich27f80022009-04-15 19:13:17 -0700533 goto exit;
534 }
Romain Guy84cac202016-12-05 12:26:02 -0800535 if (!exponent_buf) {
536 _exception = 1;
537 _exceptionType = "java/lang/IllegalArgumentException";
538 _exceptionMessage = "exponent == null";
539 goto exit;
540 }
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700541 exponent = (GLint *)getPointer(_env, exponent_buf, (jarray*)&_exponentArray, &_exponentRemaining, &_exponentBufferOffset);
Jack Palevich27f80022009-04-15 19:13:17 -0700542 if (_exponentRemaining < 16) {
543 _exception = 1;
Thomas Tafertshofer2545b322012-06-27 16:33:26 -0700544 _exceptionType = "java/lang/IllegalArgumentException";
545 _exceptionMessage = "remaining() < 16 < needed";
Jack Palevich27f80022009-04-15 19:13:17 -0700546 goto exit;
547 }
Thomas Tafertshofer17045a12012-07-12 13:55:55 -0700548 if (mantissa == NULL) {
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700549 char * _mantissaBase = (char *)_env->GetIntArrayElements(_mantissaArray, (jboolean *) 0);
Thomas Tafertshofer17045a12012-07-12 13:55:55 -0700550 mantissa = (GLfixed *) (_mantissaBase + _mantissaBufferOffset);
551 }
552 if (exponent == NULL) {
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700553 char * _exponentBase = (char *)_env->GetIntArrayElements(_exponentArray, (jboolean *) 0);
Thomas Tafertshofer17045a12012-07-12 13:55:55 -0700554 exponent = (GLint *) (_exponentBase + _exponentBufferOffset);
555 }
Jack Palevich27f80022009-04-15 19:13:17 -0700556 _returnValue = glQueryMatrixxOES(
557 (GLfixed *)mantissa,
558 (GLint *)exponent
559 );
560
561exit:
Jack Palevich27f80022009-04-15 19:13:17 -0700562 if (_exponentArray) {
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700563 _env->ReleaseIntArrayElements(_exponentArray, (jint*)exponent, _exception ? JNI_ABORT : 0);
Thomas Tafertshofer17045a12012-07-12 13:55:55 -0700564 }
565 if (_mantissaArray) {
Hiroshi Yamauchi3b1d46e2015-05-13 13:10:33 -0700566 _env->ReleaseIntArrayElements(_mantissaArray, (jint*)mantissa, _exception ? JNI_ABORT : 0);
Jack Palevich27f80022009-04-15 19:13:17 -0700567 }
Thomas Tafertshofer2545b322012-06-27 16:33:26 -0700568 if (_exception) {
569 jniThrowException(_env, _exceptionType, _exceptionMessage);
Orion Hodsonc240f222019-02-26 18:05:03 +0000570 return (jint)0;
Thomas Tafertshofer2545b322012-06-27 16:33:26 -0700571 }
Andy McFaddencee51982013-04-25 16:08:31 -0700572 return (jint)_returnValue;
Jack Palevich27f80022009-04-15 19:13:17 -0700573}
574
575static const char *classPathName = "android/opengl/GLES10Ext";
576
Daniel Micay76f6a862015-09-19 17:31:01 -0400577static const JNINativeMethod methods[] = {
Jack Palevich27f80022009-04-15 19:13:17 -0700578{"_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
583int 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}