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

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: Just modified a comment back the way it was. Created 5 years 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 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 <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 195
196 VLOG(1) << "New graphics resolution " << resolution.width << "x" 196 VLOG(1) << "New graphics resolution " << resolution.width << "x"
197 << resolution.height; 197 << resolution.height;
198 198
199 have_graphics_res_ = true; 199 have_graphics_res_ = true;
200 graphics_res_ = resolution; 200 graphics_res_ = resolution;
201 201
202 MaybeRunSetGeometry(); 202 MaybeRunSetGeometry();
203 } 203 }
204 204
205 void VideoPlaneController::Pause() {
206 DCHECK(thread_checker_.CalledOnValidThread());
207 VLOG(1) << "Pausing controller. No more VideoPlane SetGeometry calls.";
208 is_paused_ = true;
209 }
210
211 void VideoPlaneController::Resume() {
212 DCHECK(thread_checker_.CalledOnValidThread());
213 VLOG(1) << "Resuming controller. VideoPlane SetGeometry calls are active.";
214 is_paused_ = false;
215 }
216
217 bool VideoPlaneController::is_paused() const {
218 DCHECK(thread_checker_.CalledOnValidThread());
219 return is_paused_;
220 }
221
222 void VideoPlaneController::ClearGeometryState() {
223 DCHECK(thread_checker_.CalledOnValidThread());
224 have_video_plane_geometry_ = false;
225 video_plane_display_rect_ = RectF(0, 0, 0, 0);
226 video_plane_transform_ = VideoPlane::TRANSFORM_NONE;
227 }
halliwell 2015/12/17 14:46:31 So ... it looks like from the internal CL that whe
esum 2015/12/21 00:39:21 Done.
228
205 VideoPlaneController::VideoPlaneController() 229 VideoPlaneController::VideoPlaneController()
206 : have_output_res_(false), 230 : is_paused_(false),
231 have_output_res_(false),
207 have_graphics_res_(false), 232 have_graphics_res_(false),
208 output_res_(0, 0), 233 output_res_(0, 0),
209 graphics_res_(0, 0), 234 graphics_res_(0, 0),
210 have_video_plane_geometry_(false), 235 have_video_plane_geometry_(false),
211 video_plane_display_rect_(0, 0), 236 video_plane_display_rect_(0, 0),
212 video_plane_transform_(VideoPlane::TRANSFORM_NONE), 237 video_plane_transform_(VideoPlane::TRANSFORM_NONE),
213 media_task_runner_(MediaMessageLoop::GetTaskRunner()), 238 media_task_runner_(MediaMessageLoop::GetTaskRunner()),
214 video_plane_wrapper_( 239 video_plane_wrapper_(
215 new RateLimitedSetVideoPlaneGeometry(media_task_runner_)) {} 240 new RateLimitedSetVideoPlaneGeometry(media_task_runner_)) {}
216 241
217 VideoPlaneController::~VideoPlaneController() {} 242 VideoPlaneController::~VideoPlaneController() {}
218 243
219 void VideoPlaneController::MaybeRunSetGeometry() { 244 void VideoPlaneController::MaybeRunSetGeometry() {
220 DCHECK(thread_checker_.CalledOnValidThread()); 245 DCHECK(thread_checker_.CalledOnValidThread());
221 if (!HaveDataForSetGeometry()) 246 if (is_paused_) {
247 VLOG(2) << "All VideoPlane SetGeometry calls are paused. Ignoring request.";
222 return; 248 return;
249 }
250
251 if (!HaveDataForSetGeometry()) {
252 VLOG(2) << "Don't have all VideoPlane SetGeometry data. Ignoring request.";
253 return;
254 }
223 255
224 DCHECK(graphics_res_.width != 0 && graphics_res_.height != 0); 256 DCHECK(graphics_res_.width != 0 && graphics_res_.height != 0);
225 257
226 RectF scaled_rect = video_plane_display_rect_; 258 RectF scaled_rect = video_plane_display_rect_;
227 if (graphics_res_.width != output_res_.width || 259 if (graphics_res_.width != output_res_.width ||
228 graphics_res_.height != output_res_.height) { 260 graphics_res_.height != output_res_.height) {
229 float sx = static_cast<float>(output_res_.width) / graphics_res_.width; 261 float sx = static_cast<float>(output_res_.width) / graphics_res_.width;
230 float sy = static_cast<float>(output_res_.height) / graphics_res_.height; 262 float sy = static_cast<float>(output_res_.height) / graphics_res_.height;
231 scaled_rect.x *= sx; 263 scaled_rect.x *= sx;
232 scaled_rect.y *= sy; 264 scaled_rect.y *= sy;
233 scaled_rect.width *= sx; 265 scaled_rect.width *= sx;
234 scaled_rect.height *= sy; 266 scaled_rect.height *= sy;
235 } 267 }
236 268
237 media_task_runner_->PostTask( 269 media_task_runner_->PostTask(
238 FROM_HERE, 270 FROM_HERE,
239 base::Bind(&RateLimitedSetVideoPlaneGeometry::SetGeometry, 271 base::Bind(&RateLimitedSetVideoPlaneGeometry::SetGeometry,
240 video_plane_wrapper_, scaled_rect, video_plane_transform_)); 272 video_plane_wrapper_, scaled_rect, video_plane_transform_));
241 } 273 }
242 274
243 bool VideoPlaneController::HaveDataForSetGeometry() const { 275 bool VideoPlaneController::HaveDataForSetGeometry() const {
244 DCHECK(thread_checker_.CalledOnValidThread()); 276 DCHECK(thread_checker_.CalledOnValidThread());
245 return have_output_res_ && have_graphics_res_ && have_video_plane_geometry_; 277 return have_output_res_ && have_graphics_res_ && have_video_plane_geometry_;
246 } 278 }
247 279
248 } // namespace media 280 } // namespace media
249 } // namespace chromecast 281 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698