Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / ui / gfx / ozone / dri / dri_vsync_provider.cc
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.
4
5 #include "ui/gfx/ozone/dri/dri_vsync_provider.h"
6
7 #include "base/time/time.h"
8 #include "ui/gfx/ozone/dri/hardware_display_controller.h"
9
10 namespace gfx {
11
12 DriVSyncProvider::DriVSyncProvider(HardwareDisplayController* controller)
13     : controller_(controller) {}
14
15 DriVSyncProvider::~DriVSyncProvider() {}
16
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)
20     return;
21
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;
28
29   callback.Run(timebase, interval);
30 }
31
32 }  // namespace gfx