From 1f071dd8c39dc966ad18abab0528f72730a4af6a Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Wed, 30 Nov 2016 10:20:29 -0800 Subject: [PATCH] Deprecate eglCreatePixmapSurface This function was never properly supported. It had partial support in our JNI layer in EGL10 but not implementation in EGL14. It has never been tested and it is unlikely that drivers support pixmap rendering. Bug: 11257511 Test: CtsGraphicsTestCases Change-Id: I209fff470c715cd97148a32b2f41ecf7e5283bab --- api/current.txt | 4 +- api/system-current.txt | 4 +- api/test-current.txt | 4 +- .../com_google_android_gles_jni_EGLImpl.cpp | 50 +------------------ opengl/java/android/opengl/EGL14.java | 1 + .../javax/microedition/khronos/egl/EGL10.java | 1 + 6 files changed, 9 insertions(+), 55 deletions(-) diff --git a/api/current.txt b/api/current.txt index a38ff53577b42..f57ba0f6b73c0 100644 --- a/api/current.txt +++ b/api/current.txt @@ -25409,7 +25409,7 @@ package android.opengl { method public static android.opengl.EGLContext eglCreateContext(android.opengl.EGLDisplay, android.opengl.EGLConfig, android.opengl.EGLContext, int[], int); method public static android.opengl.EGLSurface eglCreatePbufferFromClientBuffer(android.opengl.EGLDisplay, int, int, android.opengl.EGLConfig, int[], int); method public static android.opengl.EGLSurface eglCreatePbufferSurface(android.opengl.EGLDisplay, android.opengl.EGLConfig, int[], int); - method public static android.opengl.EGLSurface eglCreatePixmapSurface(android.opengl.EGLDisplay, android.opengl.EGLConfig, int, int[], int); + method public static deprecated android.opengl.EGLSurface eglCreatePixmapSurface(android.opengl.EGLDisplay, android.opengl.EGLConfig, int, int[], int); method public static android.opengl.EGLSurface eglCreateWindowSurface(android.opengl.EGLDisplay, android.opengl.EGLConfig, java.lang.Object, int[], int); method public static boolean eglDestroyContext(android.opengl.EGLDisplay, android.opengl.EGLContext); method public static boolean eglDestroySurface(android.opengl.EGLDisplay, android.opengl.EGLSurface); @@ -64038,7 +64038,7 @@ package javax.microedition.khronos.egl { method public abstract boolean eglCopyBuffers(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLSurface, java.lang.Object); method public abstract javax.microedition.khronos.egl.EGLContext eglCreateContext(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLConfig, javax.microedition.khronos.egl.EGLContext, int[]); method public abstract javax.microedition.khronos.egl.EGLSurface eglCreatePbufferSurface(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLConfig, int[]); - method public abstract javax.microedition.khronos.egl.EGLSurface eglCreatePixmapSurface(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLConfig, java.lang.Object, int[]); + method public abstract deprecated javax.microedition.khronos.egl.EGLSurface eglCreatePixmapSurface(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLConfig, java.lang.Object, int[]); method public abstract javax.microedition.khronos.egl.EGLSurface eglCreateWindowSurface(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLConfig, java.lang.Object, int[]); method public abstract boolean eglDestroyContext(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLContext); method public abstract boolean eglDestroySurface(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLSurface); diff --git a/api/system-current.txt b/api/system-current.txt index bcf4897c86615..c6b16f46c204c 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -27934,7 +27934,7 @@ package android.opengl { method public static android.opengl.EGLContext eglCreateContext(android.opengl.EGLDisplay, android.opengl.EGLConfig, android.opengl.EGLContext, int[], int); method public static android.opengl.EGLSurface eglCreatePbufferFromClientBuffer(android.opengl.EGLDisplay, int, int, android.opengl.EGLConfig, int[], int); method public static android.opengl.EGLSurface eglCreatePbufferSurface(android.opengl.EGLDisplay, android.opengl.EGLConfig, int[], int); - method public static android.opengl.EGLSurface eglCreatePixmapSurface(android.opengl.EGLDisplay, android.opengl.EGLConfig, int, int[], int); + method public static deprecated android.opengl.EGLSurface eglCreatePixmapSurface(android.opengl.EGLDisplay, android.opengl.EGLConfig, int, int[], int); method public static android.opengl.EGLSurface eglCreateWindowSurface(android.opengl.EGLDisplay, android.opengl.EGLConfig, java.lang.Object, int[], int); method public static boolean eglDestroyContext(android.opengl.EGLDisplay, android.opengl.EGLContext); method public static boolean eglDestroySurface(android.opengl.EGLDisplay, android.opengl.EGLSurface); @@ -67561,7 +67561,7 @@ package javax.microedition.khronos.egl { method public abstract boolean eglCopyBuffers(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLSurface, java.lang.Object); method public abstract javax.microedition.khronos.egl.EGLContext eglCreateContext(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLConfig, javax.microedition.khronos.egl.EGLContext, int[]); method public abstract javax.microedition.khronos.egl.EGLSurface eglCreatePbufferSurface(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLConfig, int[]); - method public abstract javax.microedition.khronos.egl.EGLSurface eglCreatePixmapSurface(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLConfig, java.lang.Object, int[]); + method public abstract deprecated javax.microedition.khronos.egl.EGLSurface eglCreatePixmapSurface(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLConfig, java.lang.Object, int[]); method public abstract javax.microedition.khronos.egl.EGLSurface eglCreateWindowSurface(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLConfig, java.lang.Object, int[]); method public abstract boolean eglDestroyContext(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLContext); method public abstract boolean eglDestroySurface(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLSurface); diff --git a/api/test-current.txt b/api/test-current.txt index fa75e9b4d0a5e..df1b6275b5d12 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -25490,7 +25490,7 @@ package android.opengl { method public static android.opengl.EGLContext eglCreateContext(android.opengl.EGLDisplay, android.opengl.EGLConfig, android.opengl.EGLContext, int[], int); method public static android.opengl.EGLSurface eglCreatePbufferFromClientBuffer(android.opengl.EGLDisplay, int, int, android.opengl.EGLConfig, int[], int); method public static android.opengl.EGLSurface eglCreatePbufferSurface(android.opengl.EGLDisplay, android.opengl.EGLConfig, int[], int); - method public static android.opengl.EGLSurface eglCreatePixmapSurface(android.opengl.EGLDisplay, android.opengl.EGLConfig, int, int[], int); + method public static deprecated android.opengl.EGLSurface eglCreatePixmapSurface(android.opengl.EGLDisplay, android.opengl.EGLConfig, int, int[], int); method public static android.opengl.EGLSurface eglCreateWindowSurface(android.opengl.EGLDisplay, android.opengl.EGLConfig, java.lang.Object, int[], int); method public static boolean eglDestroyContext(android.opengl.EGLDisplay, android.opengl.EGLContext); method public static boolean eglDestroySurface(android.opengl.EGLDisplay, android.opengl.EGLSurface); @@ -64304,7 +64304,7 @@ package javax.microedition.khronos.egl { method public abstract boolean eglCopyBuffers(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLSurface, java.lang.Object); method public abstract javax.microedition.khronos.egl.EGLContext eglCreateContext(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLConfig, javax.microedition.khronos.egl.EGLContext, int[]); method public abstract javax.microedition.khronos.egl.EGLSurface eglCreatePbufferSurface(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLConfig, int[]); - method public abstract javax.microedition.khronos.egl.EGLSurface eglCreatePixmapSurface(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLConfig, java.lang.Object, int[]); + method public abstract deprecated javax.microedition.khronos.egl.EGLSurface eglCreatePixmapSurface(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLConfig, java.lang.Object, int[]); method public abstract javax.microedition.khronos.egl.EGLSurface eglCreateWindowSurface(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLConfig, java.lang.Object, int[]); method public abstract boolean eglDestroyContext(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLContext); method public abstract boolean eglDestroySurface(javax.microedition.khronos.egl.EGLDisplay, javax.microedition.khronos.egl.EGLSurface); diff --git a/core/jni/com_google_android_gles_jni_EGLImpl.cpp b/core/jni/com_google_android_gles_jni_EGLImpl.cpp index 3d63b013e9f1e..56bec186b8a39 100644 --- a/core/jni/com_google_android_gles_jni_EGLImpl.cpp +++ b/core/jni/com_google_android_gles_jni_EGLImpl.cpp @@ -254,59 +254,11 @@ static jlong jni_eglCreatePbufferSurface(JNIEnv *_env, jobject _this, jobject di return reinterpret_cast(sur); } -static PixelFormat convertPixelFormat(SkColorType format) -{ - switch (format) { - case kN32_SkColorType: return PIXEL_FORMAT_RGBA_8888; - case kARGB_4444_SkColorType: return PIXEL_FORMAT_RGBA_4444; - case kRGB_565_SkColorType: return PIXEL_FORMAT_RGB_565; - default: return PIXEL_FORMAT_NONE; - } -} - static void jni_eglCreatePixmapSurface(JNIEnv *_env, jobject _this, jobject out_sur, jobject display, jobject config, jobject native_pixmap, jintArray attrib_list) { - if (display == NULL || config == NULL || native_pixmap == NULL - || !validAttribList(_env, attrib_list)) { - jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); - return; - } - EGLDisplay dpy = getDisplay(_env, display); - EGLConfig cnf = getConfig(_env, config); - jint* base = 0; - - SkBitmap nativeBitmap; - GraphicsJNI::getSkBitmap(_env, native_pixmap, &nativeBitmap); - SkPixelRef* ref = nativeBitmap.pixelRef(); - if (ref == NULL) { - jniThrowException(_env, "java/lang/IllegalArgumentException", "Bitmap has no PixelRef"); - return; - } - - SkSafeRef(ref); - ref->lockPixels(); - - egl_native_pixmap_t pixmap; - pixmap.version = sizeof(pixmap); - pixmap.width = nativeBitmap.width(); - pixmap.height = nativeBitmap.height(); - pixmap.stride = nativeBitmap.rowBytes() / nativeBitmap.bytesPerPixel(); - pixmap.format = convertPixelFormat(nativeBitmap.colorType()); - pixmap.data = (uint8_t*)ref->pixels(); - - base = beginNativeAttribList(_env, attrib_list); - EGLSurface sur = eglCreatePixmapSurface(dpy, cnf, &pixmap, base); - endNativeAttributeList(_env, attrib_list, base); - - if (sur != EGL_NO_SURFACE) { - _env->SetLongField(out_sur, gSurface_EGLSurfaceFieldID, reinterpret_cast(sur)); - _env->SetLongField(out_sur, gSurface_NativePixelRefFieldID, reinterpret_cast(ref)); - } else { - ref->unlockPixels(); - SkSafeUnref(ref); - } + jniThrowException(_env, "java/lang/UnsupportedOperationException", "eglCreatePixmapSurface"); } static jlong jni_eglCreateWindowSurface(JNIEnv *_env, jobject _this, jobject display, diff --git a/opengl/java/android/opengl/EGL14.java b/opengl/java/android/opengl/EGL14.java index cf09c5865b981..53ec6c8980efc 100644 --- a/opengl/java/android/opengl/EGL14.java +++ b/opengl/java/android/opengl/EGL14.java @@ -284,6 +284,7 @@ public static final int EGL_CORE_NATIVE_ENGINE = 0x305B; // C function EGLSurface eglCreatePixmapSurface ( EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list ) + @Deprecated public static native EGLSurface eglCreatePixmapSurface( EGLDisplay dpy, EGLConfig config, diff --git a/opengl/java/javax/microedition/khronos/egl/EGL10.java b/opengl/java/javax/microedition/khronos/egl/EGL10.java index cf58888effae5..612d59c53e9f1 100644 --- a/opengl/java/javax/microedition/khronos/egl/EGL10.java +++ b/opengl/java/javax/microedition/khronos/egl/EGL10.java @@ -98,6 +98,7 @@ public interface EGL10 extends EGL { boolean eglCopyBuffers(EGLDisplay display, EGLSurface surface, Object native_pixmap); EGLContext eglCreateContext(EGLDisplay display, EGLConfig config, EGLContext share_context, int[] attrib_list); EGLSurface eglCreatePbufferSurface(EGLDisplay display, EGLConfig config, int[] attrib_list); + @Deprecated EGLSurface eglCreatePixmapSurface(EGLDisplay display, EGLConfig config, Object native_pixmap, int[] attrib_list); EGLSurface eglCreateWindowSurface(EGLDisplay display, EGLConfig config, Object native_window, int[] attrib_list); boolean eglDestroyContext(EGLDisplay display, EGLContext context);