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