Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e8c60cc authored by Courtney Goeltzenleuchter's avatar Courtney Goeltzenleuchter
Browse files

Add EGL15: eglCreateImage, eglDestroyImage

Also change eglCreatePlatformPixmapSurface to throw an
unsupported extension rather than call the native function
which will return an error indicating it's unsupported.

Bug: 80297325
Test: atest CtsGraphicsTestCases:EGL15Test
Change-Id: I94f2d39678515fdacf9b2fccd1c531365930ad1b
parent ff064b1e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -29745,9 +29745,11 @@ package android.opengl {
  public class EGL15 {
    ctor public EGL15();
    method public static int eglClientWaitSync(android.opengl.EGLDisplay, android.opengl.EGLSync, int, long);
    method public static android.opengl.EGLImage eglCreateImage(android.opengl.EGLDisplay, android.opengl.EGLContext, int, long, long[], int);
    method public static android.opengl.EGLSurface eglCreatePlatformPixmapSurface(android.opengl.EGLDisplay, android.opengl.EGLConfig, java.nio.Buffer, long[], int);
    method public static android.opengl.EGLSurface eglCreatePlatformWindowSurface(android.opengl.EGLDisplay, android.opengl.EGLConfig, java.nio.Buffer, long[], int);
    method public static android.opengl.EGLSync eglCreateSync(android.opengl.EGLDisplay, int, long[], int);
    method public static boolean eglDestroyImage(android.opengl.EGLDisplay, android.opengl.EGLImage);
    method public static boolean eglDestroySync(android.opengl.EGLDisplay, android.opengl.EGLSync);
    method public static android.opengl.EGLDisplay eglGetPlatformDisplay(int, long, long[], int);
    method public static boolean eglGetSyncAttrib(android.opengl.EGLDisplay, android.opengl.EGLSync, int, long[], int);
+42 −33
Original line number Diff line number Diff line
@@ -456,27 +456,41 @@ exit:
static jobject
android_eglCreatePlatformPixmapSurface
  (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jobject native_pixmap_buf, jlongArray attrib_list_ref, jint offset) {
    jniThrowException(_env, "java/lang/UnsupportedOperationException",
        "eglCreatePlatformPixmapSurface");
    return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, (EGLSurface) 0);
}

/* EGLBoolean eglWaitSync ( EGLDisplay dpy, EGLSync sync, EGLint flags ) */
static jboolean
android_eglWaitSync
  (JNIEnv *_env, jobject _this, jobject dpy, jobject sync, jint flags) {
    EGLBoolean _returnValue = (EGLBoolean) 0;
    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
    EGLSync sync_native = (EGLSync) fromEGLHandle(_env, eglsyncGetHandleID, sync);

    _returnValue = eglWaitSync(
        (EGLDisplay)dpy_native,
        (EGLSync)sync_native,
        (EGLint)flags
    );
    return (jboolean)_returnValue;
}

/* EGLImage eglCreateImage ( EGLDisplay dpy, EGLContext context, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list ) */
static jobject
android_eglCreateImage
  (JNIEnv *_env, jobject _this, jobject dpy, jobject context, jint target, jlong buffer, jlongArray attrib_list_ref, jint offset) {
    jint _exception = 0;
    const char * _exceptionType = NULL;
    const char * _exceptionMessage = NULL;
    jarray _array = (jarray) 0;
    jint _bufferOffset = (jint) 0;
    EGLSurface _returnValue = (EGLSurface) 0;
    EGLImage _returnValue = (EGLImage) 0;
    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
    EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
    jint _native_pixmapRemaining;
    void *native_pixmap = (void *) 0;
    EGLContext context_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, context);
    EGLAttrib *attrib_list_base = (EGLAttrib *) 0;
    jint _attrib_listRemaining;
    jint _remaining;
    EGLAttrib *attrib_list = (EGLAttrib *) 0;

    if (!native_pixmap_buf) {
        _exception = 1;
        _exceptionType = "java/lang/IllegalArgumentException";
        _exceptionMessage = "native_pixmap == null";
        goto exit;
    }
    native_pixmap = (void *)getPointer(_env, native_pixmap_buf, (jarray*)&_array, &_native_pixmapRemaining, &_bufferOffset);
    if (!attrib_list_ref) {
        _exception = 1;
        _exceptionType = "java/lang/IllegalArgumentException";
@@ -489,19 +503,16 @@ android_eglCreatePlatformPixmapSurface
        _exceptionMessage = "offset < 0";
        goto exit;
    }
    _attrib_listRemaining = _env->GetArrayLength(attrib_list_ref) - offset;
    _remaining = _env->GetArrayLength(attrib_list_ref) - offset;
    attrib_list_base = (EGLAttrib *)
        _env->GetLongArrayElements(attrib_list_ref, (jboolean *)0);
    attrib_list = attrib_list_base + offset;

    if (native_pixmap == NULL) {
        char * _native_pixmapBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
        native_pixmap = (void *) (_native_pixmapBase + _bufferOffset);
    }
    _returnValue = eglCreatePlatformPixmapSurface(
    _returnValue = eglCreateImage(
        (EGLDisplay)dpy_native,
        (EGLConfig)config_native,
        (void *)native_pixmap,
        (EGLContext)context_native,
        (EGLenum)target,
        (EGLClientBuffer)buffer,
        (EGLAttrib *)attrib_list
    );

@@ -510,27 +521,23 @@ exit:
        _env->ReleaseLongArrayElements(attrib_list_ref, (jlong*)attrib_list_base,
            JNI_ABORT);
    }
    if (_array) {
        releasePointer(_env, _array, native_pixmap, _exception ? JNI_FALSE : JNI_TRUE);
    }
    if (_exception) {
        jniThrowException(_env, _exceptionType, _exceptionMessage);
    }
    return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
    return toEGLHandle(_env, eglimageClass, eglimageConstructor, _returnValue);
}

/* EGLBoolean eglWaitSync ( EGLDisplay dpy, EGLSync sync, EGLint flags ) */
/* EGLBoolean eglDestroyImage ( EGLDisplay dpy, EGLImage image ) */
static jboolean
android_eglWaitSync
  (JNIEnv *_env, jobject _this, jobject dpy, jobject sync, jint flags) {
android_eglDestroyImage
  (JNIEnv *_env, jobject _this, jobject dpy, jobject image) {
    EGLBoolean _returnValue = (EGLBoolean) 0;
    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
    EGLSync sync_native = (EGLSync) fromEGLHandle(_env, eglsyncGetHandleID, sync);
    EGLImage image_native = (EGLImage) fromEGLHandle(_env, eglimageGetHandleID, image);

    _returnValue = eglWaitSync(
    _returnValue = eglDestroyImage(
        (EGLDisplay)dpy_native,
        (EGLSync)sync_native,
        (EGLint)flags
        (EGLImage)image_native
    );
    return (jboolean)_returnValue;
}
@@ -547,6 +554,8 @@ static const JNINativeMethod methods[] = {
{"eglCreatePlatformWindowSurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;Ljava/nio/Buffer;[JI)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePlatformWindowSurface },
{"eglCreatePlatformPixmapSurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;Ljava/nio/Buffer;[JI)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePlatformPixmapSurface },
{"eglWaitSync", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSync;I)Z", (void *) android_eglWaitSync },
{"eglCreateImage", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLContext;IJ[JI)Landroid/opengl/EGLImage;", (void *) android_eglCreateImage },
{"eglDestroyImage", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLImage;)Z", (void *) android_eglDestroyImage },
};

int register_android_opengl_jni_EGL15(JNIEnv *_env)
+18 −0
Original line number Diff line number Diff line
@@ -146,4 +146,22 @@ public class EGL15 {
        int flags
    );

    // C function EGLImage eglCreateImage ( EGLDisplay dpy, EGLContext context, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list )

    public static native EGLImage eglCreateImage(
        EGLDisplay dpy,
        EGLContext context,
        int target,
        long buffer,
        long[] attrib_list,
        int offset
    );

    // C function EGLBoolean eglDestroyImage ( EGLDisplay dpy, EGLImage image )

    public static native boolean eglDestroyImage(
        EGLDisplay dpy,
        EGLImage image
    );

}