1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/gfx/ozone/dri/dri_vsync_provider.h"
7 #include "base/time/time.h"
8 #include "ui/gfx/ozone/dri/hardware_display_controller.h"
12 DriVSyncProvider::DriVSyncProvider(HardwareDisplayController* controller)
13 : controller_(controller) {}
15 DriVSyncProvider::~DriVSyncProvider() {}
17 void DriVSyncProvider::GetVSyncParameters(const UpdateVSyncCallback& callback) {
18 // The value is invalid, so we can't update the parameters.
19 if (controller_->get_time_of_last_flip() == 0)
22 // Stores the time of the last refresh.
23 base::TimeTicks timebase =
24 base::TimeTicks::FromInternalValue(controller_->get_time_of_last_flip());
25 // Stores the refresh rate.
26 base::TimeDelta interval =
27 base::TimeDelta::FromSeconds(1) / controller_->get_mode().vrefresh;
29 callback.Run(timebase, interval);