From 2009cbebcdadb7b5bc7e00978ba2a837bde06c92 Mon Sep 17 00:00:00 2001 From: tdv Date: Thu, 4 Dec 2008 11:21:26 -0800 Subject: [PATCH] 6708580: Java applications slow when EXA enabled Reviewed-by: prr, tdv Contributed-by: ceisserer --- make/sun/awt/mapfile-mawt-vers | 1 + make/sun/xawt/mapfile-vers | 1 + .../sun/java2d/x11/X11SurfaceData.java | 19 +++++++++++++++++-- .../native/sun/java2d/x11/X11SurfaceData.c | 17 +++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/make/sun/awt/mapfile-mawt-vers b/make/sun/awt/mapfile-mawt-vers index ca3b430c5..7eeef21f2 100644 --- a/make/sun/awt/mapfile-mawt-vers +++ b/make/sun/awt/mapfile-mawt-vers @@ -407,6 +407,7 @@ SUNWprivate_1.1 { Java_sun_java2d_x11_X11SurfaceData_initSurface; Java_sun_java2d_x11_X11SurfaceData_isDrawableValid; Java_sun_java2d_x11_X11SurfaceData_isDgaAvailable; + Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable; Java_sun_java2d_x11_X11SurfaceData_setInvalid; Java_sun_java2d_x11_X11SurfaceData_flushNativeSurface; Java_sun_java2d_x11_X11SurfaceData_XCreateGC; diff --git a/make/sun/xawt/mapfile-vers b/make/sun/xawt/mapfile-vers index 9e0b434b5..d4b5b6e32 100644 --- a/make/sun/xawt/mapfile-vers +++ b/make/sun/xawt/mapfile-vers @@ -337,6 +337,7 @@ SUNWprivate_1.1 { Java_sun_java2d_x11_X11SurfaceData_initIDs; Java_sun_java2d_x11_X11SurfaceData_isDrawableValid; Java_sun_java2d_x11_X11SurfaceData_isDgaAvailable; + Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable; Java_sun_java2d_x11_X11SurfaceData_initOps; Java_sun_java2d_x11_X11SurfaceData_initSurface; Java_sun_java2d_x11_X11SurfaceData_flushNativeSurface; diff --git a/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java b/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java index 986f1b51e..54f797693 100644 --- a/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java +++ b/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java @@ -50,6 +50,7 @@ import sun.awt.image.PixelConverter; import sun.font.X11TextRenderer; import sun.java2d.InvalidPipeException; import sun.java2d.SunGraphics2D; +import sun.java2d.SunGraphicsEnvironment; import sun.java2d.SurfaceData; import sun.java2d.SurfaceDataProxy; import sun.java2d.loops.SurfaceType; @@ -240,6 +241,11 @@ public abstract class X11SurfaceData extends SurfaceData { */ public static native boolean isDgaAvailable(); + /** + * Returns true if shared memory pixmaps are available + */ + private static native boolean isShmPMAvailable(); + public static boolean isAccelerationEnabled() { if (accelerationEnabled == null) { @@ -253,8 +259,17 @@ public abstract class X11SurfaceData extends SurfaceData { // true iff prop==true, false otherwise accelerationEnabled = Boolean.valueOf(prop); } else { - // use pixmaps if there is no dga, no matter local or remote - accelerationEnabled = Boolean.valueOf(!isDgaAvailable()); + boolean isDisplayLocal = false; + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + if (ge instanceof SunGraphicsEnvironment) { + isDisplayLocal = ((SunGraphicsEnvironment) ge).isDisplayLocal(); + } + + // EXA based drivers tend to place pixmaps in VRAM, slowing down readbacks. + // Don't use pixmaps if dga is available, + // or we are local and shared memory Pixmaps are not available. + accelerationEnabled = + !(isDgaAvailable() || (isDisplayLocal && !isShmPMAvailable())); } } } diff --git a/src/solaris/native/sun/java2d/x11/X11SurfaceData.c b/src/solaris/native/sun/java2d/x11/X11SurfaceData.c index 8b275bc91..8423f1eee 100644 --- a/src/solaris/native/sun/java2d/x11/X11SurfaceData.c +++ b/src/solaris/native/sun/java2d/x11/X11SurfaceData.c @@ -208,6 +208,23 @@ Java_sun_java2d_x11_X11SurfaceData_isDgaAvailable(JNIEnv *env, jobject this) #endif /* HEADLESS */ } + +/* + * Class: sun_java2d_x11_X11SurfaceData + * Method: isShmPMAvailable + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL +Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable(JNIEnv *env, jobject this) +{ +#if defined(HEADLESS) || !defined(MITSHM) + return JNI_FALSE; +#else + return useMitShmPixmaps; +#endif /* HEADLESS, MITSHM */ +} + + /* * Class: sun_java2d_x11_X11SurfaceData * Method: initOps -- GitLab