| 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 "base/command_line.h" | 7 #include "base/command_line.h" | 
| 8 #include "base/hash.h" | 8 #include "base/hash.h" | 
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" | 
| 10 #include "cc/blink/context_provider_web_context.h" | 10 #include "cc/blink/context_provider_web_context.h" | 
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 99     rendering_frame_buffer_.reset(new media::VideoRendererAlgorithm( | 99     rendering_frame_buffer_.reset(new media::VideoRendererAlgorithm( | 
| 100         base::Bind(&WebMediaPlayerMSCompositor::MapTimestampsToRenderTimeTicks, | 100         base::Bind(&WebMediaPlayerMSCompositor::MapTimestampsToRenderTimeTicks, | 
| 101                    base::Unretained(this)))); | 101                    base::Unretained(this)))); | 
| 102   } | 102   } | 
| 103 | 103 | 
| 104   // Just for logging purpose. | 104   // Just for logging purpose. | 
| 105   const uint32 hash_value = base::Hash(url.string().utf8()); | 105   const uint32 hash_value = base::Hash(url.string().utf8()); | 
| 106   serial_ = (hash_value << 1) | (remote_video ? 1 : 0); | 106   serial_ = (hash_value << 1) | (remote_video ? 1 : 0); | 
| 107 } | 107 } | 
| 108 | 108 | 
|  | 109 WebMediaPlayerMSCompositor::WebMediaPlayerMSCompositor( | 
|  | 110     const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner, | 
|  | 111     const bool algorithm_enabled) | 
|  | 112     : compositor_task_runner_(compositor_task_runner), | 
|  | 113       video_frame_provider_client_(nullptr), | 
|  | 114       current_frame_used_by_compositor_(false), | 
|  | 115       last_render_length_(base::TimeDelta::FromSecondsD(1.0 / 60.0)), | 
|  | 116       total_frame_count_(0), | 
|  | 117       dropped_frame_count_(0), | 
|  | 118       stopped_(true) { | 
|  | 119   if (algorithm_enabled) { | 
|  | 120     base::AutoLock auto_lock(current_frame_lock_); | 
|  | 121     rendering_frame_buffer_.reset(new media::VideoRendererAlgorithm( | 
|  | 122         base::Bind(&WebMediaPlayerMSCompositor::MapTimestampsToRenderTimeTicks, | 
|  | 123                    base::Unretained(this)))); | 
|  | 124   } | 
|  | 125 | 
|  | 126   serial_ = algorithm_enabled ? 1 : 0; | 
|  | 127 } | 
|  | 128 | 
| 109 WebMediaPlayerMSCompositor::~WebMediaPlayerMSCompositor() { | 129 WebMediaPlayerMSCompositor::~WebMediaPlayerMSCompositor() { | 
| 110   DCHECK(compositor_task_runner_->BelongsToCurrentThread()); | 130   DCHECK(compositor_task_runner_->BelongsToCurrentThread()); | 
| 111   if (video_frame_provider_client_) | 131   if (video_frame_provider_client_) | 
| 112     video_frame_provider_client_->StopUsingProvider(); | 132     video_frame_provider_client_->StopUsingProvider(); | 
| 113 } | 133 } | 
| 114 | 134 | 
| 115 gfx::Size WebMediaPlayerMSCompositor::GetCurrentSize() { | 135 gfx::Size WebMediaPlayerMSCompositor::GetCurrentSize() { | 
| 116   DCHECK(thread_checker_.CalledOnValidThread()); | 136   DCHECK(thread_checker_.CalledOnValidThread()); | 
| 117   base::AutoLock auto_lock(current_frame_lock_); | 137   base::AutoLock auto_lock(current_frame_lock_); | 
| 118   return current_frame_ ? current_frame_->natural_size() : gfx::Size(); | 138   return current_frame_ ? current_frame_->natural_size() : gfx::Size(); | 
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 339 | 359 | 
| 340 void WebMediaPlayerMSCompositor::SetCurrentFrame( | 360 void WebMediaPlayerMSCompositor::SetCurrentFrame( | 
| 341     const scoped_refptr<media::VideoFrame>& frame) { | 361     const scoped_refptr<media::VideoFrame>& frame) { | 
| 342   current_frame_lock_.AssertAcquired(); | 362   current_frame_lock_.AssertAcquired(); | 
| 343   if (!current_frame_used_by_compositor_) | 363   if (!current_frame_used_by_compositor_) | 
| 344     ++dropped_frame_count_; | 364     ++dropped_frame_count_; | 
| 345   current_frame_used_by_compositor_ = false; | 365   current_frame_used_by_compositor_ = false; | 
| 346   current_frame_ = frame; | 366   current_frame_ = frame; | 
| 347 } | 367 } | 
| 348 } | 368 } | 
| OLD | NEW | 
|---|