1 // Copyright 2014 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/ozone/platform/dri/dri_vsync_provider.h"
7 #include "base/time/time.h"
8 #include "ui/ozone/platform/dri/hardware_display_controller.h"
12 DriVSyncProvider::DriVSyncProvider(
13 const base::WeakPtr<HardwareDisplayController>& controller)
14 : controller_(controller) {
17 DriVSyncProvider::~DriVSyncProvider() {}
19 void DriVSyncProvider::GetVSyncParameters(const UpdateVSyncCallback& callback) {
23 // The value is invalid, so we can't update the parameters.
24 if (controller_->get_time_of_last_flip() == 0 ||
25 controller_->get_mode().vrefresh == 0)
28 // Stores the time of the last refresh.
29 base::TimeTicks timebase =
30 base::TimeTicks::FromInternalValue(controller_->get_time_of_last_flip());
31 // Stores the refresh rate.
32 base::TimeDelta interval =
33 base::TimeDelta::FromSeconds(1) / controller_->get_mode().vrefresh;
35 callback.Run(timebase, interval);