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

Print this page




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  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.GraphicsConfiguration;
  29 import java.awt.GraphicsDevice;
  30 import java.awt.Window;
  31 import java.awt.AWTPermission;
  32 import java.awt.DisplayMode;
  33 import java.util.Objects;
  34 
  35 import sun.java2d.opengl.CGLGraphicsConfig;
  36 
  37 public final class CGraphicsDevice extends GraphicsDevice {
  38 
  39     // CoreGraphics display ID
  40     private final int displayID;
  41 
  42     // Array of all GraphicsConfig instances for this device
  43     private final GraphicsConfiguration[] configs;
  44 
  45     // Default config (temporarily hard coded)
  46     private final int DEFAULT_CONFIG = 0;
  47 
  48     private static AWTPermission fullScreenExclusivePermission;
  49 
  50     // Save/restore DisplayMode for the Full Screen mode
  51     private DisplayMode originalMode;
  52 
  53     public CGraphicsDevice(int displayID) {
  54         this.displayID = displayID;
  55         configs = new GraphicsConfiguration[] {
  56             CGLGraphicsConfig.getConfig(this, 0)
  57         };
  58     }
  59 
  60     /**



  61      * @return CoreGraphics display id.
  62      */
  63     public int getCoreGraphicsScreen() {
  64         return displayID;
  65     }
  66 
  67     /**
  68      * Return a list of all configurations.
  69      */
  70     @Override
  71     public GraphicsConfiguration[] getConfigurations() {
  72         return configs.clone();
  73     }
  74 
  75     /**
  76      * Return the default configuration.
  77      */
  78     @Override
  79     public GraphicsConfiguration getDefaultConfiguration() {
  80         return configs[DEFAULT_CONFIG];
  81     }
  82 
  83     /**




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  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.Window;


  33 import java.util.Objects;
  34 
  35 import sun.java2d.opengl.CGLGraphicsConfig;
  36 
  37 public final class CGraphicsDevice extends GraphicsDevice {
  38 
  39     // CoreGraphics display ID
  40     private final int displayID;
  41 
  42     // Array of all GraphicsConfig instances for this device
  43     private final GraphicsConfiguration[] configs;
  44 
  45     // Default config (temporarily hard coded)
  46     private final int DEFAULT_CONFIG = 0;
  47 
  48     private static AWTPermission fullScreenExclusivePermission;
  49 
  50     // Save/restore DisplayMode for the Full Screen mode
  51     private DisplayMode originalMode;
  52 
  53     public CGraphicsDevice(int displayID) {
  54         this.displayID = displayID;
  55         configs = new GraphicsConfiguration[] {
  56             CGLGraphicsConfig.getConfig(this, 0)
  57         };
  58     }
  59 
  60     /**
  61      * Returns CGDirectDisplayID, which is the same id as @"NSScreenNumber" in
  62      * NSScreen.
  63      *
  64      * @return CoreGraphics display id.
  65      */
  66     public int getCGDisplayID() {
  67         return displayID;
  68     }
  69 
  70     /**
  71      * Return a list of all configurations.
  72      */
  73     @Override
  74     public GraphicsConfiguration[] getConfigurations() {
  75         return configs.clone();
  76     }
  77 
  78     /**
  79      * Return the default configuration.
  80      */
  81     @Override
  82     public GraphicsConfiguration getDefaultConfiguration() {
  83         return configs[DEFAULT_CONFIG];
  84     }
  85 
  86     /**