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