< prev index next >

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

Print this page




  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 import sun.java2d.metal.MetalGraphicsConfig;
  41 
  42 public final class CGraphicsDevice extends GraphicsDevice
  43         implements DisplayChangedListener {
  44 
  45     /**
  46      * CoreGraphics display ID. This identifier can become non-valid at any time
  47      * therefore methods, which is using this id should be ready to it.
  48      */
  49     private volatile int displayID;
  50     private volatile double xResolution;
  51     private volatile double yResolution;
  52     private volatile Rectangle bounds;
  53     private volatile int scale;
  54 
  55     private final GraphicsConfiguration config;
  56 
  57     private static AWTPermission fullScreenExclusivePermission;
  58 
  59     // Save/restore DisplayMode for the Full Screen mode
  60     private DisplayMode originalMode;
  61 
  62     public CGraphicsDevice(final int displayID) {
  63         this.displayID = displayID;
  64 
  65         if (isMetalSystemProperty()) {
  66             config = MetalGraphicsConfig.getConfig(this, displayID, 0);
  67             System.out.println("Created MetalGraphicsConfig");
  68         } else {
  69             config = CGLGraphicsConfig.getConfig(this, displayID, 0);
  70         }
  71     }
  72 
  73     private boolean isMetalSystemProperty() {
  74            String str = System.getProperty("sun.java2d.metal");
  75            
  76            if (str != null) {
  77                System.out.println("Property : sun.java2d.metal=" + str);
  78                if (str.equals("true")) {
  79                 return true;    
  80                }
  81          }
  82          return false;
  83     }
  84 
  85     /**
  86      * Return a list of all configurations.
  87      */
  88     @Override
  89     public GraphicsConfiguration[] getConfigurations() {
  90         return new GraphicsConfiguration[]{config};
  91     }
  92 
  93     /**
  94      * Return the default configuration.
  95      */
  96     @Override
  97     public GraphicsConfiguration getDefaultConfiguration() {
  98         return config;
  99     }
 100 
 101     /**
 102      * 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 >