Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1387)

Unified Diff: gpu/ipc/service/gpu_vsync_provider_win.cc

Issue 2846613002: Fix a CHECK when monitor configuration changes (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/ipc/service/gpu_vsync_provider_win.cc
diff --git a/gpu/ipc/service/gpu_vsync_provider_win.cc b/gpu/ipc/service/gpu_vsync_provider_win.cc
index cae8e38c197e6c03790bb113d50ca58346b1f1e8..fd6461988f09b3476a185c2983fa4375b7d1d914 100644
--- a/gpu/ipc/service/gpu_vsync_provider_win.cc
+++ b/gpu/ipc/service/gpu_vsync_provider_win.cc
@@ -84,6 +84,7 @@ class GpuVSyncWorker : public base::Thread,
base::TimeDelta interval);
void InvokeCallbackAndReschedule(base::TimeTicks timestamp,
base::TimeDelta interval);
+ void UseDelayBasedVSyncOnError();
void ScheduleDelayBasedVSync(base::TimeTicks timebase,
base::TimeDelta interval);
@@ -189,10 +190,15 @@ void GpuVSyncWorker::WaitForVSyncOnThread() {
HMONITOR monitor =
MonitorFromWindow(surface_handle_, MONITOR_DEFAULTTONEAREST);
- MONITORINFOEX monitor_info;
+ MONITORINFOEX monitor_info = {};
monitor_info.cbSize = sizeof(MONITORINFOEX);
BOOL success = GetMonitorInfo(monitor, &monitor_info);
- CHECK(success);
+ if (!success) {
+ // This is possible when a monitor is switched off or disconnected.
+ CloseAdapter();
+ UseDelayBasedVSyncOnError();
+ return;
+ }
if (current_device_name_.compare(monitor_info.szDevice) != 0) {
// Monitor changed. Close the current adapter handle and open a new one.
@@ -204,11 +210,7 @@ void GpuVSyncWorker::WaitForVSyncOnThread() {
if (wait_result != STATUS_SUCCESS) {
if (wait_result == STATUS_GRAPHICS_PRESENT_OCCLUDED) {
// This may be triggered by the monitor going into sleep.
- // Use timer based mechanism as a backup, start with getting VSync
- // parameters to determine timebase and interval.
- // TODO(stanisc): Consider a slower v-sync rate in this particular case.
- vsync_provider_->GetVSyncParameters(base::Bind(
- &GpuVSyncWorker::ScheduleDelayBasedVSync, base::Unretained(this)));
+ UseDelayBasedVSyncOnError();
return;
} else {
base::debug::Alias(&wait_result);
@@ -259,6 +261,15 @@ void GpuVSyncWorker::InvokeCallbackAndReschedule(base::TimeTicks timestamp,
}
}
+void GpuVSyncWorker::UseDelayBasedVSyncOnError() {
+ // This is called in a case of an error.
+ // Use timer based mechanism as a backup for one v-sync cycle, start with
+ // getting VSync parameters to determine timebase and interval.
+ // TODO(stanisc): Consider a slower v-sync rate in this particular case.
+ vsync_provider_->GetVSyncParameters(base::Bind(
+ &GpuVSyncWorker::ScheduleDelayBasedVSync, base::Unretained(this)));
+}
+
void GpuVSyncWorker::ScheduleDelayBasedVSync(base::TimeTicks timebase,
base::TimeDelta interval) {
// This is called only when WaitForVBlankEvent fails due to monitor going to
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698