summaryrefslogtreecommitdiffstats
path: root/gfx/ipc/GPUProcessManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/ipc/GPUProcessManager.cpp')
-rw-r--r--gfx/ipc/GPUProcessManager.cpp60
1 files changed, 51 insertions, 9 deletions
diff --git a/gfx/ipc/GPUProcessManager.cpp b/gfx/ipc/GPUProcessManager.cpp
index babc523e3a..97f4d47111 100644
--- a/gfx/ipc/GPUProcessManager.cpp
+++ b/gfx/ipc/GPUProcessManager.cpp
@@ -136,10 +136,28 @@ GPUProcessManager::Observer::Observe(nsISupports* aSubject, const char* aTopic,
}
} else if (!strcmp(aTopic, "application-background")) {
mManager->mAppInForeground = false;
+ } else if (!strcmp(aTopic, "screen-information-changed")) {
+ mManager->ScreenInformationChanged();
}
return NS_OK;
}
+GPUProcessManager::BatteryObserver::BatteryObserver(GPUProcessManager* aManager)
+ : mManager(aManager) {
+ hal::RegisterBatteryObserver(this);
+}
+
+void GPUProcessManager::BatteryObserver::Notify(
+ const hal::BatteryInformation& aBatteryInfo) {
+ mManager->NotifyBatteryInfo(aBatteryInfo);
+}
+
+void GPUProcessManager::BatteryObserver::ShutDown() {
+ hal::UnregisterBatteryObserver(this);
+}
+
+GPUProcessManager::BatteryObserver::~BatteryObserver() {}
+
void GPUProcessManager::OnXPCOMShutdown() {
if (mObserver) {
nsContentUtils::UnregisterShutdownObserver(mObserver);
@@ -148,6 +166,7 @@ void GPUProcessManager::OnXPCOMShutdown() {
if (obsServ) {
obsServ->RemoveObserver(mObserver, "application-foreground");
obsServ->RemoveObserver(mObserver, "application-background");
+ obsServ->RemoveObserver(mObserver, "screen-information-changed");
}
mObserver = nullptr;
}
@@ -172,6 +191,21 @@ void GPUProcessManager::OnPreferenceChange(const char16_t* aData) {
}
}
+void GPUProcessManager::ScreenInformationChanged() {
+#if defined(XP_WIN)
+ if (!!mGPUChild) {
+ mGPUChild->SendScreenInformationChanged();
+ }
+#endif
+}
+
+void GPUProcessManager::NotifyBatteryInfo(
+ const hal::BatteryInformation& aBatteryInfo) {
+ if (mGPUChild) {
+ mGPUChild->SendNotifyBatteryInfo(aBatteryInfo);
+ }
+}
+
void GPUProcessManager::ResetProcessStable() {
mTotalProcessAttempts++;
mProcessStable = false;
@@ -207,6 +241,7 @@ bool GPUProcessManager::LaunchGPUProcess() {
if (obsServ) {
obsServ->AddObserver(mObserver, "application-foreground", false);
obsServ->AddObserver(mObserver, "application-background", false);
+ obsServ->AddObserver(mObserver, "screen-information-changed", false);
}
}
@@ -566,6 +601,9 @@ void GPUProcessManager::OnProcessLaunchComplete(GPUProcessHost* aHost) {
std::move(vsyncChild));
mGPUChild->SendInitVsyncBridge(std::move(vsyncParent));
+ MOZ_ASSERT(!mBatteryObserver);
+ mBatteryObserver = new BatteryObserver(this);
+
// Flush any pref updates that happened during launch and weren't
// included in the blobs set up in LaunchGPUProcess.
for (const mozilla::dom::Pref& pref : mQueuedPrefs) {
@@ -573,12 +611,11 @@ void GPUProcessManager::OnProcessLaunchComplete(GPUProcessHost* aHost) {
}
mQueuedPrefs.Clear();
- CrashReporter::AnnotateCrashReport(
- CrashReporter::Annotation::GPUProcessStatus, "Running"_ns);
+ CrashReporter::RecordAnnotationCString(
+ CrashReporter::Annotation::GPUProcessStatus, "Running");
- CrashReporter::AnnotateCrashReport(
- CrashReporter::Annotation::GPUProcessLaunchCount,
- static_cast<int>(mTotalProcessAttempts));
+ CrashReporter::RecordAnnotationU32(
+ CrashReporter::Annotation::GPUProcessLaunchCount, mTotalProcessAttempts);
ReinitializeRendering();
}
@@ -754,8 +791,9 @@ void GPUProcessManager::NotifyWebRenderError(wr::WebRenderError aError) {
Telemetry::Accumulate(Telemetry::DEVICE_RESET_REASON, uint32_t(aReason));
}
- CrashReporter::AnnotateCrashReport(
- CrashReporter::Annotation::DeviceResetReason, int(aReason));
+ CrashReporter::RecordAnnotationU32(
+ CrashReporter::Annotation::DeviceResetReason,
+ static_cast<uint32_t>(aReason));
}
bool GPUProcessManager::OnDeviceReset(bool aTrackThreshold) {
@@ -1062,9 +1100,13 @@ void GPUProcessManager::DestroyProcess(bool aUnexpectedShutdown) {
mVsyncBridge->Close();
mVsyncBridge = nullptr;
}
+ if (mBatteryObserver) {
+ mBatteryObserver->ShutDown();
+ mBatteryObserver = nullptr;
+ }
- CrashReporter::AnnotateCrashReport(
- CrashReporter::Annotation::GPUProcessStatus, "Destroyed"_ns);
+ CrashReporter::RecordAnnotationCString(
+ CrashReporter::Annotation::GPUProcessStatus, "Destroyed");
}
already_AddRefed<CompositorSession> GPUProcessManager::CreateTopLevelCompositor(