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

Side by Side Diff: chromecast/media/base/video_plane_controller.cc

Issue 1531543002: [Chromecast] Adding pause/resume operations to VideoPlaneController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase of Patch Set 8. Created 4 years, 11 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
« no previous file with comments | « chromecast/media/base/video_plane_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chromecast/media/base/video_plane_controller.h" 5 #include "chromecast/media/base/video_plane_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 199
200 VLOG(1) << "New graphics resolution " << resolution.width << "x" 200 VLOG(1) << "New graphics resolution " << resolution.width << "x"
201 << resolution.height; 201 << resolution.height;
202 202
203 have_graphics_res_ = true; 203 have_graphics_res_ = true;
204 graphics_res_ = resolution; 204 graphics_res_ = resolution;
205 205
206 MaybeRunSetGeometry(); 206 MaybeRunSetGeometry();
207 } 207 }
208 208
209 void VideoPlaneController::Pause() {
210 DCHECK(thread_checker_.CalledOnValidThread());
211 VLOG(1) << "Pausing controller. No more VideoPlane SetGeometry calls.";
212 is_paused_ = true;
213 }
214
215 void VideoPlaneController::Resume() {
216 DCHECK(thread_checker_.CalledOnValidThread());
217 VLOG(1) << "Resuming controller. VideoPlane SetGeometry calls are active.";
218 is_paused_ = false;
219 MaybeRunSetGeometry();
220 }
221
222 bool VideoPlaneController::is_paused() const {
223 DCHECK(thread_checker_.CalledOnValidThread());
224 return is_paused_;
225 }
226
209 VideoPlaneController::VideoPlaneController() 227 VideoPlaneController::VideoPlaneController()
210 : have_output_res_(false), 228 : is_paused_(false),
229 have_output_res_(false),
211 have_graphics_res_(false), 230 have_graphics_res_(false),
212 output_res_(0, 0), 231 output_res_(0, 0),
213 graphics_res_(0, 0), 232 graphics_res_(0, 0),
214 have_video_plane_geometry_(false), 233 have_video_plane_geometry_(false),
215 video_plane_display_rect_(0, 0), 234 video_plane_display_rect_(0, 0),
216 video_plane_transform_(VideoPlane::TRANSFORM_NONE), 235 video_plane_transform_(VideoPlane::TRANSFORM_NONE),
217 media_task_runner_(MediaMessageLoop::GetTaskRunner()), 236 media_task_runner_(MediaMessageLoop::GetTaskRunner()),
218 video_plane_wrapper_( 237 video_plane_wrapper_(
219 new RateLimitedSetVideoPlaneGeometry(media_task_runner_)) {} 238 new RateLimitedSetVideoPlaneGeometry(media_task_runner_)) {}
220 239
221 VideoPlaneController::~VideoPlaneController() {} 240 VideoPlaneController::~VideoPlaneController() {}
222 241
223 void VideoPlaneController::MaybeRunSetGeometry() { 242 void VideoPlaneController::MaybeRunSetGeometry() {
224 DCHECK(thread_checker_.CalledOnValidThread()); 243 DCHECK(thread_checker_.CalledOnValidThread());
225 if (!HaveDataForSetGeometry()) 244 if (is_paused_) {
245 VLOG(2) << "All VideoPlane SetGeometry calls are paused. Ignoring request.";
226 return; 246 return;
247 }
248
249 if (!HaveDataForSetGeometry()) {
250 VLOG(2) << "Don't have all VideoPlane SetGeometry data. Ignoring request.";
251 return;
252 }
227 253
228 DCHECK(graphics_res_.width != 0 && graphics_res_.height != 0); 254 DCHECK(graphics_res_.width != 0 && graphics_res_.height != 0);
229 255
230 RectF scaled_rect = video_plane_display_rect_; 256 RectF scaled_rect = video_plane_display_rect_;
231 if (graphics_res_.width != output_res_.width || 257 if (graphics_res_.width != output_res_.width ||
232 graphics_res_.height != output_res_.height) { 258 graphics_res_.height != output_res_.height) {
233 float sx = static_cast<float>(output_res_.width) / graphics_res_.width; 259 float sx = static_cast<float>(output_res_.width) / graphics_res_.width;
234 float sy = static_cast<float>(output_res_.height) / graphics_res_.height; 260 float sy = static_cast<float>(output_res_.height) / graphics_res_.height;
235 scaled_rect.x *= sx; 261 scaled_rect.x *= sx;
236 scaled_rect.y *= sy; 262 scaled_rect.y *= sy;
237 scaled_rect.width *= sx; 263 scaled_rect.width *= sx;
238 scaled_rect.height *= sy; 264 scaled_rect.height *= sy;
239 } 265 }
240 266
241 media_task_runner_->PostTask( 267 media_task_runner_->PostTask(
242 FROM_HERE, 268 FROM_HERE,
243 base::Bind(&RateLimitedSetVideoPlaneGeometry::SetGeometry, 269 base::Bind(&RateLimitedSetVideoPlaneGeometry::SetGeometry,
244 video_plane_wrapper_, scaled_rect, video_plane_transform_)); 270 video_plane_wrapper_, scaled_rect, video_plane_transform_));
245 } 271 }
246 272
247 bool VideoPlaneController::HaveDataForSetGeometry() const { 273 bool VideoPlaneController::HaveDataForSetGeometry() const {
248 DCHECK(thread_checker_.CalledOnValidThread()); 274 DCHECK(thread_checker_.CalledOnValidThread());
249 return have_output_res_ && have_graphics_res_ && have_video_plane_geometry_; 275 return have_output_res_ && have_graphics_res_ && have_video_plane_geometry_;
250 } 276 }
251 277
252 } // namespace media 278 } // namespace media
253 } // namespace chromecast 279 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/media/base/video_plane_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698