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

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

Issue 1972433002: [Chromecast] Handle device scale factor correctly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test compile error Created 4 years, 7 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // (i.e. allow at least as much time between calls as the call itself takes). 133 // (i.e. allow at least as much time between calls as the call itself takes).
134 std::vector<int64_t> samples_; 134 std::vector<int64_t> samples_;
135 size_t sample_counter_; 135 size_t sample_counter_;
136 136
137 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 137 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
138 138
139 DISALLOW_COPY_AND_ASSIGN(RateLimitedSetVideoPlaneGeometry); 139 DISALLOW_COPY_AND_ASSIGN(RateLimitedSetVideoPlaneGeometry);
140 }; 140 };
141 141
142 VideoPlaneController::VideoPlaneController( 142 VideoPlaneController::VideoPlaneController(
143 const Size& graphics_resolution,
143 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner) 144 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner)
144 : is_paused_(false), 145 : is_paused_(false),
145 have_screen_res_(false), 146 have_screen_res_(false),
146 have_graphics_plane_res_(false),
147 screen_res_(0, 0), 147 screen_res_(0, 0),
148 graphics_plane_res_(0, 0), 148 graphics_plane_res_(graphics_resolution),
149 have_video_plane_geometry_(false), 149 have_video_plane_geometry_(false),
150 video_plane_display_rect_(0, 0), 150 video_plane_display_rect_(0, 0),
151 video_plane_transform_(VideoPlane::TRANSFORM_NONE), 151 video_plane_transform_(VideoPlane::TRANSFORM_NONE),
152 media_task_runner_(media_task_runner), 152 media_task_runner_(media_task_runner),
153 video_plane_wrapper_( 153 video_plane_wrapper_(
154 new RateLimitedSetVideoPlaneGeometry(media_task_runner_)) {} 154 new RateLimitedSetVideoPlaneGeometry(media_task_runner_)) {}
155 155
156 VideoPlaneController::~VideoPlaneController() {} 156 VideoPlaneController::~VideoPlaneController() {}
157 157
158 void VideoPlaneController::SetGeometry(const RectF& display_rect, 158 void VideoPlaneController::SetGeometry(const RectF& display_rect,
(...skipping 29 matching lines...) Expand all
188 188
189 VLOG(1) << "New screen resolution " << resolution.width << "x" 189 VLOG(1) << "New screen resolution " << resolution.width << "x"
190 << resolution.height; 190 << resolution.height;
191 191
192 have_screen_res_ = true; 192 have_screen_res_ = true;
193 screen_res_ = resolution; 193 screen_res_ = resolution;
194 194
195 MaybeRunSetGeometry(); 195 MaybeRunSetGeometry();
196 } 196 }
197 197
198 void VideoPlaneController::SetGraphicsPlaneResolution(const Size& resolution) {
199 DCHECK(thread_checker_.CalledOnValidThread());
200 DCHECK(ResolutionSizeValid(resolution));
201 if (have_graphics_plane_res_ && SizeEqual(resolution, graphics_plane_res_)) {
202 VLOG(2) << "No change found in graphics plane resolution.";
203 return;
204 }
205
206 VLOG(1) << "New graphics plane resolution " << resolution.width << "x"
207 << resolution.height;
208
209 have_graphics_plane_res_ = true;
210 graphics_plane_res_ = resolution;
211
212 // Any cached video plane geometry parameters are no longer valid since they
213 // were relative to the PREVIOUS graphics plane resolution. Thus, the cached
214 // parameters are cleared, and it's the caller's responsibility to call
215 // SetGeometry() with arguments relative to the NEW graphics plane if needed.
216 ClearVideoPlaneGeometry();
217 }
218
219 void VideoPlaneController::Pause() { 198 void VideoPlaneController::Pause() {
220 DCHECK(thread_checker_.CalledOnValidThread()); 199 DCHECK(thread_checker_.CalledOnValidThread());
221 VLOG(1) << "Pausing controller. No more VideoPlane SetGeometry calls."; 200 VLOG(1) << "Pausing controller. No more VideoPlane SetGeometry calls.";
222 is_paused_ = true; 201 is_paused_ = true;
223 } 202 }
224 203
225 void VideoPlaneController::Resume() { 204 void VideoPlaneController::Resume() {
226 DCHECK(thread_checker_.CalledOnValidThread()); 205 DCHECK(thread_checker_.CalledOnValidThread());
227 VLOG(1) << "Resuming controller. VideoPlane SetGeometry calls are active."; 206 VLOG(1) << "Resuming controller. VideoPlane SetGeometry calls are active.";
228 is_paused_ = false; 207 is_paused_ = false;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 scaled_rect.height *= sy; 239 scaled_rect.height *= sy;
261 } 240 }
262 241
263 media_task_runner_->PostTask( 242 media_task_runner_->PostTask(
264 FROM_HERE, 243 FROM_HERE,
265 base::Bind(&RateLimitedSetVideoPlaneGeometry::SetGeometry, 244 base::Bind(&RateLimitedSetVideoPlaneGeometry::SetGeometry,
266 video_plane_wrapper_, scaled_rect, video_plane_transform_)); 245 video_plane_wrapper_, scaled_rect, video_plane_transform_));
267 } 246 }
268 247
269 bool VideoPlaneController::HaveDataForSetGeometry() const { 248 bool VideoPlaneController::HaveDataForSetGeometry() const {
270 return have_screen_res_ && have_graphics_plane_res_ && 249 return have_screen_res_ && have_video_plane_geometry_;
271 have_video_plane_geometry_;
272 } 250 }
273 251
274 void VideoPlaneController::ClearVideoPlaneGeometry() { 252 void VideoPlaneController::ClearVideoPlaneGeometry() {
275 have_video_plane_geometry_ = false; 253 have_video_plane_geometry_ = false;
276 video_plane_display_rect_ = RectF(0, 0); 254 video_plane_display_rect_ = RectF(0, 0);
277 video_plane_transform_ = VideoPlane::TRANSFORM_NONE; 255 video_plane_transform_ = VideoPlane::TRANSFORM_NONE;
278 } 256 }
279 257
280 } // namespace media 258 } // namespace media
281 } // namespace chromecast 259 } // 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