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         if (offset < 0) {
     18             _exception = 1;
     19             _exceptionType = "java/lang/IllegalArgumentException";
     20             _exceptionMessage = "offset < 0";
     21             goto exit;
     22         }
     23         _remaining = _env->GetArrayLength(attrib_list_ref) - offset;
     24         attrib_list_base = (EGLint *)
     25             _env->GetIntArrayElements(attrib_list_ref, (jboolean *)0);
     26         attrib_list = attrib_list_base + offset;
     27         attrib_list_sentinel = false;
     28         for (int i = _remaining - 1; i >= 0; i--)  {
     29             if (attrib_list[i] == EGL_NONE){
     30                 attrib_list_sentinel = true;
     31                 break;
     32             }
     33         }
     34         if (attrib_list_sentinel == false) {
     35             _exception = 1;
     36             _exceptionType = "java/lang/IllegalArgumentException";
     37             _exceptionMessage = "attrib_list must contain EGL_NONE!";
     38             goto exit;
     39         }
     40     }
     41 
     42     _returnValue = eglCreatePbufferFromClientBuffer(
     43         (EGLDisplay)dpy_native,
     44         (EGLenum)buftype,
     45         reinterpret_cast<EGLClientBuffer>(buffer),
     46         (EGLConfig)config_native,
     47         (EGLint *)attrib_list
     48     );
     49 
     50 exit:
     51     if (attrib_list_base) {
     52         _env->ReleaseIntArrayElements(attrib_list_ref, attrib_list_base,
     53             JNI_ABORT);
     54     }
     55     if (_exception) {
     56         jniThrowException(_env, _exceptionType, _exceptionMessage);
     57     }
     58     return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
     59 }
     60 
     61 static jobject
     62 android_eglCreatePbufferFromClientBufferInt
     63   (JNIEnv *_env, jobject _this, jobject dpy, jint buftype, jint buffer, jobject config, jintArray attrib_list_ref, jint offset) {
     64     if(sizeof(void*) != sizeof(uint32_t)) {
     65         jniThrowException(_env, "java/lang/UnsupportedOperationException", "eglCreatePbufferFromClientBuffer");
     66         return 0;
     67     }
     68     return android_eglCreatePbufferFromClientBuffer(_env, _this, dpy, buftype, buffer, config, attrib_list_ref, offset);
     69 }
     70