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