Bug 590368. Pass SWP_NOCOPYBITS when moving a clipped plugin window with D3D9, to work around a Windows/driver bug. r=jmathies a=blocking
authorRobert O'Callahan <robert@ocallahan.org>
Sun, 05 Dec 2010 15:02:17 +0000
changeset 58633 a49bc63fe3d0938b68b841274d9416baf84313f2
parent 58632 20441229d0a7be4a7b4bf8b038f0f48b9e9164b6
child 58634 12c31d0065cab5a446001415e42853fc6627b64c
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersjmathies, blocking
bugs590368
milestone2.0b8pre
Bug 590368. Pass SWP_NOCOPYBITS when moving a clipped plugin window with D3D9, to work around a Windows/driver bug. r=jmathies a=blocking
widget/src/windows/nsWindow.cpp
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -228,16 +228,17 @@
 
 #ifdef MOZ_CRASHREPORTER
 #include "nsICrashReporter.h"
 #endif
 
 #include "nsIXULRuntime.h"
 
 using namespace mozilla::widget;
+using namespace mozilla::layers;
 
 /**************************************************************
  **************************************************************
  **
  ** BLOCK: Variables
  **
  ** nsWindow Class static initializations and global variables. 
  **
@@ -1387,18 +1388,29 @@ NS_METHOD nsWindow::Move(PRInt32 aX, PRI
           if (aX < 0 || aX >= workArea.right || aY < 0 || aY >= workArea.bottom)
             printf("window moved to offscreen position\n");
         }
       ::ReleaseDC(mWnd, dc);
       }
     }
 #endif
     ClearThemeRegion();
-    VERIFY(::SetWindowPos(mWnd, NULL, aX, aY, 0, 0,
-                          SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE));
+
+    UINT flags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE;
+    // Workaround SetWindowPos bug with D3D9. If our window has a clip
+    // region, some drivers or OSes may incorrectly copy into the clipped-out
+    // area.
+    if (mWindowType == eWindowType_plugin &&
+        (!mLayerManager || mLayerManager->GetBackendType() == LayerManager::LAYERS_D3D9) &&
+        mClipRects &&
+        (mClipRectCount != 1 || mClipRects[0] != nsIntRect(0, 0, mBounds.width, mBounds.height))) {
+      flags |= SWP_NOCOPYBITS;
+    }
+    VERIFY(::SetWindowPos(mWnd, NULL, aX, aY, 0, 0, flags));
+
     SetThemeRegion();
   }
   return NS_OK;
 }
 
 // Resize this component
 NS_METHOD nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
 {