From 5c51801714e3227e52b8bcfd4384edf46655a2f7 Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Tue, 17 Jul 2018 18:05:44 -0400 Subject: [PATCH] Bug 1475355. Only use WebRender if there's no battery. r=kats MozReview-Commit-ID: 86cfi2SGkA2 --HG-- extra : rebase_source : 078f17d049c86d9110ae2a26edb58455070b8eb0 --- gfx/thebes/gfxPlatform.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index efbfba7ba2f3..85f5f8c70374 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -57,6 +57,7 @@ #endif #ifdef XP_WIN +#include #include "mozilla/WindowsVersion.h" #include "mozilla/gfx/DeviceManagerDx.h" #endif @@ -2522,6 +2523,22 @@ gfxPlatform::WebRenderEnvvarEnabled() return (env && *env == '1'); } +/* This is a pretty conservative check for having a battery. + * For now we'd rather err on the side of thinking we do. */ +static bool HasBattery() +{ +#ifdef XP_WIN + SYSTEM_POWER_STATUS status; + const BYTE NO_SYSTEM_BATTERY = 128; + if (GetSystemPowerStatus(&status)) { + if (status.BatteryFlag == NO_SYSTEM_BATTERY) { + return false; + } + } +#endif + return true; +} + void gfxPlatform::InitWebRenderConfig() { @@ -2572,7 +2589,7 @@ gfxPlatform::InitWebRenderConfig() int32_t status; if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_WEBRENDER, discardFailureId, &status))) { - if (status == nsIGfxInfo::FEATURE_STATUS_OK) { + if (status == nsIGfxInfo::FEATURE_STATUS_OK && !HasBattery()) { featureWebRender.UserEnable("Qualified enabled by pref "); } else { featureWebRender.ForceDisable(FeatureStatus::Blocked,