| 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() : compositor_frame_sink_id(0u) {} | 13 SynchronousCompositor::Frame::Frame() : compositor_frame_sink_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 : compositor_frame_sink_id(rhs.compositor_frame_sink_id), | 18 : compositor_frame_sink_id(rhs.compositor_frame_sink_id), |
| 19 frame(std::move(rhs.frame)) {} | 19 frame(std::move(rhs.frame)) {} |
| 20 | 20 |
| 21 SynchronousCompositor::FrameFuture::FrameFuture() | 21 SynchronousCompositor::FrameFuture::FrameFuture() |
| 22 : waitable_event_(base::WaitableEvent::ResetPolicy::MANUAL, | 22 : waitable_event_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 23 base::WaitableEvent::InitialState::NOT_SIGNALED) {} | 23 base::WaitableEvent::InitialState::NOT_SIGNALED) {} |
| 24 | 24 |
| 25 SynchronousCompositor::FrameFuture::~FrameFuture() {} | 25 SynchronousCompositor::FrameFuture::~FrameFuture() {} |
| 26 | 26 |
| 27 void SynchronousCompositor::FrameFuture::setFrame( | 27 void SynchronousCompositor::FrameFuture::SetFrame( |
| 28 std::unique_ptr<Frame> frame) { | 28 std::unique_ptr<Frame> frame) { |
| 29 frame_ = std::move(frame); | 29 frame_ = std::move(frame); |
| 30 waitable_event_.Signal(); | 30 waitable_event_.Signal(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 std::unique_ptr<SynchronousCompositor::Frame> | 33 std::unique_ptr<SynchronousCompositor::Frame> |
| 34 SynchronousCompositor::FrameFuture::getFrame() { | 34 SynchronousCompositor::FrameFuture::GetFrame() { |
| 35 #if DCHECK_IS_ON() | 35 #if DCHECK_IS_ON() |
| 36 DCHECK(!waited_); | 36 DCHECK(!waited_); |
| 37 waited_ = true; | 37 waited_ = true; |
| 38 #endif | 38 #endif |
| 39 waitable_event_.Wait(); | 39 waitable_event_.Wait(); |
| 40 return std::move(frame_); | 40 return std::move(frame_); |
| 41 } | 41 } |
| 42 | 42 |
| 43 SynchronousCompositor::Frame& SynchronousCompositor::Frame::operator=( | 43 SynchronousCompositor::Frame& SynchronousCompositor::Frame::operator=( |
| 44 Frame&& rhs) { | 44 Frame&& rhs) { |
| 45 compositor_frame_sink_id = rhs.compositor_frame_sink_id; | 45 compositor_frame_sink_id = rhs.compositor_frame_sink_id; |
| 46 frame = std::move(rhs.frame); | 46 frame = std::move(rhs.frame); |
| 47 return *this; | 47 return *this; |
| 48 } | 48 } |
| 49 | 49 |
| 50 } // namespace content | 50 } // namespace content |
| OLD | NEW |