Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/public/browser/android/synchronous_compositor.h" | 5 #include "content/public/browser/android/synchronous_compositor.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 | 12 |
| 13 SynchronousCompositor::Frame::Frame() : output_surface_id(0u) {} | 13 SynchronousCompositor::Frame::Frame() : output_surface_id(0u) {} |
| 14 | 14 |
| 15 SynchronousCompositor::Frame::~Frame() {} | 15 SynchronousCompositor::Frame::~Frame() {} |
| 16 | 16 |
| 17 SynchronousCompositor::Frame::Frame(Frame&& rhs) | 17 SynchronousCompositor::Frame::Frame(Frame&& rhs) |
| 18 : output_surface_id(rhs.output_surface_id), frame(std::move(rhs.frame)) {} | 18 : output_surface_id(rhs.output_surface_id), frame(std::move(rhs.frame)) {} |
| 19 | 19 |
| 20 SynchronousCompositor::FrameFuture::FrameFuture() | |
| 21 : waitable_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, | |
|
boliu
2016/09/16 16:26:12
should be manual
ojars
2016/09/19 22:02:37
Done.
| |
| 22 base::WaitableEvent::InitialState::NOT_SIGNALED) {} | |
| 23 | |
| 24 SynchronousCompositor::FrameFuture::~FrameFuture() {} | |
| 25 | |
| 26 void SynchronousCompositor::FrameFuture::setFrame( | |
| 27 std::unique_ptr<content::SynchronousCompositor::Frame> frame) { | |
| 28 frame_ = std::move(frame); | |
| 29 waitable_event_.Signal(); | |
| 30 } | |
| 31 | |
| 32 content::SynchronousCompositor::Frame* | |
| 33 SynchronousCompositor::FrameFuture::getFrame() { | |
| 34 waitable_event_.Wait(); | |
|
boliu
2016/09/16 16:26:12
All the waitable_event calls are super expensive.
| |
| 35 return frame_.get(); | |
| 36 } | |
| 37 | |
| 38 bool SynchronousCompositor::FrameFuture::hasFrame() { | |
| 39 return waitable_event_.IsSignaled(); | |
| 40 } | |
| 41 | |
| 20 SynchronousCompositor::Frame& SynchronousCompositor::Frame::operator=( | 42 SynchronousCompositor::Frame& SynchronousCompositor::Frame::operator=( |
| 21 Frame&& rhs) { | 43 Frame&& rhs) { |
| 22 output_surface_id = rhs.output_surface_id; | 44 output_surface_id = rhs.output_surface_id; |
| 23 frame = std::move(rhs.frame); | 45 frame = std::move(rhs.frame); |
| 24 return *this; | 46 return *this; |
| 25 } | 47 } |
| 26 | 48 |
| 27 } // namespace content | 49 } // namespace content |
| OLD | NEW |