Bug 1256728: Add environment variable to disable force present from bug 1232042. r?benwa draft
authorMilan Sreckovic <milan@mozilla.com>
Mon, 28 Mar 2016 12:59:38 -0400
changeset 345256 a2f4ec4ecdfa50902faa589d4aed441be1c0f302
parent 344995 63be002b4a803df1122823841ef7633b7561d873
child 517140 2d57f6d691c80128b367ac64c21525f59daf5a39
push id14030
push usermsreckovic@mozilla.com
push dateMon, 28 Mar 2016 17:02:43 +0000
reviewersbenwa
bugs1256728, 1232042
milestone48.0a1
Bug 1256728: Add environment variable to disable force present from bug 1232042. r?benwa MozReview-Commit-ID: 5jRr0dPMKRV
gfx/thebes/gfxEnv.h
widget/windows/nsWindowGfx.cpp
--- a/gfx/thebes/gfxEnv.h
+++ b/gfx/thebes/gfxEnv.h
@@ -43,16 +43,20 @@ public:
   DECL_GFX_ENV_LIVE("MOZ_DEBUG_SHADERS", DebugShaders);
 
   // Disabling context sharing in GLContextProviderGLX
   DECL_GFX_ENV_ONCE("MOZ_DISABLE_CONTEXT_SHARING_GLX", DisableContextSharingGlx);
 
   // Disabling the crash guard in DriverCrashGuard
   DECL_GFX_ENV_ONCE("MOZ_DISABLE_CRASH_GUARD", DisableCrashGuard);
 
+  // We force present to work around some Windows bugs - disable that if this
+  // environment variable is set.
+  DECL_GFX_ENV_ONCE("MOZ_DISABLE_FORCE_PRESENT", DisableForcePresent);
+
   // Together with paint dumping, only when MOZ_DUMP_PAINTING is defined.
   // Dumping compositor textures is broken pretty badly. For example,
   // on Linux it crashes TextureHost::GetAsSurface() returns null.
   // Expect to have to fix things like this if you turn it on.
   // Meanwhile, content-side texture dumping
   // (conditioned on DebugDumpPainting()) is a good replacement.
   DECL_GFX_ENV_ONCE("MOZ_DUMP_COMPOSITOR_TEXTURES", DumpCompositorTextures);
 
--- a/widget/windows/nsWindowGfx.cpp
+++ b/widget/windows/nsWindowGfx.cpp
@@ -19,16 +19,17 @@
 
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/plugins/PluginInstanceParent.h"
 using mozilla::plugins::PluginInstanceParent;
 
 #include "nsWindowGfx.h"
 #include "nsAppRunner.h"
 #include <windows.h>
+#include "gfxEnv.h"
 #include "gfxImageSurface.h"
 #include "gfxUtils.h"
 #include "gfxWindowsSurface.h"
 #include "gfxWindowsPlatform.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/DataSurfaceHelpers.h"
 #include "mozilla/gfx/Tools.h"
 #include "mozilla/RefPtr.h"
@@ -521,19 +522,21 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t
             }
           }
         }
         break;
       case LayersBackend::LAYERS_CLIENT:
         {
           result = listener->PaintWindow(
             this, LayoutDeviceIntRegion::FromUnknownRegion(region));
-          nsCOMPtr<nsIRunnable> event =
-            NS_NewRunnableMethod(this, &nsWindow::ForcePresent);
-          NS_DispatchToMainThread(event);
+          if (!gfxEnv::DisableForcePresent()) {
+            nsCOMPtr<nsIRunnable> event =
+              NS_NewRunnableMethod(this, &nsWindow::ForcePresent);
+            NS_DispatchToMainThread(event);
+          }
         }
         break;
       default:
         NS_ERROR("Unknown layers backend used!");
         break;
     }
   }