1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
|
/*
**
** 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/GLConsumer.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);
}
// --------------------------------------------------------------------------
/* EGLint eglGetError ( void ) */
static jint
android_eglGetError
(JNIEnv *_env, jobject _this) {
EGLint _returnValue = (EGLint) 0;
_returnValue = eglGetError();
return _returnValue;
}
/* EGLDisplay eglGetDisplay ( EGLNativeDisplayType display_id ) */
static jobject
android_eglGetDisplay
(JNIEnv *_env, jobject _this, jint display_id) {
EGLDisplay _returnValue = (EGLDisplay) 0;
_returnValue = eglGetDisplay(
(EGLNativeDisplayType)display_id
);
return toEGLHandle(_env, egldisplayClass, egldisplayConstructor, _returnValue);
}
/* EGLBoolean eglInitialize ( EGLDisplay dpy, EGLint *major, EGLint *minor ) */
static jboolean
android_eglInitialize
(JNIEnv *_env, jobject _this, jobject dpy, jintArray major_ref, jint majorOffset, jintArray minor_ref, jint minorOffset) {
jint _exception = 0;
const char * _exceptionType;
const char * _exceptionMessage;
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLint *major_base = (EGLint *) 0;
jint _majorRemaining;
EGLint *major = (EGLint *) 0;
EGLint *minor_base = (EGLint *) 0;
jint _minorRemaining;
EGLint *minor = (EGLint *) 0;
if (!major_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "major == null";
goto exit;
}
if (majorOffset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "majorOffset < 0";
goto exit;
}
_majorRemaining = _env->GetArrayLength(major_ref) - majorOffset;
if (_majorRemaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - majorOffset < 1 < needed";
goto exit;
}
major_base = (EGLint *)
_env->GetPrimitiveArrayCritical(major_ref, (jboolean *)0);
major = major_base + majorOffset;
if (!minor_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "minor == null";
goto exit;
}
if (minorOffset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "minorOffset < 0";
goto exit;
}
_minorRemaining = _env->GetArrayLength(minor_ref) - minorOffset;
if (_minorRemaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - minorOffset < 1 < needed";
goto exit;
}
minor_base = (EGLint *)
_env->GetPrimitiveArrayCritical(minor_ref, (jboolean *)0);
minor = minor_base + minorOffset;
_returnValue = eglInitialize(
(EGLDisplay)dpy_native,
(EGLint *)major,
(EGLint *)minor
);
exit:
if (minor_base) {
_env->ReleasePrimitiveArrayCritical(minor_ref, minor_base,
_exception ? JNI_ABORT: 0);
}
if (major_base) {
_env->ReleasePrimitiveArrayCritical(major_ref, major_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
return _returnValue;
}
/* EGLBoolean eglTerminate ( EGLDisplay dpy ) */
static jboolean
android_eglTerminate
(JNIEnv *_env, jobject _this, jobject dpy) {
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
_returnValue = eglTerminate(
(EGLDisplay)dpy_native
);
return _returnValue;
}
/* 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);
}
/* EGLBoolean eglGetConfigs ( EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config ) */
static jboolean
android_eglGetConfigs
(JNIEnv *_env, jobject _this, jobject dpy, jobjectArray configs_ref, jint configsOffset, jint config_size, jintArray num_config_ref, jint num_configOffset) {
jint _exception = 0;
const char * _exceptionType;
const char * _exceptionMessage;
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
jint _configsRemaining;
EGLConfig *configs = (EGLConfig *) 0;
EGLint *num_config_base = (EGLint *) 0;
jint _num_configRemaining;
EGLint *num_config = (EGLint *) 0;
if (!configs_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "configs == null";
goto exit;
}
if (configsOffset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "configsOffset < 0";
goto exit;
}
_configsRemaining = _env->GetArrayLength(configs_ref) - configsOffset;
if (_configsRemaining < config_size) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - configsOffset < config_size < needed";
goto exit;
}
configs = new EGLConfig[_configsRemaining];
if (!num_config_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "num_config == null";
goto exit;
}
if (num_configOffset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "num_configOffset < 0";
goto exit;
}
_num_configRemaining = _env->GetArrayLength(num_config_ref) - num_configOffset;
num_config_base = (EGLint *)
_env->GetPrimitiveArrayCritical(num_config_ref, (jboolean *)0);
num_config = num_config_base + num_configOffset;
_returnValue = eglGetConfigs(
(EGLDisplay)dpy_native,
(EGLConfig *)configs,
(EGLint)config_size,
(EGLint *)num_config
);
exit:
if (num_config_base) {
_env->ReleasePrimitiveArrayCritical(num_config_ref, num_config_base,
_exception ? JNI_ABORT: 0);
}
if (configs) {
for (int i = 0; i < _configsRemaining; i++) {
jobject configs_new = toEGLHandle(_env, eglconfigClass, eglconfigConstructor, configs[i]);
_env->SetObjectArrayElement(configs_ref, i + configsOffset, configs_new);
}
delete[] configs;
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
return _returnValue;
}
/* EGLBoolean eglChooseConfig ( EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config ) */
static jboolean
android_eglChooseConfig
(JNIEnv *_env, jobject _this, jobject dpy, jintArray attrib_list_ref, jint attrib_listOffset, jobjectArray configs_ref, jint configsOffset, jint config_size, jintArray num_config_ref, jint num_configOffset) {
jint _exception = 0;
const char * _exceptionType;
const char * _exceptionMessage;
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
bool attrib_list_sentinel = false;
EGLint *attrib_list_base = (EGLint *) 0;
jint _attrib_listRemaining;
EGLint *attrib_list = (EGLint *) 0;
jint _configsRemaining;
EGLConfig *configs = (EGLConfig *) 0;
EGLint *num_config_base = (EGLint *) 0;
jint _num_configRemaining;
EGLint *num_config = (EGLint *) 0;
if (!attrib_list_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "attrib_list == null";
goto exit;
}
if (attrib_listOffset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "attrib_listOffset < 0";
goto exit;
}
_attrib_listRemaining = _env->GetArrayLength(attrib_list_ref) - attrib_listOffset;
attrib_list_base = (EGLint *)
_env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0);
attrib_list = attrib_list_base + attrib_listOffset;
attrib_list_sentinel = false;
for (int i = _attrib_listRemaining - 1; i >= 0; i--) {
if (attrib_list[i] == EGL_NONE){
attrib_list_sentinel = true;
break;
}
}
if (attrib_list_sentinel == false) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "attrib_list must contain EGL_NONE!";
goto exit;
}
if (!configs_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "configs == null";
goto exit;
}
if (configsOffset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "configsOffset < 0";
goto exit;
}
_configsRemaining = _env->GetArrayLength(configs_ref) - configsOffset;
if (_configsRemaining < config_size) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - configsOffset < config_size < needed";
goto exit;
}
configs = new EGLConfig[_configsRemaining];
if (!num_config_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "num_config == null";
goto exit;
}
if (num_configOffset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "num_configOffset < 0";
goto exit;
}
_num_configRemaining = _env->GetArrayLength(num_config_ref) - num_configOffset;
if (_num_configRemaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - num_configOffset < 1 < needed";
goto exit;
}
num_config_base = (EGLint *)
_env->GetPrimitiveArrayCritical(num_config_ref, (jboolean *)0);
num_config = num_config_base + num_configOffset;
_returnValue = eglChooseConfig(
(EGLDisplay)dpy_native,
(EGLint *)attrib_list,
(EGLConfig *)configs,
(EGLint)config_size,
(EGLint *)num_config
);
exit:
if (num_config_base) {
_env->ReleasePrimitiveArrayCritical(num_config_ref, num_config_base,
_exception ? JNI_ABORT: 0);
}
if (attrib_list_base) {
_env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base,
JNI_ABORT);
}
if (configs) {
for (int i = 0; i < _configsRemaining; i++) {
jobject configs_new = toEGLHandle(_env, eglconfigClass, eglconfigConstructor, configs[i]);
_env->SetObjectArrayElement(configs_ref, i + configsOffset, configs_new);
}
delete[] configs;
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
return _returnValue;
}
/* EGLBoolean eglGetConfigAttrib ( EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value ) */
static jboolean
android_eglGetConfigAttrib
(JNIEnv *_env, jobject _this, jobject dpy, jobject config, jint attribute, jintArray value_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType;
const char * _exceptionMessage;
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
EGLint *value_base = (EGLint *) 0;
jint _remaining;
EGLint *value = (EGLint *) 0;
if (!value_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "value == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(value_ref) - offset;
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < 1 < needed";
goto exit;
}
value_base = (EGLint *)
_env->GetPrimitiveArrayCritical(value_ref, (jboolean *)0);
value = value_base + offset;
_returnValue = eglGetConfigAttrib(
(EGLDisplay)dpy_native,
(EGLConfig)config_native,
(EGLint)attribute,
(EGLint *)value
);
exit:
if (value_base) {
_env->ReleasePrimitiveArrayCritical(value_ref, value_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
return _returnValue;
}
/* 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_view_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::GLConsumer> 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);
if (surfaceTexture == NULL)
goto not_valid_surface;
window = new android::SurfaceTextureClient(surfaceTexture->getBufferQueue());
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 eglCreatePbufferSurface ( EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list ) */
static jobject
android_eglCreatePbufferSurface
(JNIEnv *_env, jobject _this, jobject dpy, jobject config, 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);
bool attrib_list_sentinel = false;
EGLint *attrib_list_base = (EGLint *) 0;
jint _remaining;
EGLint *attrib_list = (EGLint *) 0;
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;
}
_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 = false;
for (int i = _remaining - 1; i >= 0; i--) {
if (attrib_list[i] == EGL_NONE){
attrib_list_sentinel = true;
break;
}
}
if (attrib_list_sentinel == false) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "attrib_list must contain EGL_NONE!";
goto exit;
}
_returnValue = eglCreatePbufferSurface(
(EGLDisplay)dpy_native,
(EGLConfig)config_native,
(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 eglCreatePixmapSurface ( EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list ) */
static jobject
android_eglCreatePixmapSurface
(JNIEnv *_env, jobject _this, jobject dpy, jobject config, jint pixmap, jintArray attrib_list_ref, jint offset) {
jniThrowException(_env, "java/lang/UnsupportedOperationException",
"eglCreatePixmapSurface");
return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, (EGLSurface) 0);
}
/* EGLBoolean eglDestroySurface ( EGLDisplay dpy, EGLSurface surface ) */
static jboolean
android_eglDestroySurface
(JNIEnv *_env, jobject _this, jobject dpy, jobject surface) {
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface);
_returnValue = eglDestroySurface(
(EGLDisplay)dpy_native,
(EGLSurface)surface_native
);
return _returnValue;
}
/* EGLBoolean eglQuerySurface ( EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value ) */
static jboolean
android_eglQuerySurface
(JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint attribute, jintArray value_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType;
const char * _exceptionMessage;
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface);
EGLint *value_base = (EGLint *) 0;
jint _remaining;
EGLint *value = (EGLint *) 0;
if (!value_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "value == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(value_ref) - offset;
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < 1 < needed";
goto exit;
}
value_base = (EGLint *)
_env->GetPrimitiveArrayCritical(value_ref, (jboolean *)0);
value = value_base + offset;
_returnValue = eglQuerySurface(
(EGLDisplay)dpy_native,
(EGLSurface)surface_native,
(EGLint)attribute,
(EGLint *)value
);
exit:
if (value_base) {
_env->ReleasePrimitiveArrayCritical(value_ref, value_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
return _returnValue;
}
/* EGLBoolean eglBindAPI ( EGLenum api ) */
static jboolean
android_eglBindAPI
(JNIEnv *_env, jobject _this, jint api) {
EGLBoolean _returnValue = (EGLBoolean) 0;
_returnValue = eglBindAPI(
(EGLenum)api
);
return _returnValue;
}
/* EGLenum eglQueryAPI ( void ) */
static jint
android_eglQueryAPI
(JNIEnv *_env, jobject _this) {
EGLenum _returnValue = (EGLenum) 0;
_returnValue = eglQueryAPI();
return _returnValue;
}
/* EGLBoolean eglWaitClient ( void ) */
static jboolean
android_eglWaitClient
(JNIEnv *_env, jobject _this) {
EGLBoolean _returnValue = (EGLBoolean) 0;
_returnValue = eglWaitClient();
return _returnValue;
}
/* EGLBoolean eglReleaseThread ( void ) */
static jboolean
android_eglReleaseThread
(JNIEnv *_env, jobject _this) {
EGLBoolean _returnValue = (EGLBoolean) 0;
_returnValue = eglReleaseThread();
return _returnValue;
}
/* EGLSurface eglCreatePbufferFromClientBuffer ( EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list ) */
static jobject
android_eglCreatePbufferFromClientBuffer
(JNIEnv *_env, jobject _this, jobject dpy, jint buftype, jint buffer, jobject config, 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);
bool attrib_list_sentinel = false;
EGLint *attrib_list_base = (EGLint *) 0;
jint _remaining;
EGLint *attrib_list = (EGLint *) 0;
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;
}
_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 = false;
for (int i = _remaining - 1; i >= 0; i--) {
if (attrib_list[i] == EGL_NONE){
attrib_list_sentinel = true;
break;
}
}
if (attrib_list_sentinel == false) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "attrib_list must contain EGL_NONE!";
goto exit;
}
_returnValue = eglCreatePbufferFromClientBuffer(
(EGLDisplay)dpy_native,
(EGLenum)buftype,
(EGLClientBuffer)buffer,
(EGLConfig)config_native,
(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);
}
/* EGLBoolean eglSurfaceAttrib ( EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value ) */
static jboolean
android_eglSurfaceAttrib
(JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint attribute, jint value) {
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface);
_returnValue = eglSurfaceAttrib(
(EGLDisplay)dpy_native,
(EGLSurface)surface_native,
(EGLint)attribute,
(EGLint)value
);
return _returnValue;
}
/* EGLBoolean eglBindTexImage ( EGLDisplay dpy, EGLSurface surface, EGLint buffer ) */
static jboolean
android_eglBindTexImage
(JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint buffer) {
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface);
_returnValue = eglBindTexImage(
(EGLDisplay)dpy_native,
(EGLSurface)surface_native,
(EGLint)buffer
);
return _returnValue;
}
/* EGLBoolean eglReleaseTexImage ( EGLDisplay dpy, EGLSurface surface, EGLint buffer ) */
static jboolean
android_eglReleaseTexImage
(JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint buffer) {
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface);
_returnValue = eglReleaseTexImage(
(EGLDisplay)dpy_native,
(EGLSurface)surface_native,
(EGLint)buffer
);
return _returnValue;
}
/* EGLBoolean eglSwapInterval ( EGLDisplay dpy, EGLint interval ) */
static jboolean
android_eglSwapInterval
(JNIEnv *_env, jobject _this, jobject dpy, jint interval) {
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
_returnValue = eglSwapInterval(
(EGLDisplay)dpy_native,
(EGLint)interval
);
return _returnValue;
}
/* EGLContext eglCreateContext ( EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list ) */
static jobject
android_eglCreateContext
(JNIEnv *_env, jobject _this, jobject dpy, jobject config, jobject share_context, jintArray attrib_list_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType;
const char * _exceptionMessage;
EGLContext _returnValue = (EGLContext) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
EGLContext share_context_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, share_context);
bool attrib_list_sentinel = false;
EGLint *attrib_list_base = (EGLint *) 0;
jint _remaining;
EGLint *attrib_list = (EGLint *) 0;
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;
}
_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 = false;
for (int i = _remaining - 1; i >= 0; i--) {
if (attrib_list[i] == EGL_NONE){
attrib_list_sentinel = true;
break;
}
}
if (attrib_list_sentinel == false) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "attrib_list must contain EGL_NONE!";
goto exit;
}
_returnValue = eglCreateContext(
(EGLDisplay)dpy_native,
(EGLConfig)config_native,
(EGLContext)share_context_native,
(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, eglcontextClass, eglcontextConstructor, _returnValue);
}
/* EGLBoolean eglDestroyContext ( EGLDisplay dpy, EGLContext ctx ) */
static jboolean
android_eglDestroyContext
(JNIEnv *_env, jobject _this, jobject dpy, jobject ctx) {
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLContext ctx_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, ctx);
_returnValue = eglDestroyContext(
(EGLDisplay)dpy_native,
(EGLContext)ctx_native
);
return _returnValue;
}
/* EGLBoolean eglMakeCurrent ( EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx ) */
static jboolean
android_eglMakeCurrent
(JNIEnv *_env, jobject _this, jobject dpy, jobject draw, jobject read, jobject ctx) {
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLSurface draw_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, draw);
EGLSurface read_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, read);
EGLContext ctx_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, ctx);
_returnValue = eglMakeCurrent(
(EGLDisplay)dpy_native,
(EGLSurface)draw_native,
(EGLSurface)read_native,
(EGLContext)ctx_native
);
return _returnValue;
}
/* EGLContext eglGetCurrentContext ( void ) */
static jobject
android_eglGetCurrentContext
(JNIEnv *_env, jobject _this) {
EGLContext _returnValue = (EGLContext) 0;
_returnValue = eglGetCurrentContext();
return toEGLHandle(_env, eglcontextClass, eglcontextConstructor, _returnValue);
}
/* EGLSurface eglGetCurrentSurface ( EGLint readdraw ) */
static jobject
android_eglGetCurrentSurface
(JNIEnv *_env, jobject _this, jint readdraw) {
EGLSurface _returnValue = (EGLSurface) 0;
_returnValue = eglGetCurrentSurface(
(EGLint)readdraw
);
return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
}
/* EGLDisplay eglGetCurrentDisplay ( void ) */
static jobject
android_eglGetCurrentDisplay
(JNIEnv *_env, jobject _this) {
EGLDisplay _returnValue = (EGLDisplay) 0;
_returnValue = eglGetCurrentDisplay();
return toEGLHandle(_env, egldisplayClass, egldisplayConstructor, _returnValue);
}
/* EGLBoolean eglQueryContext ( EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value ) */
static jboolean
android_eglQueryContext
(JNIEnv *_env, jobject _this, jobject dpy, jobject ctx, jint attribute, jintArray value_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType;
const char * _exceptionMessage;
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLContext ctx_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, ctx);
EGLint *value_base = (EGLint *) 0;
jint _remaining;
EGLint *value = (EGLint *) 0;
if (!value_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "value == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(value_ref) - offset;
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < 1 < needed";
goto exit;
}
value_base = (EGLint *)
_env->GetPrimitiveArrayCritical(value_ref, (jboolean *)0);
value = value_base + offset;
_returnValue = eglQueryContext(
(EGLDisplay)dpy_native,
(EGLContext)ctx_native,
(EGLint)attribute,
(EGLint *)value
);
exit:
if (value_base) {
_env->ReleasePrimitiveArrayCritical(value_ref, value_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
return _returnValue;
}
/* EGLBoolean eglWaitGL ( void ) */
static jboolean
android_eglWaitGL
(JNIEnv *_env, jobject _this) {
EGLBoolean _returnValue = (EGLBoolean) 0;
_returnValue = eglWaitGL();
return _returnValue;
}
/* EGLBoolean eglWaitNative ( EGLint engine ) */
static jboolean
android_eglWaitNative
(JNIEnv *_env, jobject _this, jint engine) {
EGLBoolean _returnValue = (EGLBoolean) 0;
_returnValue = eglWaitNative(
(EGLint)engine
);
return _returnValue;
}
/* EGLBoolean eglSwapBuffers ( EGLDisplay dpy, EGLSurface surface ) */
static jboolean
android_eglSwapBuffers
(JNIEnv *_env, jobject _this, jobject dpy, jobject surface) {
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface);
_returnValue = eglSwapBuffers(
(EGLDisplay)dpy_native,
(EGLSurface)surface_native
);
return _returnValue;
}
/* EGLBoolean eglCopyBuffers ( EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target ) */
static jboolean
android_eglCopyBuffers
(JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint target) {
jniThrowException(_env, "java/lang/UnsupportedOperationException",
"eglCopyBuffers");
return (EGLBoolean) 0;
}
static const char *classPathName = "android/opengl/EGL14";
static JNINativeMethod methods[] = {
{"_nativeClassInit", "()V", (void*)nativeClassInit },
{"eglGetError", "()I", (void *) android_eglGetError },
{"eglGetDisplay", "(I)Landroid/opengl/EGLDisplay;", (void *) android_eglGetDisplay },
{"eglInitialize", "(Landroid/opengl/EGLDisplay;[II[II)Z", (void *) android_eglInitialize },
{"eglTerminate", "(Landroid/opengl/EGLDisplay;)Z", (void *) android_eglTerminate },
{"eglQueryString", "(Landroid/opengl/EGLDisplay;I)Ljava/lang/String;", (void *) android_eglQueryString__Landroind_opengl_EGLDisplay_2I },
{"eglGetConfigs", "(Landroid/opengl/EGLDisplay;[Landroid/opengl/EGLConfig;II[II)Z", (void *) android_eglGetConfigs },
{"eglChooseConfig", "(Landroid/opengl/EGLDisplay;[II[Landroid/opengl/EGLConfig;II[II)Z", (void *) android_eglChooseConfig },
{"eglGetConfigAttrib", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;I[II)Z", (void *) android_eglGetConfigAttrib },
{"_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 },
{"eglCreatePbufferSurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePbufferSurface },
{"eglCreatePixmapSurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;I[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePixmapSurface },
{"eglDestroySurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;)Z", (void *) android_eglDestroySurface },
{"eglQuerySurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;I[II)Z", (void *) android_eglQuerySurface },
{"eglBindAPI", "(I)Z", (void *) android_eglBindAPI },
{"eglQueryAPI", "()I", (void *) android_eglQueryAPI },
{"eglWaitClient", "()Z", (void *) android_eglWaitClient },
{"eglReleaseThread", "()Z", (void *) android_eglReleaseThread },
{"eglCreatePbufferFromClientBuffer", "(Landroid/opengl/EGLDisplay;IILandroid/opengl/EGLConfig;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePbufferFromClientBuffer },
{"eglSurfaceAttrib", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;II)Z", (void *) android_eglSurfaceAttrib },
{"eglBindTexImage", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;I)Z", (void *) android_eglBindTexImage },
{"eglReleaseTexImage", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;I)Z", (void *) android_eglReleaseTexImage },
{"eglSwapInterval", "(Landroid/opengl/EGLDisplay;I)Z", (void *) android_eglSwapInterval },
{"eglCreateContext", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;Landroid/opengl/EGLContext;[II)Landroid/opengl/EGLContext;", (void *) android_eglCreateContext },
{"eglDestroyContext", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLContext;)Z", (void *) android_eglDestroyContext },
{"eglMakeCurrent", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;Landroid/opengl/EGLSurface;Landroid/opengl/EGLContext;)Z", (void *) android_eglMakeCurrent },
{"eglGetCurrentContext", "()Landroid/opengl/EGLContext;", (void *) android_eglGetCurrentContext },
{"eglGetCurrentSurface", "(I)Landroid/opengl/EGLSurface;", (void *) android_eglGetCurrentSurface },
{"eglGetCurrentDisplay", "()Landroid/opengl/EGLDisplay;", (void *) android_eglGetCurrentDisplay },
{"eglQueryContext", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLContext;I[II)Z", (void *) android_eglQueryContext },
{"eglWaitGL", "()Z", (void *) android_eglWaitGL },
{"eglWaitNative", "(I)Z", (void *) android_eglWaitNative },
{"eglSwapBuffers", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;)Z", (void *) android_eglSwapBuffers },
{"eglCopyBuffers", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;I)Z", (void *) android_eglCopyBuffers },
};
int register_android_opengl_jni_EGL14(JNIEnv *_env)
{
int err;
err = android::AndroidRuntime::registerNativeMethods(_env, classPathName, methods, NELEM(methods));
return err;
}
|