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