Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: media/blink/video_frame_compositor.cc

Issue 1873513003: Add video-rendering to mojo media pipeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "media/base/video_frame.h" 11 #include "media/base/video_frame.h"
12 12
13 namespace media { 13 namespace media {
14 14
15 // Amount of time to wait between UpdateCurrentFrame() callbacks before starting 15 // Amount of time to wait between UpdateCurrentFrame() callbacks before starting
16 // background rendering to keep the Render() callbacks moving. 16 // background rendering to keep the Render() callbacks moving.
17 const int kBackgroundRenderingTimeoutMs = 250; 17 const int kBackgroundRenderingTimeoutMs = 250;
18 18
19 VideoFrameCompositor::VideoFrameCompositor( 19 VideoFrameCompositor::VideoFrameCompositor(
20 const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner, 20 const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner,
21 const base::Callback<void(gfx::Size)>& natural_size_changed_cb,
22 const base::Callback<void(bool)>& opacity_changed_cb) 21 const base::Callback<void(bool)>& opacity_changed_cb)
23 : compositor_task_runner_(compositor_task_runner), 22 : compositor_task_runner_(compositor_task_runner),
24 tick_clock_(new base::DefaultTickClock()), 23 tick_clock_(new base::DefaultTickClock()),
25 natural_size_changed_cb_(natural_size_changed_cb),
26 opacity_changed_cb_(opacity_changed_cb), 24 opacity_changed_cb_(opacity_changed_cb),
27 background_rendering_enabled_(true), 25 background_rendering_enabled_(true),
28 background_rendering_timer_( 26 background_rendering_timer_(
29 FROM_HERE, 27 FROM_HERE,
30 base::TimeDelta::FromMilliseconds(kBackgroundRenderingTimeoutMs), 28 base::TimeDelta::FromMilliseconds(kBackgroundRenderingTimeoutMs),
31 base::Bind(&VideoFrameCompositor::BackgroundRender, 29 base::Bind(&VideoFrameCompositor::BackgroundRender,
32 base::Unretained(this)), 30 base::Unretained(this)),
33 // Task is not repeating, CallRender() will reset the task as needed. 31 // Task is not repeating, CallRender() will reset the task as needed.
34 false), 32 false),
35 client_(nullptr), 33 client_(nullptr),
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 const scoped_refptr<VideoFrame>& frame) { 184 const scoped_refptr<VideoFrame>& frame) {
187 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); 185 DCHECK(compositor_task_runner_->BelongsToCurrentThread());
188 186
189 if (frame == current_frame_) 187 if (frame == current_frame_)
190 return false; 188 return false;
191 189
192 // Set the flag indicating that the current frame is unrendered, if we get a 190 // Set the flag indicating that the current frame is unrendered, if we get a
193 // subsequent PutCurrentFrame() call it will mark it as rendered. 191 // subsequent PutCurrentFrame() call it will mark it as rendered.
194 rendered_last_frame_ = false; 192 rendered_last_frame_ = false;
195 193
196 if (current_frame_ &&
197 current_frame_->natural_size() != frame->natural_size()) {
198 natural_size_changed_cb_.Run(frame->natural_size());
199 }
200
201 if (!current_frame_ || 194 if (!current_frame_ ||
202 IsOpaque(current_frame_->format()) != IsOpaque(frame->format())) 195 IsOpaque(current_frame_->format()) != IsOpaque(frame->format()))
203 opacity_changed_cb_.Run(IsOpaque(frame->format())); 196 opacity_changed_cb_.Run(IsOpaque(frame->format()));
204 197
205 current_frame_ = frame; 198 current_frame_ = frame;
206 return true; 199 return true;
207 } 200 }
208 201
209 void VideoFrameCompositor::BackgroundRender() { 202 void VideoFrameCompositor::BackgroundRender() {
210 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); 203 DCHECK(compositor_task_runner_->BelongsToCurrentThread());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 last_interval_ = deadline_max - deadline_min; 242 last_interval_ = deadline_max - deadline_min;
250 243
251 // Restart the background rendering timer whether we're background rendering 244 // Restart the background rendering timer whether we're background rendering
252 // or not; in either case we should wait for |kBackgroundRenderingTimeoutMs|. 245 // or not; in either case we should wait for |kBackgroundRenderingTimeoutMs|.
253 if (background_rendering_enabled_) 246 if (background_rendering_enabled_)
254 background_rendering_timer_.Reset(); 247 background_rendering_timer_.Reset();
255 return new_frame || had_new_background_frame; 248 return new_frame || had_new_background_frame;
256 } 249 }
257 250
258 } // namespace media 251 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698