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

Side by Side Diff: gpu/ipc/service/gpu_vsync_provider_win.cc

Issue 2710183004: Support GPU VSync when DirectComposition isn't enabled (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | gpu/ipc/service/image_transport_surface_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/ipc/service/gpu_vsync_provider_win.h" 5 #include "gpu/ipc/service/gpu_vsync_provider_win.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/atomicops.h" 9 #include "base/atomicops.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 monitor_info.cbSize = sizeof(MONITORINFOEX); 183 monitor_info.cbSize = sizeof(MONITORINFOEX);
184 BOOL success = GetMonitorInfo(monitor, &monitor_info); 184 BOOL success = GetMonitorInfo(monitor, &monitor_info);
185 CHECK(success); 185 CHECK(success);
186 186
187 if (current_device_name_.compare(monitor_info.szDevice) != 0) { 187 if (current_device_name_.compare(monitor_info.szDevice) != 0) {
188 // Monitor changed. Close the current adapter handle and open a new one. 188 // Monitor changed. Close the current adapter handle and open a new one.
189 CloseAdapter(); 189 CloseAdapter();
190 OpenAdapter(monitor_info.szDevice); 190 OpenAdapter(monitor_info.szDevice);
191 } 191 }
192 192
193 if (WaitForVBlankEvent()) { 193 // Crash if WaitForVBlankEvent fails to avoid spinning the loop.
194 vsync_provider_->GetVSyncParameters( 194 CHECK(WaitForVBlankEvent());
195 base::Bind(&GpuVSyncWorker::SendVSyncUpdate, base::Unretained(this), 195
196 base::TimeTicks::Now())); 196 vsync_provider_->GetVSyncParameters(
197 } 197 base::Bind(&GpuVSyncWorker::SendVSyncUpdate, base::Unretained(this),
198 base::TimeTicks::Now()));
198 199
199 Reschedule(); 200 Reschedule();
200 } 201 }
201 202
202 void GpuVSyncWorker::SendVSyncUpdate(base::TimeTicks now, 203 void GpuVSyncWorker::SendVSyncUpdate(base::TimeTicks now,
203 base::TimeTicks timestamp, 204 base::TimeTicks timestamp,
204 base::TimeDelta interval) { 205 base::TimeDelta interval) {
205 base::TimeDelta adjustment; 206 base::TimeDelta adjustment;
206 207
207 if (!(timestamp.is_null() || interval.is_zero())) { 208 if (!(timestamp.is_null() || interval.is_zero())) {
208 // Timestamp comes from DwmGetCompositionTimingInfo and apparently it might 209 // Timestamp comes from DwmGetCompositionTimingInfo and apparently it might
209 // be up to 2-3 vsync cycles in the past or in the future. 210 // be up to 2-3 vsync cycles in the past or in the future.
210 // The adjustment formula was suggested here: 211 // The adjustment formula was suggested here:
211 // http://www.vsynctester.com/firefoxisbroken.html 212 // http://www.vsynctester.com/firefoxisbroken.html
212 base::TimeDelta adjustment = 213 adjustment =
213 ((now - timestamp + interval / 8) % interval + interval) % interval - 214 ((now - timestamp + interval / 8) % interval + interval) % interval -
214 interval / 8; 215 interval / 8;
215 timestamp = now - adjustment; 216 timestamp = now - adjustment;
216 } else { 217 } else {
217 // DWM must be disabled. 218 // DWM must be disabled.
218 timestamp = now; 219 timestamp = now;
219 } 220 }
220 221
221 TRACE_EVENT1("gpu", "GpuVSyncWorker::SendVSyncUpdate", "adjustment", 222 TRACE_EVENT1("gpu", "GpuVSyncWorker::SendVSyncUpdate", "adjustment",
222 adjustment.ToInternalValue()); 223 adjustment.ToInternalValue());
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 void GpuVSyncProviderWin::OnVSync(base::TimeTicks timestamp, 385 void GpuVSyncProviderWin::OnVSync(base::TimeTicks timestamp,
385 base::TimeDelta interval) { 386 base::TimeDelta interval) {
386 DCHECK(vsync_worker_->BelongsToWorkerThread()); 387 DCHECK(vsync_worker_->BelongsToWorkerThread());
387 388
388 message_filter_->Send( 389 message_filter_->Send(
389 base::MakeUnique<GpuCommandBufferMsg_UpdateVSyncParameters>( 390 base::MakeUnique<GpuCommandBufferMsg_UpdateVSyncParameters>(
390 message_filter_->route_id(), timestamp, interval)); 391 message_filter_->route_id(), timestamp, interval));
391 } 392 }
392 393
393 } // namespace gpu 394 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/ipc/service/image_transport_surface_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698