Print this page
Added gradle and cmake project


  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     // Array of all GraphicsConfig instances for this device
  55     private final GraphicsConfiguration[] configs;
  56 
  57     // Default config (temporarily hard coded)
  58     private final int DEFAULT_CONFIG = 0;
  59 
  60     private static AWTPermission fullScreenExclusivePermission;
  61 
  62     // Save/restore DisplayMode for the Full Screen mode
  63     private DisplayMode originalMode;
  64 
  65     public CGraphicsDevice(final int displayID) {
  66         this.displayID = displayID;
  67         configs = new GraphicsConfiguration[] {


  68             CGLGraphicsConfig.getConfig(this, displayID, 0)
  69         };
  70     }
  71 
  72     /**
  73      * Return a list of all configurations.
  74      */
  75     @Override
  76     public GraphicsConfiguration[] getConfigurations() {
  77         return configs.clone();
  78     }
  79 
  80     /**
  81      * Return the default configuration.
  82      */
  83     @Override
  84     public GraphicsConfiguration getDefaultConfiguration() {
  85         return configs[DEFAULT_CONFIG];
  86     }
  87 


 256                     : nativeGetScaleFactor(displayID));
 257         } else {
 258             scale = 1;
 259         }
 260     }
 261 
 262     private static native double nativeGetScaleFactor(int displayID);
 263 
 264     private static native void nativeSetDisplayMode(int displayID, int w, int h, int bpp, int refrate);
 265 
 266     private static native DisplayMode nativeGetDisplayMode(int displayID);
 267 
 268     private static native DisplayMode[] nativeGetDisplayModes(int displayID);
 269 
 270     private static native double nativeGetXResolution(int displayID);
 271 
 272     private static native double nativeGetYResolution(int displayID);
 273 
 274     private static native Insets nativeGetScreenInsets(int displayID);
 275 


 276     private static native Rectangle2D nativeGetBounds(int displayID);
 277 }


  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     // Array of all GraphicsConfig instances for this device
  57     private final GraphicsConfiguration[] configs;
  58 
  59     // Default config (temporarily hard coded)
  60     private final int DEFAULT_CONFIG = 0;
  61 
  62     private static AWTPermission fullScreenExclusivePermission;
  63 
  64     // Save/restore DisplayMode for the Full Screen mode
  65     private DisplayMode originalMode;
  66 
  67     public CGraphicsDevice(final int displayID) {
  68         this.displayID = displayID;
  69         configs = new GraphicsConfiguration[] {
  70                 MacOSFlags.isMetalEnabled() ?
  71                         MTLGraphicsConfig.getConfig(this, displayID, 0) :
  72                         CGLGraphicsConfig.getConfig(this, displayID, 0)
  73         };
  74     }
  75 
  76     /**
  77      * Return a list of all configurations.
  78      */
  79     @Override
  80     public GraphicsConfiguration[] getConfigurations() {
  81         return configs.clone();
  82     }
  83 
  84     /**
  85      * Return the default configuration.
  86      */
  87     @Override
  88     public GraphicsConfiguration getDefaultConfiguration() {
  89         return configs[DEFAULT_CONFIG];
  90     }
  91 


 260                     : nativeGetScaleFactor(displayID));
 261         } else {
 262             scale = 1;
 263         }
 264     }
 265 
 266     private static native double nativeGetScaleFactor(int displayID);
 267 
 268     private static native void nativeSetDisplayMode(int displayID, int w, int h, int bpp, int refrate);
 269 
 270     private static native DisplayMode nativeGetDisplayMode(int displayID);
 271 
 272     private static native DisplayMode[] nativeGetDisplayModes(int displayID);
 273 
 274     private static native double nativeGetXResolution(int displayID);
 275 
 276     private static native double nativeGetYResolution(int displayID);
 277 
 278     private static native Insets nativeGetScreenInsets(int displayID);
 279 
 280     private static native String nativeGetMetalDeviceName(int displayID);
 281 
 282     private static native Rectangle2D nativeGetBounds(int displayID);
 283 }