src/macosx/classes/sun/awt/CGraphicsEnvironment.java

Print this page




  23  * questions.
  24  */
  25 
  26 package sun.awt;
  27 
  28 import java.awt.*;
  29 import java.util.*;
  30 
  31 import sun.java2d.*;
  32 
  33 /**
  34  * This is an implementation of a GraphicsEnvironment object for the default
  35  * local GraphicsEnvironment used by the Java Runtime Environment for Mac OS X
  36  * GUI environments.
  37  *
  38  * @see GraphicsDevice
  39  * @see GraphicsConfiguration
  40  */
  41 public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
  42 
  43     // Global initialization of the Cocoa runtime.
  44     private static native void initCocoa();
  45 
  46     /**
  47      * Fetch an array of all valid CoreGraphics display identifiers.
  48      */
  49     private static native int[] getDisplayIDs();
  50 
  51     /**
  52      * Fetch the CoreGraphics display ID for the 'main' display.
  53      */
  54     private static native int getMainDisplayID();
  55 
  56     /**
  57      * Noop function that just acts as an entry point for someone to force a
  58      * static initialization of this class.
  59      */
  60     public static void init() { }
  61 
  62     static {
  63         java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<Void>() {
  64             public Void run() {
  65                 System.loadLibrary("awt");
  66                 return null;
  67             }
  68         });
  69 
  70         java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<Void>() {
  71             public Void run() {
  72                 if (isHeadless()) return null;
  73                 initCocoa();
  74                 return null;
  75             }
  76         });
  77 
  78         // Install the correct surface manager factory.
  79         SurfaceManagerFactory.setInstance(new MacosxSurfaceManagerFactory());
  80     }
  81 
  82     /**
  83      * Register the instance with CGDisplayRegisterReconfigurationCallback().
  84      * The registration uses a weak global reference -- if our instance is
  85      * garbage collected, the reference will be dropped.
  86      *
  87      * @return Return the registration context (a pointer).
  88      */
  89     private native long registerDisplayReconfiguration();
  90 
  91     /**
  92      * Remove the instance's registration with CGDisplayRemoveReconfigurationCallback()
  93      */
  94     private native void deregisterDisplayReconfiguration(long context);
  95 
  96     /** Available CoreGraphics displays. */
  97     private final Map<Integer, CGraphicsDevice> devices = new HashMap<>(5);




  23  * questions.
  24  */
  25 
  26 package sun.awt;
  27 
  28 import java.awt.*;
  29 import java.util.*;
  30 
  31 import sun.java2d.*;
  32 
  33 /**
  34  * This is an implementation of a GraphicsEnvironment object for the default
  35  * local GraphicsEnvironment used by the Java Runtime Environment for Mac OS X
  36  * GUI environments.
  37  *
  38  * @see GraphicsDevice
  39  * @see GraphicsConfiguration
  40  */
  41 public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
  42 



  43     /**
  44      * Fetch an array of all valid CoreGraphics display identifiers.
  45      */
  46     private static native int[] getDisplayIDs();
  47 
  48     /**
  49      * Fetch the CoreGraphics display ID for the 'main' display.
  50      */
  51     private static native int getMainDisplayID();
  52 
  53     /**
  54      * Noop function that just acts as an entry point for someone to force a
  55      * static initialization of this class.
  56      */
  57     public static void init() { }
  58 
  59     static {
  60         // Load libraries and initialize the Toolkit.
  61         Toolkit.getDefaultToolkit();













  62         // Install the correct surface manager factory.
  63         SurfaceManagerFactory.setInstance(new MacosxSurfaceManagerFactory());
  64     }
  65 
  66     /**
  67      * Register the instance with CGDisplayRegisterReconfigurationCallback().
  68      * The registration uses a weak global reference -- if our instance is
  69      * garbage collected, the reference will be dropped.
  70      *
  71      * @return Return the registration context (a pointer).
  72      */
  73     private native long registerDisplayReconfiguration();
  74 
  75     /**
  76      * Remove the instance's registration with CGDisplayRemoveReconfigurationCallback()
  77      */
  78     private native void deregisterDisplayReconfiguration(long context);
  79 
  80     /** Available CoreGraphics displays. */
  81     private final Map<Integer, CGraphicsDevice> devices = new HashMap<>(5);