Chromium Code Reviews| Index: ui/ozone/platform/dri/page_flip_event_handler.cc |
| diff --git a/ui/ozone/platform/dri/page_flip_event_handler.cc b/ui/ozone/platform/dri/page_flip_event_handler.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d5a48a2b9eab5ed5b53b7a3b788ae5f2027bf8aa |
| --- /dev/null |
| +++ b/ui/ozone/platform/dri/page_flip_event_handler.cc |
| @@ -0,0 +1,58 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/ozone/platform/dri/page_flip_event_handler.h" |
| + |
| +#include "base/bind.h" |
| +#include "ui/ozone/platform/dri/hardware_display_controller.h" |
| + |
| +namespace ui { |
| + |
| +PageFilpEventHandler::PageFilpEventHandler() |
| + : base::Thread("PageFilpEventHandler"), |
| + child_message_loop_proxy_(base::MessageLoopProxy::current()), |
| + polling_(true, true) { |
|
brianderson
2014/12/10 22:48:05
This should probably be polling_(true, false).
|
| + base::Thread::Options options; |
| + options.message_loop_type = base::MessageLoop::TYPE_IO; |
| + StartWithOptions(options); |
| + SetPriority(base::kThreadPriority_Background); |
| +} |
| + |
| +PageFilpEventHandler::~PageFilpEventHandler() { |
| +} |
| + |
| +void PageFilpEventHandler::EnsurePreviousFlipHandled() { |
| + polling_.Wait(); |
| +} |
| + |
| +void PageFilpEventHandler::GetPageFlipCompleted( |
| + HardwareDisplayController* controller, |
| + const ui::SurfaceOzoneEGL::PageFlipCompletionCallback& callback) { |
| + message_loop_proxy()->PostTask( |
| + FROM_HERE, base::Bind(&PageFilpEventHandler::CheckPageFlipEvent, this, |
| + controller, callback)); |
| +} |
| + |
| +void PageFilpEventHandler::CleanUp() { |
| + SetThreadWasQuitProperly(true); |
| +} |
| + |
| +void PageFilpEventHandler::RunFlipEventCallBack( |
| + const ui::SurfaceOzoneEGL::PageFlipCompletionCallback& callback) { |
| + callback.Run(); |
| +} |
| + |
| +void PageFilpEventHandler::CheckPageFlipEvent( |
| + PageFilpEventHandler* data, |
| + HardwareDisplayController* controller, |
| + const ui::SurfaceOzoneEGL::PageFlipCompletionCallback& callback) { |
| + data->polling_.Reset(); |
|
brianderson
2014/12/10 22:48:05
This should be a DCHECK that IsSignaled is false.
|
| + controller->WaitForPageFlipEvent(); |
| + data->polling_.Signal(); |
| + data->child_message_loop_proxy_->PostTask( |
| + FROM_HERE, |
| + base::Bind(&PageFilpEventHandler::RunFlipEventCallBack, callback)); |
| +} |
| + |
| +} // namespace ui |