| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "media/blink/video_frame_compositor.h" | 5 #include "media/blink/video_frame_compositor.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/time/default_tick_clock.h" | 9 #include "base/time/default_tick_clock.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); | 98 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); |
| 99 return CallRender(deadline_min, deadline_max, false); | 99 return CallRender(deadline_min, deadline_max, false); |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool VideoFrameCompositor::HasCurrentFrame() { | 102 bool VideoFrameCompositor::HasCurrentFrame() { |
| 103 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); | 103 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); |
| 104 return static_cast<bool>(current_frame_); | 104 return static_cast<bool>(current_frame_); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void VideoFrameCompositor::Start(RenderCallback* callback) { | 107 void VideoFrameCompositor::Start(RenderCallback* callback) { |
| 108 TRACE_EVENT0("media", "VideoFrameCompositor::Start"); | 108 TRACE_EVENT0("media,rail", "VideoFrameCompositor::Start"); |
| 109 | 109 |
| 110 // Called from the media thread, so acquire the callback under lock before | 110 // Called from the media thread, so acquire the callback under lock before |
| 111 // returning in case a Stop() call comes in before the PostTask is processed. | 111 // returning in case a Stop() call comes in before the PostTask is processed. |
| 112 base::AutoLock lock(callback_lock_); | 112 base::AutoLock lock(callback_lock_); |
| 113 DCHECK(!callback_); | 113 DCHECK(!callback_); |
| 114 callback_ = callback; | 114 callback_ = callback; |
| 115 compositor_task_runner_->PostTask( | 115 compositor_task_runner_->PostTask( |
| 116 FROM_HERE, base::Bind(&VideoFrameCompositor::OnRendererStateUpdate, | 116 FROM_HERE, base::Bind(&VideoFrameCompositor::OnRendererStateUpdate, |
| 117 base::Unretained(this), true)); | 117 base::Unretained(this), true)); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void VideoFrameCompositor::Stop() { | 120 void VideoFrameCompositor::Stop() { |
| 121 TRACE_EVENT0("media", "VideoFrameCompositor::Stop"); | 121 TRACE_EVENT0("media,rail", "VideoFrameCompositor::Stop"); |
| 122 | 122 |
| 123 // Called from the media thread, so release the callback under lock before | 123 // Called from the media thread, so release the callback under lock before |
| 124 // returning to avoid a pending UpdateCurrentFrame() call occurring before | 124 // returning to avoid a pending UpdateCurrentFrame() call occurring before |
| 125 // the PostTask is processed. | 125 // the PostTask is processed. |
| 126 base::AutoLock lock(callback_lock_); | 126 base::AutoLock lock(callback_lock_); |
| 127 DCHECK(callback_); | 127 DCHECK(callback_); |
| 128 callback_ = nullptr; | 128 callback_ = nullptr; |
| 129 compositor_task_runner_->PostTask( | 129 compositor_task_runner_->PostTask( |
| 130 FROM_HERE, base::Bind(&VideoFrameCompositor::OnRendererStateUpdate, | 130 FROM_HERE, base::Bind(&VideoFrameCompositor::OnRendererStateUpdate, |
| 131 base::Unretained(this), false)); | 131 base::Unretained(this), false)); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 last_interval_ = deadline_max - deadline_min; | 235 last_interval_ = deadline_max - deadline_min; |
| 236 | 236 |
| 237 // Restart the background rendering timer whether we're background rendering | 237 // Restart the background rendering timer whether we're background rendering |
| 238 // or not; in either case we should wait for |kBackgroundRenderingTimeoutMs|. | 238 // or not; in either case we should wait for |kBackgroundRenderingTimeoutMs|. |
| 239 if (background_rendering_enabled_) | 239 if (background_rendering_enabled_) |
| 240 background_rendering_timer_.Reset(); | 240 background_rendering_timer_.Reset(); |
| 241 return new_frame || had_new_background_frame; | 241 return new_frame || had_new_background_frame; |
| 242 } | 242 } |
| 243 | 243 |
| 244 } // namespace media | 244 } // namespace media |
| OLD | NEW |