1 // Copyright 2013 Intel Corporation. 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 "ozone/ui/gfx/vsync_provider_wayland.h"
8 #include "base/message_loop/message_loop.h"
9 #include "ozone/ui/gfx/ozone_display.h"
13 WaylandSyncProvider::WaylandSyncProvider(unsigned handle) : handle_(handle) {
16 WaylandSyncProvider::~WaylandSyncProvider() {
17 // WaylandSyncProvider is destroyed when the associated NativeSurface is
18 // destroyed. Inform OzoneDisplay to release Wayland resources.
19 OzoneDisplay::GetInstance()->DestroyWidget(handle_);
20 OzoneDisplay::GetInstance()->FlushDisplay();
23 void WaylandSyncProvider::GetVSyncParameters(
24 const UpdateVSyncCallback& callback) {
25 // PassThroughImageTransportSurface calls this before swapping the surface.
26 // Post a task to flush display as it should be handled immediately after
27 // swap buffers is done.
28 base::MessageLoop::current()->message_loop_proxy()->PostTask(
29 FROM_HERE, base::Bind(&WaylandSyncProvider::ScheduleFlush));
31 // TODO(kalyan): Pass refresh rate and time of the last refresh.
34 void WaylandSyncProvider::ScheduleFlush() {
35 OzoneDisplay* native_display = OzoneDisplay::GetInstance();
37 native_display->FlushDisplay();