Bug 1475355. Only use WebRender if there's no battery. r=kats

MozReview-Commit-ID: 86cfi2SGkA2

--HG--
extra : rebase_source : 078f17d049c86d9110ae2a26edb58455070b8eb0
This commit is contained in:
Jeff Muizelaar 2018-07-17 18:05:44 -04:00
Родитель c6926db959
Коммит 5c51801714
1 изменённых файлов: 18 добавлений и 1 удалений

Просмотреть файл

@ -57,6 +57,7 @@
#endif
#ifdef XP_WIN
#include <windows.h>
#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,