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.java2d.d3d; 27 28 import java.awt.Dialog; 29 import java.awt.DisplayMode; 30 import java.awt.Frame; 31 import java.awt.GraphicsConfiguration; 32 import java.awt.Rectangle; 33 import java.awt.Toolkit; 34 import java.awt.Window; 35 import java.awt.event.WindowAdapter; 36 import java.awt.event.WindowEvent; 37 import java.awt.event.WindowListener; 38 import java.awt.peer.WindowPeer; 39 import java.util.ArrayList; 40 41 import jdk.internal.perf.PerfCounter; 42 import sun.awt.AWTAccessor; 43 import sun.awt.AWTAccessor.ComponentAccessor; 44 import sun.awt.Win32GraphicsDevice; 45 import sun.awt.windows.WWindowPeer; 46 import sun.java2d.pipe.hw.ContextCapabilities; 47 import sun.java2d.windows.WindowsFlags; 48 import static sun.java2d.d3d.D3DContext.D3DContextCaps.*; 49 import sun.java2d.d3d.D3DContext.D3DContextCaps; 50 51 /** 52 * This class implements D3D-specific functionality, such as fullscreen 53 * exclusive mode and display changes. It is kept separate from 54 * Win32GraphicsDevice to help avoid overburdening the parent class. 55 */ 56 public class D3DGraphicsDevice extends Win32GraphicsDevice { 57 private D3DContext context; 58 59 private static boolean d3dAvailable; 60 61 private ContextCapabilities d3dCaps; 62 63 private static native boolean initD3D(); 64 65 static { 66 // loading the library doesn't help because we need the 67 // toolkit thread running, so we have to call getDefaultToolkit() 68 Toolkit.getDefaultToolkit(); 69 d3dAvailable = initD3D(); 70 if (d3dAvailable) { 71 // we don't use pixel formats for the d3d pipeline 72 pfDisabled = true; 73 PerfCounter.getD3DAvailable().set(1); 74 } else { 75 PerfCounter.getD3DAvailable().set(0); 76 } 77 } 78 79 /** 80 * Used to construct a Direct3D-enabled GraphicsDevice. 81 * 82 * @return a D3DGraphicsDevice if it could be created 83 * successfully, null otherwise. 84 */ 85 public static D3DGraphicsDevice createDevice(int screen) { 86 if (!d3dAvailable) { 87 return null; 88 } 89 90 ContextCapabilities d3dCaps = getDeviceCaps(screen); 91 // could not initialize the device successfully 92 if ((d3dCaps.getCaps() & CAPS_DEVICE_OK) == 0) { 93 if (WindowsFlags.isD3DVerbose()) { 94 System.out.println("Could not enable Direct3D pipeline on " + 95 "screen " + screen); | 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.java2d.d3d; 27 28 import java.awt.Dialog; 29 import java.awt.DisplayMode; 30 import java.awt.Frame; 31 import java.awt.GraphicsConfiguration; 32 import java.awt.Rectangle; 33 import java.awt.Toolkit; 34 import java.awt.Window; 35 import java.awt.event.WindowAdapter; 36 import java.awt.event.WindowEvent; 37 import java.awt.event.WindowListener; 38 import java.awt.peer.WindowPeer; 39 import java.util.ArrayList; 40 41 import sun.awt.AWTAccessor; 42 import sun.awt.AWTAccessor.ComponentAccessor; 43 import sun.awt.Win32GraphicsDevice; 44 import sun.awt.windows.WWindowPeer; 45 import sun.java2d.pipe.hw.ContextCapabilities; 46 import sun.java2d.windows.WindowsFlags; 47 import static sun.java2d.d3d.D3DContext.D3DContextCaps.*; 48 import sun.java2d.d3d.D3DContext.D3DContextCaps; 49 50 /** 51 * This class implements D3D-specific functionality, such as fullscreen 52 * exclusive mode and display changes. It is kept separate from 53 * Win32GraphicsDevice to help avoid overburdening the parent class. 54 */ 55 public class D3DGraphicsDevice extends Win32GraphicsDevice { 56 private D3DContext context; 57 58 private static boolean d3dAvailable; 59 60 private ContextCapabilities d3dCaps; 61 62 private static native boolean initD3D(); 63 64 static { 65 // loading the library doesn't help because we need the 66 // toolkit thread running, so we have to call getDefaultToolkit() 67 Toolkit.getDefaultToolkit(); 68 d3dAvailable = initD3D(); 69 if (d3dAvailable) { 70 // we don't use pixel formats for the d3d pipeline 71 pfDisabled = true; 72 } 73 } 74 75 /** 76 * Used to construct a Direct3D-enabled GraphicsDevice. 77 * 78 * @return a D3DGraphicsDevice if it could be created 79 * successfully, null otherwise. 80 */ 81 public static D3DGraphicsDevice createDevice(int screen) { 82 if (!d3dAvailable) { 83 return null; 84 } 85 86 ContextCapabilities d3dCaps = getDeviceCaps(screen); 87 // could not initialize the device successfully 88 if ((d3dCaps.getCaps() & CAPS_DEVICE_OK) == 0) { 89 if (WindowsFlags.isD3DVerbose()) { 90 System.out.println("Could not enable Direct3D pipeline on " + 91 "screen " + screen); |