Search in sources :

Example 1 with SunGraphicsEnvironment

use of sun.java2d.SunGraphicsEnvironment in project intellij-community by JetBrains.

the class UIUtil method isJreHiDPIEnabled.

/**
   * Returns whether the JRE-managed HiDPI mode is enabled.
   * (True for macOS JDK >= 7.10 versions)
   *
   * @see JBUI.ScaleType
   */
public static boolean isJreHiDPIEnabled() {
    if (jreHiDPI != null) {
        return jreHiDPI;
    }
    jreHiDPI = false;
    jreHiDPI_earlierVersion = true;
    if (SystemInfo.isLinux) {
        // pending support
        return false;
    }
    try {
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        if (ge instanceof SunGraphicsEnvironment) {
            Method m = ReflectionUtil.getDeclaredMethod(SunGraphicsEnvironment.class, "isUIScaleOn");
            jreHiDPI = (Boolean) m.invoke(ge);
            jreHiDPI_earlierVersion = false;
        }
    } catch (Throwable ignore) {
    }
    if (SystemInfo.isMac) {
        return jreHiDPI = (SystemInfo.isAppleJvm ? false : true);
    }
    return jreHiDPI;
}
Also used : Method(java.lang.reflect.Method) SunGraphicsEnvironment(sun.java2d.SunGraphicsEnvironment) SunGraphicsEnvironment(sun.java2d.SunGraphicsEnvironment)

Example 2 with SunGraphicsEnvironment

use of sun.java2d.SunGraphicsEnvironment in project jdk8u_jdk by JetBrains.

the class X11SurfaceData method isAccelerationEnabled.

public static boolean isAccelerationEnabled() {
    if (accelerationEnabled == null) {
        if (GraphicsEnvironment.isHeadless()) {
            accelerationEnabled = Boolean.FALSE;
        } else {
            String prop = (String) java.security.AccessController.doPrivileged(new sun.security.action.GetPropertyAction("sun.java2d.pmoffscreen"));
            if (prop != null) {
                // true iff prop==true, false otherwise
                accelerationEnabled = Boolean.valueOf(prop);
            } else {
                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()));
            }
        }
    }
    return accelerationEnabled.booleanValue();
}
Also used : GraphicsEnvironment(java.awt.GraphicsEnvironment) X11GraphicsEnvironment(sun.awt.X11GraphicsEnvironment) SunGraphicsEnvironment(sun.java2d.SunGraphicsEnvironment) SunGraphicsEnvironment(sun.java2d.SunGraphicsEnvironment)

Example 3 with SunGraphicsEnvironment

use of sun.java2d.SunGraphicsEnvironment in project jdk8u_jdk by JetBrains.

the class SwingUtilities2 method isLocalDisplay.

/* Used to help decide if AA text rendering should be used, so
     * this local display test should be additionally qualified
     * against whether we have XRender support on both ends of the wire,
     * as with that support remote performance may be good enough to turn
     * on by default. An additional complication there is XRender does not
     * appear capable of performing gamma correction needed for LCD text.
     */
public static boolean isLocalDisplay() {
    boolean isLocal;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    if (ge instanceof SunGraphicsEnvironment) {
        isLocal = ((SunGraphicsEnvironment) ge).isDisplayLocal();
    } else {
        isLocal = true;
    }
    return isLocal;
}
Also used : SunGraphicsEnvironment(sun.java2d.SunGraphicsEnvironment) SunGraphicsEnvironment(sun.java2d.SunGraphicsEnvironment)

Example 4 with SunGraphicsEnvironment

use of sun.java2d.SunGraphicsEnvironment in project jdk8u_jdk by JetBrains.

the class DisplayListenerLeak method main.

public static void main(final String[] args) throws Exception {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    if (!(ge instanceof SunGraphicsEnvironment)) {
        return;
    }
    EventQueue.invokeAndWait(() -> createAndShowGUI());
    SunGraphicsEnvironment sge = (SunGraphicsEnvironment) ge;
    final long startTime = System.nanoTime();
    while (!failed) {
        if (System.nanoTime() - startTime > 60_000_000_000L) {
            break;
        }
        // clear all weak references
        System.gc();
        EventQueue.invokeAndWait(() -> {
            frame.setSize(frame.getHeight(), frame.getWidth());
            frame.pack();
        });
        EventQueue.invokeAndWait(sge::displayChanged);
    }
    EventQueue.invokeAndWait(frame::dispose);
    if (failed) {
        throw new RuntimeException();
    }
}
Also used : SunGraphicsEnvironment(sun.java2d.SunGraphicsEnvironment) GraphicsEnvironment(java.awt.GraphicsEnvironment) SunGraphicsEnvironment(sun.java2d.SunGraphicsEnvironment)

Aggregations

SunGraphicsEnvironment (sun.java2d.SunGraphicsEnvironment)4 GraphicsEnvironment (java.awt.GraphicsEnvironment)2 Method (java.lang.reflect.Method)1 X11GraphicsEnvironment (sun.awt.X11GraphicsEnvironment)1