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
34 import sun.java2d.opengl.CGLGraphicsConfig;
35
36 import sun.awt.FullScreenCapable;
37
38 public class CGraphicsDevice extends GraphicsDevice {
39
40 // CoreGraphics display ID
41 private final int displayID;
42
43 // Array of all GraphicsConfig instances for this device
44 private final GraphicsConfiguration[] configs;
45
46 // Default config (temporarily hard coded)
47 private final int DEFAULT_CONFIG = 0;
48
49 private static AWTPermission fullScreenExclusivePermission;
50
51 // Save/restore DisplayMode for the Full Screen mode
52 private DisplayMode originalMode;
53
54 public CGraphicsDevice(int displayID) {
55 this.displayID = displayID;
56 configs = new GraphicsConfiguration[] {
57 CGLGraphicsConfig.getConfig(this, 0)
58 };
89 return "Display " + this.displayID;
90 }
91
92 /**
93 * Returns the type of the graphics device.
94 * @see #TYPE_RASTER_SCREEN
95 * @see #TYPE_PRINTER
96 * @see #TYPE_IMAGE_BUFFER
97 */
98 @Override
99 public int getType() {
100 return TYPE_RASTER_SCREEN;
101 }
102
103 public double getXResolution() {
104 return nativeGetXResolution(displayID);
105 }
106
107 public double getYResolution() {
108 return nativeGetYResolution(displayID);
109 }
110
111 public int getScreenResolution() {
112 // TODO: report non-72 value when HiDPI is turned on
113 return 72;
114 }
115
116 private static native double nativeGetXResolution(int displayID);
117 private static native double nativeGetYResolution(int displayID);
118
119 /**
120 * Enters full-screen mode, or returns to windowed mode.
121 */
122 @Override
123 public synchronized void setFullScreenWindow(Window w) {
124 Window old = getFullScreenWindow();
125 if (w == old) {
126 return;
127 }
128
129 boolean fsSupported = isFullScreenSupported();
130
131 if (fsSupported && old != null) {
132 // enter windowed mode (and restore original display mode)
133 exitFullScreenExclusive(old);
|
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
34 import sun.java2d.opengl.CGLGraphicsConfig;
35
36 public final class CGraphicsDevice extends GraphicsDevice {
37
38 // CoreGraphics display ID
39 private final int displayID;
40
41 // Array of all GraphicsConfig instances for this device
42 private final GraphicsConfiguration[] configs;
43
44 // Default config (temporarily hard coded)
45 private final int DEFAULT_CONFIG = 0;
46
47 private static AWTPermission fullScreenExclusivePermission;
48
49 // Save/restore DisplayMode for the Full Screen mode
50 private DisplayMode originalMode;
51
52 public CGraphicsDevice(int displayID) {
53 this.displayID = displayID;
54 configs = new GraphicsConfiguration[] {
55 CGLGraphicsConfig.getConfig(this, 0)
56 };
87 return "Display " + this.displayID;
88 }
89
90 /**
91 * Returns the type of the graphics device.
92 * @see #TYPE_RASTER_SCREEN
93 * @see #TYPE_PRINTER
94 * @see #TYPE_IMAGE_BUFFER
95 */
96 @Override
97 public int getType() {
98 return TYPE_RASTER_SCREEN;
99 }
100
101 public double getXResolution() {
102 return nativeGetXResolution(displayID);
103 }
104
105 public double getYResolution() {
106 return nativeGetYResolution(displayID);
107 }
108
109 private static native double nativeGetXResolution(int displayID);
110 private static native double nativeGetYResolution(int displayID);
111
112 /**
113 * Enters full-screen mode, or returns to windowed mode.
114 */
115 @Override
116 public synchronized void setFullScreenWindow(Window w) {
117 Window old = getFullScreenWindow();
118 if (w == old) {
119 return;
120 }
121
122 boolean fsSupported = isFullScreenSupported();
123
124 if (fsSupported && old != null) {
125 // enter windowed mode (and restore original display mode)
126 exitFullScreenExclusive(old);
|