| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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)); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void VideoFrameCompositor::PaintFrameUsingOldRenderingPath( | 134 void VideoFrameCompositor::PaintSingleFrame( |
| 135 const scoped_refptr<VideoFrame>& frame) { | 135 const scoped_refptr<VideoFrame>& frame) { |
| 136 if (!compositor_task_runner_->BelongsToCurrentThread()) { | 136 if (!compositor_task_runner_->BelongsToCurrentThread()) { |
| 137 compositor_task_runner_->PostTask( | 137 compositor_task_runner_->PostTask( |
| 138 FROM_HERE, | 138 FROM_HERE, base::Bind(&VideoFrameCompositor::PaintSingleFrame, |
| 139 base::Bind(&VideoFrameCompositor::PaintFrameUsingOldRenderingPath, | 139 base::Unretained(this), frame)); |
| 140 base::Unretained(this), frame)); | |
| 141 return; | 140 return; |
| 142 } | 141 } |
| 143 | 142 |
| 144 if (ProcessNewFrame(frame) && client_) | 143 if (ProcessNewFrame(frame) && client_) |
| 145 client_->DidReceiveFrame(); | 144 client_->DidReceiveFrame(); |
| 146 } | 145 } |
| 147 | 146 |
| 148 scoped_refptr<VideoFrame> | 147 scoped_refptr<VideoFrame> |
| 149 VideoFrameCompositor::GetCurrentFrameAndUpdateIfStale() { | 148 VideoFrameCompositor::GetCurrentFrameAndUpdateIfStale() { |
| 150 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); | 149 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 165 last_interval_ = interval; | 164 last_interval_ = interval; |
| 166 BackgroundRender(); | 165 BackgroundRender(); |
| 167 | 166 |
| 168 return current_frame_; | 167 return current_frame_; |
| 169 } | 168 } |
| 170 | 169 |
| 171 base::TimeDelta VideoFrameCompositor::GetCurrentFrameTimestamp() const { | 170 base::TimeDelta VideoFrameCompositor::GetCurrentFrameTimestamp() const { |
| 172 // When the VFC is stopped, |callback_| is cleared; this synchronously | 171 // When the VFC is stopped, |callback_| is cleared; this synchronously |
| 173 // prevents CallRender() from invoking ProcessNewFrame(), and so | 172 // prevents CallRender() from invoking ProcessNewFrame(), and so |
| 174 // |current_frame_| won't change again until after Start(). (Assuming that | 173 // |current_frame_| won't change again until after Start(). (Assuming that |
| 175 // PaintFrameUsingOldRenderingPath() is not also called while stopped.) | 174 // PaintSingleFrame() is not also called while stopped.) |
| 176 if (!current_frame_) | 175 if (!current_frame_) |
| 177 return base::TimeDelta(); | 176 return base::TimeDelta(); |
| 178 return current_frame_->timestamp(); | 177 return current_frame_->timestamp(); |
| 179 } | 178 } |
| 180 | 179 |
| 181 bool VideoFrameCompositor::ProcessNewFrame( | 180 bool VideoFrameCompositor::ProcessNewFrame( |
| 182 const scoped_refptr<VideoFrame>& frame) { | 181 const scoped_refptr<VideoFrame>& frame) { |
| 183 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); | 182 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); |
| 184 | 183 |
| 185 if (frame == current_frame_) | 184 if (frame == current_frame_) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 last_interval_ = deadline_max - deadline_min; | 235 last_interval_ = deadline_max - deadline_min; |
| 237 | 236 |
| 238 // Restart the background rendering timer whether we're background rendering | 237 // Restart the background rendering timer whether we're background rendering |
| 239 // or not; in either case we should wait for |kBackgroundRenderingTimeoutMs|. | 238 // or not; in either case we should wait for |kBackgroundRenderingTimeoutMs|. |
| 240 if (background_rendering_enabled_) | 239 if (background_rendering_enabled_) |
| 241 background_rendering_timer_.Reset(); | 240 background_rendering_timer_.Reset(); |
| 242 return new_frame || had_new_background_frame; | 241 return new_frame || had_new_background_frame; |
| 243 } | 242 } |
| 244 | 243 |
| 245 } // namespace media | 244 } // namespace media |
| OLD | NEW |