< prev index next >

src/java.desktop/macosx/classes/sun/awt/CGraphicsDevice.java

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


  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.awt;
  27 
  28 import java.awt.AWTPermission;
  29 import java.awt.DisplayMode;
  30 import java.awt.GraphicsConfiguration;
  31 import java.awt.GraphicsDevice;
  32 import java.awt.Insets;
  33 import java.awt.Rectangle;
  34 import java.awt.Window;
  35 import java.awt.geom.Rectangle2D;
  36 import java.util.Objects;
  37 
  38 import sun.java2d.SunGraphicsEnvironment;


  39 import sun.java2d.opengl.CGLGraphicsConfig;
  40 
  41 public final class CGraphicsDevice extends GraphicsDevice
  42         implements DisplayChangedListener {
  43 
  44     /**
  45      * CoreGraphics display ID. This identifier can become non-valid at any time
  46      * therefore methods, which is using this id should be ready to it.
  47      */
  48     private volatile int displayID;
  49     private volatile double xResolution;
  50     private volatile double yResolution;
  51     private volatile Rectangle bounds;
  52     private volatile int scale;
  53 
  54     private final GraphicsConfiguration config;
  55 
  56     private static AWTPermission fullScreenExclusivePermission;
  57 
  58     // Save/restore DisplayMode for the Full Screen mode
  59     private DisplayMode originalMode;
  60 
  61     public CGraphicsDevice(final int displayID) {
  62         this.displayID = displayID;
  63         config = CGLGraphicsConfig.getConfig(this, displayID, 0);


  64     }
  65 
  66     /**
  67      * Return a list of all configurations.
  68      */
  69     @Override
  70     public GraphicsConfiguration[] getConfigurations() {
  71         return new GraphicsConfiguration[]{config};
  72     }
  73 
  74     /**
  75      * Return the default configuration.
  76      */
  77     @Override
  78     public GraphicsConfiguration getDefaultConfiguration() {
  79         return config;
  80     }
  81 
  82     /**
  83      * Return a human-readable screen description.




  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.awt;
  27 
  28 import java.awt.AWTPermission;
  29 import java.awt.DisplayMode;
  30 import java.awt.GraphicsConfiguration;
  31 import java.awt.GraphicsDevice;
  32 import java.awt.Insets;
  33 import java.awt.Rectangle;
  34 import java.awt.Window;
  35 import java.awt.geom.Rectangle2D;
  36 import java.util.Objects;
  37 
  38 import sun.java2d.SunGraphicsEnvironment;
  39 import sun.java2d.macos.MacOSFlags;
  40 import sun.java2d.metal.MTLGraphicsConfig;
  41 import sun.java2d.opengl.CGLGraphicsConfig;
  42 
  43 public final class CGraphicsDevice extends GraphicsDevice
  44         implements DisplayChangedListener {
  45 
  46     /**
  47      * CoreGraphics display ID. This identifier can become non-valid at any time
  48      * therefore methods, which is using this id should be ready to it.
  49      */
  50     private volatile int displayID;
  51     private volatile double xResolution;
  52     private volatile double yResolution;
  53     private volatile Rectangle bounds;
  54     private volatile int scale;
  55 
  56     private final GraphicsConfiguration config;
  57 
  58     private static AWTPermission fullScreenExclusivePermission;
  59 
  60     // Save/restore DisplayMode for the Full Screen mode
  61     private DisplayMode originalMode;
  62 
  63     public CGraphicsDevice(final int displayID) {
  64         this.displayID = displayID;
  65         config = MacOSFlags.isMetalEnabled() ?
  66                 MTLGraphicsConfig.getConfig(this, displayID, 0) :
  67                 CGLGraphicsConfig.getConfig(this, displayID, 0);
  68     }
  69 
  70     /**
  71      * Return a list of all configurations.
  72      */
  73     @Override
  74     public GraphicsConfiguration[] getConfigurations() {
  75         return new GraphicsConfiguration[]{config};
  76     }
  77 
  78     /**
  79      * Return the default configuration.
  80      */
  81     @Override
  82     public GraphicsConfiguration getDefaultConfiguration() {
  83         return config;
  84     }
  85 
  86     /**
  87      * Return a human-readable screen description.


< prev index next >