Home | History | Annotate | Download | only in egl
      1 /* EGLSurface eglCreatePbufferFromClientBuffer ( EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list ) */
      2 static jobject
      3 android_eglCreatePbufferFromClientBuffer
      4   (JNIEnv *_env, jobject _this, jobject dpy, jint buftype, jlong buffer, jobject config, jintArray attrib_list_ref, jint offset) {
      5     jint _exception = 0;
      6     const char * _exceptionType = NULL;
      7     const char * _exceptionMessage = NULL;
      8     EGLSurface _returnValue = (EGLSurface) 0;
      9     EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
     10     EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
     11     bool attrib_list_sentinel = false;
     12     EGLint *attrib_list_base = (EGLint *) 0;
     13     jint _remaining;
     14     EGLint *attrib_list = (EGLint *) 0;
     15 
     16     if (!attrib_list_ref) {
     17         _exception = 1;
     18         _exceptionType = "java/lang/IllegalArgumentException";
     19         _exceptionMessage = "attrib_list == null";
     20         goto exit;
     21     }
     22     if (offset < 0) {
     23         _exception = 1;
     24         _exceptionType = "java/lang/IllegalArgumentException";
     25         _exceptionMessage = "offset < 0";
     26         goto exit;
     27     }
     28     _remaining = _env->GetArrayLength(attrib_list_ref) - offset;
     29     attrib_list_base = (EGLint *)
     30         _env->GetIntArrayElements(attrib_list_ref, (jboolean *)0);
     31     attrib_list = attrib_list_base + offset;
     32     attrib_list_sentinel = false;
     33     for (int i = _remaining - 1; i >= 0; i--)  {
     34         if (attrib_list[i] == EGL_NONE){
     35             attrib_list_sentinel = true;
     36             break;
     37         }
     38     }
     39     if (attrib_list_sentinel == false) {
     40         _exception = 1;
     41         _exceptionType = "java/lang/IllegalArgumentException";
     42         _exceptionMessage = "attrib_list must contain EGL_NONE!";
     43         goto exit;
     44     }
     45 
     46     _returnValue = eglCreatePbufferFromClientBuffer(
     47         (EGLDisplay)dpy_native,
     48         (EGLenum)buftype,
     49         reinterpret_cast<EGLClientBuffer>(buffer),
     50         (EGLConfig)config_native,
     51         (EGLint *)attrib_list
     52     );
     53 
     54 exit:
     55     if (attrib_list_base) {
     56         _env->ReleaseIntArrayElements(attrib_list_ref, attrib_list_base,
     57             JNI_ABORT);
     58     }
     59     if (_exception) {
     60         jniThrowException(_env, _exceptionType, _exceptionMessage);
     61     }
     62     return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
     63 }
     64 
     65 static jobject
     66 android_eglCreatePbufferFromClientBufferInt
     67   (JNIEnv *_env, jobject _this, jobject dpy, jint buftype, jint buffer, jobject config, jintArray attrib_list_ref, jint offset) {
     68     if(sizeof(void*) != sizeof(uint32_t)) {
     69         jniThrowException(_env, "java/lang/UnsupportedOperationException", "eglCreatePbufferFromClientBuffer");
     70         return 0;
     71     }
     72     return android_eglCreatePbufferFromClientBuffer(_env, _this, dpy, buftype, buffer, config, attrib_list_ref, offset);
     73 }
     74