OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "ui/ozone/platform/dri/page_flip_event_handler.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "ui/ozone/platform/dri/hardware_display_controller.h" | |
9 | |
10 namespace ui { | |
11 | |
12 PageFilpEventHandler::PageFilpEventHandler() | |
13 : base::Thread("PageFilpEventHandler"), | |
14 child_message_loop_proxy_(base::MessageLoopProxy::current()), | |
15 polling_(true, true) { | |
brianderson
2014/12/10 22:48:05
This should probably be polling_(true, false).
| |
16 base::Thread::Options options; | |
17 options.message_loop_type = base::MessageLoop::TYPE_IO; | |
18 StartWithOptions(options); | |
19 SetPriority(base::kThreadPriority_Background); | |
20 } | |
21 | |
22 PageFilpEventHandler::~PageFilpEventHandler() { | |
23 } | |
24 | |
25 void PageFilpEventHandler::EnsurePreviousFlipHandled() { | |
26 polling_.Wait(); | |
27 } | |
28 | |
29 void PageFilpEventHandler::GetPageFlipCompleted( | |
30 HardwareDisplayController* controller, | |
31 const ui::SurfaceOzoneEGL::PageFlipCompletionCallback& callback) { | |
32 message_loop_proxy()->PostTask( | |
33 FROM_HERE, base::Bind(&PageFilpEventHandler::CheckPageFlipEvent, this, | |
34 controller, callback)); | |
35 } | |
36 | |
37 void PageFilpEventHandler::CleanUp() { | |
38 SetThreadWasQuitProperly(true); | |
39 } | |
40 | |
41 void PageFilpEventHandler::RunFlipEventCallBack( | |
42 const ui::SurfaceOzoneEGL::PageFlipCompletionCallback& callback) { | |
43 callback.Run(); | |
44 } | |
45 | |
46 void PageFilpEventHandler::CheckPageFlipEvent( | |
47 PageFilpEventHandler* data, | |
48 HardwareDisplayController* controller, | |
49 const ui::SurfaceOzoneEGL::PageFlipCompletionCallback& callback) { | |
50 data->polling_.Reset(); | |
brianderson
2014/12/10 22:48:05
This should be a DCHECK that IsSignaled is false.
| |
51 controller->WaitForPageFlipEvent(); | |
52 data->polling_.Signal(); | |
53 data->child_message_loop_proxy_->PostTask( | |
54 FROM_HERE, | |
55 base::Bind(&PageFilpEventHandler::RunFlipEventCallBack, callback)); | |
56 } | |
57 | |
58 } // namespace ui | |
OLD | NEW |