6663447: D3D: excessive surface data replacements
authorbae
Fri, 22 Oct 2010 16:57:41 +0400
changeset 6996 5122ee0dcc92
parent 6818 feb638afc792
child 6997 3642614e2282
6663447: D3D: excessive surface data replacements Reviewed-by: prr, art
jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java
--- a/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java	Fri Oct 22 16:57:41 2010 +0400
@@ -605,6 +605,7 @@
     }
 
     private native void setOpacity(int iOpacity);
+    private float opacity = 1.0f;
 
     public void setOpacity(float opacity) {
         if (!((SunToolkit)((Window)target).getToolkit()).
@@ -613,7 +614,21 @@
             return;
         }
 
-        replaceSurfaceDataRecursively((Component)getTarget());
+        if (opacity < 0.0f || opacity > 1.0f) {
+            throw new IllegalArgumentException(
+                "The value of opacity should be in the range [0.0f .. 1.0f].");
+        }
+
+        if (((this.opacity == 1.0f && opacity <  1.0f) ||
+             (this.opacity <  1.0f && opacity == 1.0f)) &&
+            !Win32GraphicsEnvironment.isVistaOS())
+        {
+            // non-Vista OS: only replace the surface data if opacity status
+            // changed (see WComponentPeer.isAccelCapable() for more)
+            replaceSurfaceDataRecursively((Component)getTarget());
+        }
+
+        this.opacity = opacity;
 
         final int maxOpacity = 0xff;
         int iOpacity = (int)(opacity * maxOpacity);
@@ -655,7 +670,7 @@
 
         boolean isVistaOS = Win32GraphicsEnvironment.isVistaOS();
 
-        if (!isVistaOS) {
+        if (this.isOpaque != isOpaque && !isVistaOS) {
             // non-Vista OS: only replace the surface data if the opacity
             // status changed (see WComponentPeer.isAccelCapable() for more)
             replaceSurfaceDataRecursively(target);