--- a/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java Tue Jul 22 11:40:06 2008 -0700
+++ b/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java Thu Jul 24 21:12:50 2008 -0700
@@ -25,9 +25,11 @@
package sun.awt;
+import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;
+import java.awt.peer.ComponentPeer;
import java.io.File;
import java.io.IOException;
import java.lang.ref.WeakReference;
@@ -44,6 +46,7 @@
import sun.java2d.SunGraphicsEnvironment;
import sun.java2d.SurfaceManagerFactory;
import sun.java2d.WindowsSurfaceManagerFactory;
+import sun.java2d.d3d.D3DGraphicsDevice;
import sun.java2d.windows.WindowsFlags;
/**
@@ -333,12 +336,21 @@
protected static native void deRegisterFontWithPlatform(String fontName);
protected GraphicsDevice makeScreenDevice(int screennum) {
- return new Win32GraphicsDevice(screennum);
+ GraphicsDevice device = null;
+ if (WindowsFlags.isD3DEnabled()) {
+ device = D3DGraphicsDevice.createDevice(screennum);
+ }
+ if (device == null) {
+ device = new Win32GraphicsDevice(screennum);
+ }
+ return device;
}
// Implements SunGraphicsEnvironment.createFontConfiguration.
protected FontConfiguration createFontConfiguration() {
- return new WFontConfiguration(this);
+ FontConfiguration fc = new WFontConfiguration(this);
+ fc.init();
+ return fc;
}
public FontConfiguration createFontConfiguration(boolean preferLocaleFonts,
@@ -346,4 +358,39 @@
return new WFontConfiguration(this, preferLocaleFonts,preferPropFonts);
}
+
+ @Override
+ public boolean isFlipStrategyPreferred(ComponentPeer peer) {
+ GraphicsConfiguration gc;
+ if (peer != null && (gc = peer.getGraphicsConfiguration()) != null) {
+ GraphicsDevice gd = gc.getDevice();
+ if (gd instanceof D3DGraphicsDevice) {
+ return ((D3DGraphicsDevice)gd).isD3DEnabledOnDevice();
+ }
+ }
+ return false;
+ }
+
+ private static volatile boolean isDWMCompositionEnabled;
+ /**
+ * Returns true if dwm composition is currently enabled, false otherwise.
+ *
+ * @return true if dwm composition is enabled, false otherwise
+ */
+ public static boolean isDWMCompositionEnabled() {
+ return isDWMCompositionEnabled;
+ }
+
+ /**
+ * Called from the native code when DWM composition state changed.
+ * May be called multiple times during the lifetime of the application.
+ * REMIND: we may want to create a listener mechanism for this.
+ *
+ * Note: called on the Toolkit thread, no user code or locks are allowed.
+ *
+ * @param enabled indicates the state of dwm composition
+ */
+ private static void dwmCompositionChanged(boolean enabled) {
+ isDWMCompositionEnabled = enabled;
+ }
}