Print this page
rev 54883 : JDK-8220154 Improve java2d rendering performance on macOS by using Metal framework

Split Close
Expand all
Collapse all
          --- old/src/java.desktop/macosx/classes/sun/awt/CGraphicsDevice.java
          +++ new/src/java.desktop/macosx/classes/sun/awt/CGraphicsDevice.java
↓ open down ↓ 28 lines elided ↑ open up ↑
  29   29  import java.awt.DisplayMode;
  30   30  import java.awt.GraphicsConfiguration;
  31   31  import java.awt.GraphicsDevice;
  32   32  import java.awt.Insets;
  33   33  import java.awt.Rectangle;
  34   34  import java.awt.Window;
  35   35  import java.awt.geom.Rectangle2D;
  36   36  import java.util.Objects;
  37   37  
  38   38  import sun.java2d.SunGraphicsEnvironment;
       39 +import sun.java2d.macos.MacOSFlags;
       40 +import sun.java2d.metal.MTLGraphicsConfig;
  39   41  import sun.java2d.opengl.CGLGraphicsConfig;
  40   42  
  41   43  public final class CGraphicsDevice extends GraphicsDevice
  42   44          implements DisplayChangedListener {
  43   45  
  44   46      /**
  45   47       * CoreGraphics display ID. This identifier can become non-valid at any time
  46   48       * therefore methods, which is using this id should be ready to it.
  47   49       */
  48   50      private volatile int displayID;
↓ open down ↓ 4 lines elided ↑ open up ↑
  53   55  
  54   56      private final GraphicsConfiguration config;
  55   57  
  56   58      private static AWTPermission fullScreenExclusivePermission;
  57   59  
  58   60      // Save/restore DisplayMode for the Full Screen mode
  59   61      private DisplayMode originalMode;
  60   62  
  61   63      public CGraphicsDevice(final int displayID) {
  62   64          this.displayID = displayID;
  63      -        config = CGLGraphicsConfig.getConfig(this, displayID, 0);
       65 +        config = MacOSFlags.isMetalEnabled() ?
       66 +                MTLGraphicsConfig.getConfig(this, displayID, 0) :
       67 +                CGLGraphicsConfig.getConfig(this, displayID, 0);
  64   68      }
  65   69  
  66   70      /**
  67   71       * Return a list of all configurations.
  68   72       */
  69   73      @Override
  70   74      public GraphicsConfiguration[] getConfigurations() {
  71   75          return new GraphicsConfiguration[]{config};
  72   76      }
  73   77  
↓ open down ↓ 198 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX