The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright 2006, The Android Open Source Project |
| 4 | ** |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 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 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 8 | ** |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 10 | ** |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 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 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 18 | #include "JNIHelp.h" |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | #include <android_runtime/AndroidRuntime.h> |
Dianne Hackborn | 289b9b6 | 2010-07-09 11:44:11 -0700 | [diff] [blame] | 20 | #include <android_runtime/android_view_Surface.h> |
Romain Guy | e5e0c50 | 2011-06-15 15:18:31 -0700 | [diff] [blame] | 21 | #include <android_runtime/android_graphics_SurfaceTexture.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | #include <utils/misc.h> |
| 23 | |
Mathias Agopian | 8335f1c | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 24 | |
| 25 | #include <EGL/egl_display.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | #include <EGL/egl.h> |
| 27 | #include <GLES/gl.h> |
| 28 | |
Mathias Agopian | 8335f1c | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 29 | #include <gui/Surface.h> |
| 30 | #include <gui/SurfaceTexture.h> |
| 31 | #include <gui/SurfaceTextureClient.h> |
Romain Guy | 8ff6b9e | 2011-11-09 20:10:18 -0800 | [diff] [blame] | 32 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | #include <SkBitmap.h> |
| 34 | #include <SkPixelRef.h> |
| 35 | |
Mathias Agopian | af01feaf | 2012-02-24 18:25:41 -0800 | [diff] [blame] | 36 | #include <ui/ANativeObjectBase.h> |
| 37 | |
Dianne Hackborn | 54a181b | 2010-06-30 18:35:14 -0700 | [diff] [blame] | 38 | namespace android { |
Mathias Agopian | 8b73ae4 | 2010-06-10 17:02:51 -0700 | [diff] [blame] | 39 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | static jclass gConfig_class; |
| 41 | |
| 42 | static jmethodID gConfig_ctorID; |
| 43 | |
| 44 | static jfieldID gDisplay_EGLDisplayFieldID; |
| 45 | static jfieldID gContext_EGLContextFieldID; |
| 46 | static jfieldID gSurface_EGLSurfaceFieldID; |
| 47 | static jfieldID gSurface_NativePixelRefFieldID; |
| 48 | static jfieldID gConfig_EGLConfigFieldID; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | static jfieldID gBitmap_NativeBitmapFieldID; |
| 50 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | static inline EGLDisplay getDisplay(JNIEnv* env, jobject o) { |
| 52 | if (!o) return EGL_NO_DISPLAY; |
| 53 | return (EGLDisplay)env->GetIntField(o, gDisplay_EGLDisplayFieldID); |
| 54 | } |
| 55 | static inline EGLSurface getSurface(JNIEnv* env, jobject o) { |
| 56 | if (!o) return EGL_NO_SURFACE; |
| 57 | return (EGLSurface)env->GetIntField(o, gSurface_EGLSurfaceFieldID); |
| 58 | } |
| 59 | static inline EGLContext getContext(JNIEnv* env, jobject o) { |
| 60 | if (!o) return EGL_NO_CONTEXT; |
| 61 | return (EGLContext)env->GetIntField(o, gContext_EGLContextFieldID); |
| 62 | } |
| 63 | static inline EGLConfig getConfig(JNIEnv* env, jobject o) { |
| 64 | if (!o) return 0; |
| 65 | return (EGLConfig)env->GetIntField(o, gConfig_EGLConfigFieldID); |
| 66 | } |
| 67 | static void nativeClassInit(JNIEnv *_env, jclass eglImplClass) |
| 68 | { |
Elliott Hughes | dd66bcb | 2011-04-12 11:28:59 -0700 | [diff] [blame] | 69 | jclass config_class = _env->FindClass("com/google/android/gles_jni/EGLConfigImpl"); |
| 70 | gConfig_class = (jclass) _env->NewGlobalRef(config_class); |
| 71 | gConfig_ctorID = _env->GetMethodID(gConfig_class, "<init>", "(I)V"); |
| 72 | gConfig_EGLConfigFieldID = _env->GetFieldID(gConfig_class, "mEGLConfig", "I"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 73 | |
Elliott Hughes | dd66bcb | 2011-04-12 11:28:59 -0700 | [diff] [blame] | 74 | jclass display_class = _env->FindClass("com/google/android/gles_jni/EGLDisplayImpl"); |
| 75 | gDisplay_EGLDisplayFieldID = _env->GetFieldID(display_class, "mEGLDisplay", "I"); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 76 | |
Elliott Hughes | dd66bcb | 2011-04-12 11:28:59 -0700 | [diff] [blame] | 77 | jclass context_class = _env->FindClass("com/google/android/gles_jni/EGLContextImpl"); |
| 78 | gContext_EGLContextFieldID = _env->GetFieldID(context_class, "mEGLContext", "I"); |
| 79 | |
| 80 | jclass surface_class = _env->FindClass("com/google/android/gles_jni/EGLSurfaceImpl"); |
| 81 | gSurface_EGLSurfaceFieldID = _env->GetFieldID(surface_class, "mEGLSurface", "I"); |
| 82 | gSurface_NativePixelRefFieldID = _env->GetFieldID(surface_class, "mNativePixelRef", "I"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 83 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | jclass bitmap_class = _env->FindClass("android/graphics/Bitmap"); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 85 | gBitmap_NativeBitmapFieldID = _env->GetFieldID(bitmap_class, "mNativeBitmap", "I"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | } |
| 87 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 88 | static const jint gNull_attrib_base[] = {EGL_NONE}; |
| 89 | |
| 90 | static bool validAttribList(JNIEnv *_env, jintArray attrib_list) { |
| 91 | if (attrib_list == NULL) { |
| 92 | return true; |
| 93 | } |
| 94 | jsize len = _env->GetArrayLength(attrib_list); |
| 95 | if (len < 1) { |
| 96 | return false; |
| 97 | } |
| 98 | jint item = 0; |
| 99 | _env->GetIntArrayRegion(attrib_list, len-1, 1, &item); |
| 100 | return item == EGL_NONE; |
| 101 | } |
| 102 | |
| 103 | static jint* beginNativeAttribList(JNIEnv *_env, jintArray attrib_list) { |
| 104 | if (attrib_list != NULL) { |
| 105 | return (jint *)_env->GetPrimitiveArrayCritical(attrib_list, (jboolean *)0); |
| 106 | } else { |
| 107 | return(jint*) gNull_attrib_base; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | static void endNativeAttributeList(JNIEnv *_env, jintArray attrib_list, jint* attrib_base) { |
| 112 | if (attrib_list != NULL) { |
| 113 | _env->ReleasePrimitiveArrayCritical(attrib_list, attrib_base, JNI_ABORT); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | static jboolean jni_eglInitialize(JNIEnv *_env, jobject _this, jobject display, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 118 | jintArray major_minor) { |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 119 | if (display == NULL || (major_minor != NULL && |
| 120 | _env->GetArrayLength(major_minor) < 2)) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 121 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 122 | return JNI_FALSE; |
| 123 | } |
| 124 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 125 | EGLDisplay dpy = getDisplay(_env, display); |
| 126 | jboolean success = eglInitialize(dpy, NULL, NULL); |
| 127 | if (success && major_minor) { |
| 128 | int len = _env->GetArrayLength(major_minor); |
| 129 | if (len) { |
| 130 | // we're exposing only EGL 1.0 |
| 131 | jint* base = (jint *)_env->GetPrimitiveArrayCritical(major_minor, (jboolean *)0); |
| 132 | if (len >= 1) base[0] = 1; |
| 133 | if (len >= 2) base[1] = 0; |
| 134 | _env->ReleasePrimitiveArrayCritical(major_minor, base, JNI_ABORT); |
| 135 | } |
| 136 | } |
| 137 | return success; |
| 138 | } |
| 139 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 140 | static jboolean jni_eglQueryContext(JNIEnv *_env, jobject _this, jobject display, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 141 | jobject context, jint attribute, jintArray value) { |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 142 | if (display == NULL || context == NULL || value == NULL |
| 143 | || _env->GetArrayLength(value) < 1) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 144 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 145 | return JNI_FALSE; |
| 146 | } |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 147 | EGLDisplay dpy = getDisplay(_env, display); |
| 148 | EGLContext ctx = getContext(_env, context); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 149 | jboolean success = JNI_FALSE; |
| 150 | int len = _env->GetArrayLength(value); |
| 151 | if (len) { |
| 152 | jint* base = (jint *)_env->GetPrimitiveArrayCritical(value, (jboolean *)0); |
| 153 | success = eglQueryContext(dpy, ctx, attribute, base); |
| 154 | _env->ReleasePrimitiveArrayCritical(value, base, JNI_ABORT); |
| 155 | } |
| 156 | return success; |
| 157 | } |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 158 | |
| 159 | static jboolean jni_eglQuerySurface(JNIEnv *_env, jobject _this, jobject display, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 160 | jobject surface, jint attribute, jintArray value) { |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 161 | if (display == NULL || surface == NULL || value == NULL |
| 162 | || _env->GetArrayLength(value) < 1) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 163 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 164 | return JNI_FALSE; |
| 165 | } |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 166 | EGLDisplay dpy = getDisplay(_env, display); |
| 167 | EGLContext sur = getSurface(_env, surface); |
| 168 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 169 | jboolean success = JNI_FALSE; |
| 170 | int len = _env->GetArrayLength(value); |
| 171 | if (len) { |
| 172 | jint* base = (jint *)_env->GetPrimitiveArrayCritical(value, (jboolean *)0); |
| 173 | success = eglQuerySurface(dpy, sur, attribute, base); |
| 174 | _env->ReleasePrimitiveArrayCritical(value, base, JNI_ABORT); |
| 175 | } |
| 176 | return success; |
| 177 | } |
| 178 | |
Romain Guy | 8ff6b9e | 2011-11-09 20:10:18 -0800 | [diff] [blame] | 179 | static jint jni_getInitCount(JNIEnv *_env, jobject _clazz, jobject display) { |
| 180 | EGLDisplay dpy = getDisplay(_env, display); |
Jesse Hall | 9847f31 | 2012-04-05 10:37:13 -0700 | [diff] [blame] | 181 | egl_display_t* eglDisplay = get_display_nowake(dpy); |
Romain Guy | 8ff6b9e | 2011-11-09 20:10:18 -0800 | [diff] [blame] | 182 | return eglDisplay ? eglDisplay->getRefsCount() : 0; |
| 183 | } |
| 184 | |
| 185 | static jboolean jni_eglReleaseThread(JNIEnv *_env, jobject _this) { |
| 186 | return eglReleaseThread(); |
| 187 | } |
| 188 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 189 | static jboolean jni_eglChooseConfig(JNIEnv *_env, jobject _this, jobject display, |
| 190 | jintArray attrib_list, jobjectArray configs, jint config_size, jintArray num_config) { |
| 191 | if (display == NULL |
| 192 | || !validAttribList(_env, attrib_list) |
| 193 | || (configs != NULL && _env->GetArrayLength(configs) < config_size) |
| 194 | || (num_config != NULL && _env->GetArrayLength(num_config) < 1)) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 195 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 196 | return JNI_FALSE; |
| 197 | } |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 198 | EGLDisplay dpy = getDisplay(_env, display); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 199 | jboolean success = JNI_FALSE; |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 200 | |
| 201 | if (configs == NULL) { |
| 202 | config_size = 0; |
| 203 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 204 | EGLConfig nativeConfigs[config_size]; |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 205 | |
| 206 | int num = 0; |
| 207 | jint* attrib_base = beginNativeAttribList(_env, attrib_list); |
| 208 | success = eglChooseConfig(dpy, attrib_base, configs ? nativeConfigs : 0, config_size, &num); |
| 209 | endNativeAttributeList(_env, attrib_list, attrib_base); |
| 210 | |
| 211 | if (num_config != NULL) { |
| 212 | _env->SetIntArrayRegion(num_config, 0, 1, (jint*) &num); |
| 213 | } |
| 214 | |
| 215 | if (success && configs!=NULL) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 216 | for (int i=0 ; i<num ; i++) { |
| 217 | jobject obj = _env->NewObject(gConfig_class, gConfig_ctorID, (jint)nativeConfigs[i]); |
| 218 | _env->SetObjectArrayElement(configs, i, obj); |
| 219 | } |
| 220 | } |
| 221 | return success; |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 222 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 223 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 224 | static jint jni_eglCreateContext(JNIEnv *_env, jobject _this, jobject display, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 225 | jobject config, jobject share_context, jintArray attrib_list) { |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 226 | if (display == NULL || config == NULL || share_context == NULL |
| 227 | || !validAttribList(_env, attrib_list)) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 228 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 229 | return JNI_FALSE; |
| 230 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 231 | EGLDisplay dpy = getDisplay(_env, display); |
| 232 | EGLConfig cnf = getConfig(_env, config); |
| 233 | EGLContext shr = getContext(_env, share_context); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 234 | jint* base = beginNativeAttribList(_env, attrib_list); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 235 | EGLContext ctx = eglCreateContext(dpy, cnf, shr, base); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 236 | endNativeAttributeList(_env, attrib_list, base); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 237 | return (jint)ctx; |
| 238 | } |
| 239 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 240 | static jint jni_eglCreatePbufferSurface(JNIEnv *_env, jobject _this, jobject display, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 241 | jobject config, jintArray attrib_list) { |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 242 | if (display == NULL || config == NULL |
| 243 | || !validAttribList(_env, attrib_list)) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 244 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 245 | return JNI_FALSE; |
| 246 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 247 | EGLDisplay dpy = getDisplay(_env, display); |
| 248 | EGLConfig cnf = getConfig(_env, config); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 249 | jint* base = beginNativeAttribList(_env, attrib_list); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 250 | EGLSurface sur = eglCreatePbufferSurface(dpy, cnf, base); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 251 | endNativeAttributeList(_env, attrib_list, base); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 252 | return (jint)sur; |
| 253 | } |
| 254 | |
| 255 | static PixelFormat convertPixelFormat(SkBitmap::Config format) |
| 256 | { |
| 257 | switch (format) { |
| 258 | case SkBitmap::kARGB_8888_Config: return PIXEL_FORMAT_RGBA_8888; |
| 259 | case SkBitmap::kARGB_4444_Config: return PIXEL_FORMAT_RGBA_4444; |
| 260 | case SkBitmap::kRGB_565_Config: return PIXEL_FORMAT_RGB_565; |
| 261 | case SkBitmap::kA8_Config: return PIXEL_FORMAT_A_8; |
| 262 | default: return PIXEL_FORMAT_NONE; |
| 263 | } |
| 264 | } |
| 265 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 266 | static void jni_eglCreatePixmapSurface(JNIEnv *_env, jobject _this, jobject out_sur, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 267 | jobject display, jobject config, jobject native_pixmap, |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 268 | jintArray attrib_list) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 269 | { |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 270 | if (display == NULL || config == NULL || native_pixmap == NULL |
| 271 | || !validAttribList(_env, attrib_list)) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 272 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 273 | return; |
| 274 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 275 | EGLDisplay dpy = getDisplay(_env, display); |
| 276 | EGLConfig cnf = getConfig(_env, config); |
| 277 | jint* base = 0; |
| 278 | |
| 279 | SkBitmap const * nativeBitmap = |
| 280 | (SkBitmap const *)_env->GetIntField(native_pixmap, |
| 281 | gBitmap_NativeBitmapFieldID); |
| 282 | SkPixelRef* ref = nativeBitmap ? nativeBitmap->pixelRef() : 0; |
| 283 | if (ref == NULL) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 284 | jniThrowException(_env, "java/lang/IllegalArgumentException", "Bitmap has no PixelRef"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 285 | return; |
| 286 | } |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 287 | |
Derek Sollenberger | 6062c59 | 2011-02-22 13:55:04 -0500 | [diff] [blame] | 288 | SkSafeRef(ref); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 289 | ref->lockPixels(); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 290 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 291 | egl_native_pixmap_t pixmap; |
| 292 | pixmap.version = sizeof(pixmap); |
| 293 | pixmap.width = nativeBitmap->width(); |
| 294 | pixmap.height = nativeBitmap->height(); |
| 295 | pixmap.stride = nativeBitmap->rowBytes() / nativeBitmap->bytesPerPixel(); |
| 296 | pixmap.format = convertPixelFormat(nativeBitmap->config()); |
| 297 | pixmap.data = (uint8_t*)ref->pixels(); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 298 | |
| 299 | base = beginNativeAttribList(_env, attrib_list); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 300 | EGLSurface sur = eglCreatePixmapSurface(dpy, cnf, &pixmap, base); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 301 | endNativeAttributeList(_env, attrib_list, base); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 302 | |
| 303 | if (sur != EGL_NO_SURFACE) { |
| 304 | _env->SetIntField(out_sur, gSurface_EGLSurfaceFieldID, (int)sur); |
| 305 | _env->SetIntField(out_sur, gSurface_NativePixelRefFieldID, (int)ref); |
| 306 | } else { |
| 307 | ref->unlockPixels(); |
Derek Sollenberger | 6062c59 | 2011-02-22 13:55:04 -0500 | [diff] [blame] | 308 | SkSafeUnref(ref); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 309 | } |
| 310 | } |
| 311 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 312 | static jint jni_eglCreateWindowSurface(JNIEnv *_env, jobject _this, jobject display, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 313 | jobject config, jobject native_window, jintArray attrib_list) { |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 314 | if (display == NULL || config == NULL |
| 315 | || !validAttribList(_env, attrib_list)) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 316 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 317 | return JNI_FALSE; |
| 318 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 319 | EGLDisplay dpy = getDisplay(_env, display); |
| 320 | EGLContext cnf = getConfig(_env, config); |
Dianne Hackborn | 54a181b | 2010-06-30 18:35:14 -0700 | [diff] [blame] | 321 | sp<ANativeWindow> window; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 322 | if (native_window == NULL) { |
| 323 | not_valid_surface: |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 324 | jniThrowException(_env, "java/lang/IllegalArgumentException", |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 325 | "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface"); |
| 326 | return 0; |
| 327 | } |
Mathias Agopian | 8b73ae4 | 2010-06-10 17:02:51 -0700 | [diff] [blame] | 328 | |
Jeff Brown | 64a55af | 2012-08-26 02:47:39 -0700 | [diff] [blame] | 329 | window = android_view_Surface_getNativeWindow(_env, native_window); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 330 | if (window == NULL) |
| 331 | goto not_valid_surface; |
| 332 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 333 | jint* base = beginNativeAttribList(_env, attrib_list); |
Dianne Hackborn | 54a181b | 2010-06-30 18:35:14 -0700 | [diff] [blame] | 334 | EGLSurface sur = eglCreateWindowSurface(dpy, cnf, window.get(), base); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 335 | endNativeAttributeList(_env, attrib_list, base); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 336 | return (jint)sur; |
| 337 | } |
| 338 | |
Romain Guy | 8f0095c | 2011-05-02 17:24:22 -0700 | [diff] [blame] | 339 | static jint jni_eglCreateWindowSurfaceTexture(JNIEnv *_env, jobject _this, jobject display, |
Romain Guy | e5e0c50 | 2011-06-15 15:18:31 -0700 | [diff] [blame] | 340 | jobject config, jobject native_window, jintArray attrib_list) { |
Romain Guy | 8f0095c | 2011-05-02 17:24:22 -0700 | [diff] [blame] | 341 | if (display == NULL || config == NULL |
| 342 | || !validAttribList(_env, attrib_list)) { |
| 343 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
| 344 | return JNI_FALSE; |
| 345 | } |
| 346 | EGLDisplay dpy = getDisplay(_env, display); |
| 347 | EGLContext cnf = getConfig(_env, config); |
| 348 | sp<ANativeWindow> window; |
| 349 | if (native_window == 0) { |
| 350 | not_valid_surface: |
| 351 | jniThrowException(_env, "java/lang/IllegalArgumentException", |
| 352 | "Make sure the SurfaceTexture is valid"); |
| 353 | return 0; |
| 354 | } |
| 355 | |
Romain Guy | e5e0c50 | 2011-06-15 15:18:31 -0700 | [diff] [blame] | 356 | sp<SurfaceTexture> surfaceTexture(SurfaceTexture_getSurfaceTexture(_env, native_window)); |
Romain Guy | 8f0095c | 2011-05-02 17:24:22 -0700 | [diff] [blame] | 357 | |
| 358 | window = new SurfaceTextureClient(surfaceTexture); |
| 359 | if (window == NULL) |
| 360 | goto not_valid_surface; |
| 361 | |
| 362 | jint* base = beginNativeAttribList(_env, attrib_list); |
| 363 | EGLSurface sur = eglCreateWindowSurface(dpy, cnf, window.get(), base); |
| 364 | endNativeAttributeList(_env, attrib_list, base); |
| 365 | return (jint)sur; |
| 366 | } |
| 367 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 368 | static jboolean jni_eglGetConfigAttrib(JNIEnv *_env, jobject _this, jobject display, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 369 | jobject config, jint attribute, jintArray value) { |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 370 | if (display == NULL || config == NULL |
| 371 | || (value == NULL || _env->GetArrayLength(value) < 1)) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 372 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 373 | return JNI_FALSE; |
| 374 | } |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 375 | EGLDisplay dpy = getDisplay(_env, display); |
| 376 | EGLContext cnf = getConfig(_env, config); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 377 | jboolean success = JNI_FALSE; |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 378 | jint localValue; |
| 379 | success = eglGetConfigAttrib(dpy, cnf, attribute, &localValue); |
| 380 | if (success) { |
| 381 | _env->SetIntArrayRegion(value, 0, 1, &localValue); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 382 | } |
| 383 | return success; |
| 384 | } |
| 385 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 386 | static jboolean jni_eglGetConfigs(JNIEnv *_env, jobject _this, jobject display, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 387 | jobjectArray configs, jint config_size, jintArray num_config) { |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 388 | if (display == NULL || (configs != NULL && _env->GetArrayLength(configs) < config_size) |
| 389 | || (num_config != NULL && _env->GetArrayLength(num_config) < 1)) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 390 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 391 | return JNI_FALSE; |
| 392 | } |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 393 | EGLDisplay dpy = getDisplay(_env, display); |
| 394 | jboolean success = JNI_FALSE; |
| 395 | if (configs == NULL) { |
| 396 | config_size = 0; |
| 397 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 398 | EGLConfig nativeConfigs[config_size]; |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 399 | int num; |
| 400 | success = eglGetConfigs(dpy, configs ? nativeConfigs : 0, config_size, &num); |
| 401 | if (num_config != NULL) { |
| 402 | _env->SetIntArrayRegion(num_config, 0, 1, (jint*) &num); |
| 403 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 404 | if (success && configs) { |
| 405 | for (int i=0 ; i<num ; i++) { |
| 406 | jobject obj = _env->NewObject(gConfig_class, gConfig_ctorID, (jint)nativeConfigs[i]); |
| 407 | _env->SetObjectArrayElement(configs, i, obj); |
| 408 | } |
| 409 | } |
| 410 | return success; |
| 411 | } |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 412 | |
| 413 | static jint jni_eglGetError(JNIEnv *_env, jobject _this) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 414 | EGLint error = eglGetError(); |
| 415 | return error; |
| 416 | } |
| 417 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 418 | static jint jni_eglGetCurrentContext(JNIEnv *_env, jobject _this) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 419 | return (jint)eglGetCurrentContext(); |
| 420 | } |
| 421 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 422 | static jint jni_eglGetCurrentDisplay(JNIEnv *_env, jobject _this) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 423 | return (jint)eglGetCurrentDisplay(); |
| 424 | } |
| 425 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 426 | static jint jni_eglGetCurrentSurface(JNIEnv *_env, jobject _this, jint readdraw) { |
Romain Guy | 9b7146d | 2011-03-07 18:05:04 -0800 | [diff] [blame] | 427 | if ((readdraw != EGL_READ) && (readdraw != EGL_DRAW)) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 428 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 429 | return 0; |
| 430 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 431 | return (jint)eglGetCurrentSurface(readdraw); |
| 432 | } |
| 433 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 434 | static jboolean jni_eglDestroyContext(JNIEnv *_env, jobject _this, jobject display, jobject context) { |
| 435 | if (display == NULL || context == NULL) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 436 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 437 | return JNI_FALSE; |
| 438 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 439 | EGLDisplay dpy = getDisplay(_env, display); |
| 440 | EGLContext ctx = getContext(_env, context); |
| 441 | return eglDestroyContext(dpy, ctx); |
| 442 | } |
| 443 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 444 | static jboolean jni_eglDestroySurface(JNIEnv *_env, jobject _this, jobject display, jobject surface) { |
| 445 | if (display == NULL || surface == NULL) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 446 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 447 | return JNI_FALSE; |
| 448 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 449 | EGLDisplay dpy = getDisplay(_env, display); |
| 450 | EGLSurface sur = getSurface(_env, surface); |
| 451 | |
| 452 | if (sur) { |
| 453 | SkPixelRef* ref = (SkPixelRef*)(_env->GetIntField(surface, |
| 454 | gSurface_NativePixelRefFieldID)); |
| 455 | if (ref) { |
| 456 | ref->unlockPixels(); |
Derek Sollenberger | 6062c59 | 2011-02-22 13:55:04 -0500 | [diff] [blame] | 457 | SkSafeUnref(ref); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 458 | } |
| 459 | } |
| 460 | return eglDestroySurface(dpy, sur); |
| 461 | } |
| 462 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 463 | static jint jni_eglGetDisplay(JNIEnv *_env, jobject _this, jobject native_display) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 464 | return (jint)eglGetDisplay(EGL_DEFAULT_DISPLAY); |
| 465 | } |
| 466 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 467 | static jboolean jni_eglMakeCurrent(JNIEnv *_env, jobject _this, jobject display, jobject draw, jobject read, jobject context) { |
| 468 | if (display == NULL || draw == NULL || read == NULL || context == NULL) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 469 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 470 | return JNI_FALSE; |
| 471 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 472 | EGLDisplay dpy = getDisplay(_env, display); |
| 473 | EGLSurface sdr = getSurface(_env, draw); |
| 474 | EGLSurface srd = getSurface(_env, read); |
| 475 | EGLContext ctx = getContext(_env, context); |
| 476 | return eglMakeCurrent(dpy, sdr, srd, ctx); |
| 477 | } |
| 478 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 479 | static jstring jni_eglQueryString(JNIEnv *_env, jobject _this, jobject display, jint name) { |
| 480 | if (display == NULL) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 481 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 482 | return NULL; |
| 483 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 484 | EGLDisplay dpy = getDisplay(_env, display); |
| 485 | const char* chars = eglQueryString(dpy, name); |
| 486 | return _env->NewStringUTF(chars); |
| 487 | } |
| 488 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 489 | static jboolean jni_eglSwapBuffers(JNIEnv *_env, jobject _this, jobject display, jobject surface) { |
| 490 | if (display == NULL || surface == NULL) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 491 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 492 | return JNI_FALSE; |
| 493 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 494 | EGLDisplay dpy = getDisplay(_env, display); |
| 495 | EGLSurface sur = getSurface(_env, surface); |
| 496 | return eglSwapBuffers(dpy, sur); |
| 497 | } |
| 498 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 499 | static jboolean jni_eglTerminate(JNIEnv *_env, jobject _this, jobject display) { |
| 500 | if (display == NULL) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 501 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 502 | return JNI_FALSE; |
| 503 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 504 | EGLDisplay dpy = getDisplay(_env, display); |
| 505 | return eglTerminate(dpy); |
| 506 | } |
| 507 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 508 | static jboolean jni_eglCopyBuffers(JNIEnv *_env, jobject _this, jobject display, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 509 | jobject surface, jobject native_pixmap) { |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 510 | if (display == NULL || surface == NULL || native_pixmap == NULL) { |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 511 | jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 512 | return JNI_FALSE; |
| 513 | } |
| 514 | // TODO: Implement this |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 515 | return JNI_FALSE; |
| 516 | } |
| 517 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 518 | static jboolean jni_eglWaitGL(JNIEnv *_env, jobject _this) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 519 | return eglWaitGL(); |
| 520 | } |
| 521 | |
Jack Palevich | 1badb71 | 2009-03-25 15:12:17 -0700 | [diff] [blame] | 522 | static jboolean jni_eglWaitNative(JNIEnv *_env, jobject _this, jint engine, jobject bindTarget) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 523 | return eglWaitNative(engine); |
| 524 | } |
| 525 | |
| 526 | |
| 527 | static const char *classPathName = "com/google/android/gles_jni/EGLImpl"; |
| 528 | |
| 529 | #define DISPLAY "Ljavax/microedition/khronos/egl/EGLDisplay;" |
| 530 | #define CONTEXT "Ljavax/microedition/khronos/egl/EGLContext;" |
| 531 | #define CONFIG "Ljavax/microedition/khronos/egl/EGLConfig;" |
| 532 | #define SURFACE "Ljavax/microedition/khronos/egl/EGLSurface;" |
| 533 | #define OBJECT "Ljava/lang/Object;" |
| 534 | #define STRING "Ljava/lang/String;" |
| 535 | |
| 536 | static JNINativeMethod methods[] = { |
| 537 | {"_nativeClassInit","()V", (void*)nativeClassInit }, |
| 538 | {"eglWaitGL", "()Z", (void*)jni_eglWaitGL }, |
| 539 | {"eglInitialize", "(" DISPLAY "[I)Z", (void*)jni_eglInitialize }, |
| 540 | {"eglQueryContext", "(" DISPLAY CONTEXT "I[I)Z", (void*)jni_eglQueryContext }, |
| 541 | {"eglQuerySurface", "(" DISPLAY SURFACE "I[I)Z", (void*)jni_eglQuerySurface }, |
Romain Guy | 8ff6b9e | 2011-11-09 20:10:18 -0800 | [diff] [blame] | 542 | {"eglReleaseThread","()Z", (void*)jni_eglReleaseThread }, |
| 543 | {"getInitCount", "(" DISPLAY ")I", (void*)jni_getInitCount }, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 544 | {"eglChooseConfig", "(" DISPLAY "[I[" CONFIG "I[I)Z", (void*)jni_eglChooseConfig }, |
| 545 | {"_eglCreateContext","(" DISPLAY CONFIG CONTEXT "[I)I", (void*)jni_eglCreateContext }, |
| 546 | {"eglGetConfigs", "(" DISPLAY "[" CONFIG "I[I)Z", (void*)jni_eglGetConfigs }, |
| 547 | {"eglTerminate", "(" DISPLAY ")Z", (void*)jni_eglTerminate }, |
| 548 | {"eglCopyBuffers", "(" DISPLAY SURFACE OBJECT ")Z", (void*)jni_eglCopyBuffers }, |
| 549 | {"eglWaitNative", "(I" OBJECT ")Z", (void*)jni_eglWaitNative }, |
| 550 | {"eglGetError", "()I", (void*)jni_eglGetError }, |
| 551 | {"eglGetConfigAttrib", "(" DISPLAY CONFIG "I[I)Z", (void*)jni_eglGetConfigAttrib }, |
| 552 | {"_eglGetDisplay", "(" OBJECT ")I", (void*)jni_eglGetDisplay }, |
| 553 | {"_eglGetCurrentContext", "()I", (void*)jni_eglGetCurrentContext }, |
| 554 | {"_eglGetCurrentDisplay", "()I", (void*)jni_eglGetCurrentDisplay }, |
| 555 | {"_eglGetCurrentSurface", "(I)I", (void*)jni_eglGetCurrentSurface }, |
| 556 | {"_eglCreatePbufferSurface","(" DISPLAY CONFIG "[I)I", (void*)jni_eglCreatePbufferSurface }, |
| 557 | {"_eglCreatePixmapSurface", "(" SURFACE DISPLAY CONFIG OBJECT "[I)V", (void*)jni_eglCreatePixmapSurface }, |
| 558 | {"_eglCreateWindowSurface", "(" DISPLAY CONFIG OBJECT "[I)I", (void*)jni_eglCreateWindowSurface }, |
Romain Guy | b38484c | 2011-06-15 17:43:08 -0700 | [diff] [blame] | 559 | {"_eglCreateWindowSurfaceTexture", "(" DISPLAY CONFIG OBJECT "[I)I", (void*)jni_eglCreateWindowSurfaceTexture }, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 560 | {"eglDestroyContext", "(" DISPLAY CONTEXT ")Z", (void*)jni_eglDestroyContext }, |
| 561 | {"eglDestroySurface", "(" DISPLAY SURFACE ")Z", (void*)jni_eglDestroySurface }, |
| 562 | {"eglMakeCurrent", "(" DISPLAY SURFACE SURFACE CONTEXT")Z", (void*)jni_eglMakeCurrent }, |
| 563 | {"eglQueryString", "(" DISPLAY "I)" STRING, (void*)jni_eglQueryString }, |
| 564 | {"eglSwapBuffers", "(" DISPLAY SURFACE ")Z", (void*)jni_eglSwapBuffers }, |
| 565 | }; |
| 566 | |
| 567 | } // namespace android |
| 568 | |
| 569 | int register_com_google_android_gles_jni_EGLImpl(JNIEnv *_env) |
| 570 | { |
| 571 | int err; |
| 572 | err = android::AndroidRuntime::registerNativeMethods(_env, |
| 573 | android::classPathName, android::methods, NELEM(android::methods)); |
| 574 | return err; |
| 575 | } |