Bug 1281105 - Disable GLX vsync when using the basic compositor. r?jgilbert
MozReview-Commit-ID: HNvcCUbleMw
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -10,16 +10,17 @@
#include "prenv.h"
#include "nsUnicharUtils.h"
#include "nsUnicodeProperties.h"
#include "gfx2DGlue.h"
#include "gfxFcPlatformFontList.h"
#include "gfxFontconfigUtils.h"
#include "gfxFontconfigFonts.h"
+#include "gfxConfig.h"
#include "gfxContext.h"
#include "gfxUserFontSet.h"
#include "gfxUtils.h"
#include "gfxFT2FontBase.h"
#include "gfxPrefs.h"
#include "VsyncSource.h"
#include "mozilla/Atomics.h"
#include "mozilla/Monitor.h"
@@ -833,22 +834,27 @@ public:
private:
// We need a refcounted VsyncSource::Display to use chromium IPC runnables.
RefPtr<GLXDisplay> mGlobalDisplay;
};
already_AddRefed<gfx::VsyncSource>
gfxPlatformGtk::CreateHardwareVsyncSource()
{
- if (gl::sGLXLibrary.SupportsVideoSync()) {
- RefPtr<VsyncSource> vsyncSource = new GLXVsyncSource();
- VsyncSource::Display& display = vsyncSource->GetGlobalDisplay();
- if (!static_cast<GLXVsyncSource::GLXDisplay&>(display).Setup()) {
- NS_WARNING("Failed to setup GLContext, falling back to software vsync.");
- return gfxPlatform::CreateHardwareVsyncSource();
+ // Only use GLX vsync when the OpenGL compositor is being used.
+ // The extra cost of initializing a GLX context while blocking the main
+ // thread is not worth it when using basic composition.
+ if (gfxConfig::IsEnabled(Feature::HW_COMPOSITING)) {
+ if (gl::sGLXLibrary.SupportsVideoSync()) {
+ RefPtr<VsyncSource> vsyncSource = new GLXVsyncSource();
+ VsyncSource::Display& display = vsyncSource->GetGlobalDisplay();
+ if (!static_cast<GLXVsyncSource::GLXDisplay&>(display).Setup()) {
+ NS_WARNING("Failed to setup GLContext, falling back to software vsync.");
+ return gfxPlatform::CreateHardwareVsyncSource();
+ }
+ return vsyncSource.forget();
}
- return vsyncSource.forget();
+ NS_WARNING("SGI_video_sync unsupported. Falling back to software vsync.");
}
- NS_WARNING("SGI_video_sync unsupported. Falling back to software vsync.");
return gfxPlatform::CreateHardwareVsyncSource();
}
#endif