OLD | NEW |
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 "content/renderer/media/webmediaplayer_ms_compositor.h" | 5 #include "content/renderer/media/webmediaplayer_ms_compositor.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 const auto& begin = timestamps_to_clock_times_.begin(); | 388 const auto& begin = timestamps_to_clock_times_.begin(); |
389 auto iterator = begin; | 389 auto iterator = begin; |
390 while (iterator != end && iterator->first < frame->timestamp()) | 390 while (iterator != end && iterator->first < frame->timestamp()) |
391 ++iterator; | 391 ++iterator; |
392 timestamps_to_clock_times_.erase(begin, iterator); | 392 timestamps_to_clock_times_.erase(begin, iterator); |
393 } | 393 } |
394 | 394 |
395 void WebMediaPlayerMSCompositor::SetCurrentFrame( | 395 void WebMediaPlayerMSCompositor::SetCurrentFrame( |
396 const scoped_refptr<media::VideoFrame>& frame) { | 396 const scoped_refptr<media::VideoFrame>& frame) { |
397 current_frame_lock_.AssertAcquired(); | 397 current_frame_lock_.AssertAcquired(); |
| 398 |
398 if (!current_frame_used_by_compositor_) | 399 if (!current_frame_used_by_compositor_) |
399 ++dropped_frame_count_; | 400 ++dropped_frame_count_; |
400 current_frame_used_by_compositor_ = false; | 401 current_frame_used_by_compositor_ = false; |
| 402 |
| 403 const bool size_changed = |
| 404 !current_frame_ || |
| 405 current_frame_->natural_size() != frame->natural_size(); |
401 current_frame_ = frame; | 406 current_frame_ = frame; |
| 407 if (size_changed) { |
| 408 main_message_loop_->PostTask( |
| 409 FROM_HERE, base::Bind(&WebMediaPlayerMS::TriggerResize, player_)); |
| 410 } |
402 main_message_loop_->PostTask( | 411 main_message_loop_->PostTask( |
403 FROM_HERE, base::Bind(&WebMediaPlayerMS::ResetCanvasCache, player_)); | 412 FROM_HERE, base::Bind(&WebMediaPlayerMS::ResetCanvasCache, player_)); |
404 } | 413 } |
405 | 414 |
406 void WebMediaPlayerMSCompositor::SetAlgorithmEnabledForTesting( | 415 void WebMediaPlayerMSCompositor::SetAlgorithmEnabledForTesting( |
407 bool algorithm_enabled) { | 416 bool algorithm_enabled) { |
408 if (!algorithm_enabled) { | 417 if (!algorithm_enabled) { |
409 rendering_frame_buffer_.reset(); | 418 rendering_frame_buffer_.reset(); |
410 return; | 419 return; |
411 } | 420 } |
412 | 421 |
413 if (!rendering_frame_buffer_) { | 422 if (!rendering_frame_buffer_) { |
414 rendering_frame_buffer_.reset(new media::VideoRendererAlgorithm( | 423 rendering_frame_buffer_.reset(new media::VideoRendererAlgorithm( |
415 base::Bind(&WebMediaPlayerMSCompositor::MapTimestampsToRenderTimeTicks, | 424 base::Bind(&WebMediaPlayerMSCompositor::MapTimestampsToRenderTimeTicks, |
416 base::Unretained(this)))); | 425 base::Unretained(this)))); |
417 } | 426 } |
418 } | 427 } |
419 | 428 |
420 } // namespace content | 429 } // namespace content |
OLD | NEW |