OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_impl.h" | 5 #include "content/renderer/media/webmediaplayer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 opaque_(false), | 162 opaque_(false), |
163 paused_(true), | 163 paused_(true), |
164 seeking_(false), | 164 seeking_(false), |
165 playback_rate_(0.0f), | 165 playback_rate_(0.0f), |
166 pending_seek_(false), | 166 pending_seek_(false), |
167 pending_seek_seconds_(0.0f), | 167 pending_seek_seconds_(0.0f), |
168 should_notify_time_changed_(false), | 168 should_notify_time_changed_(false), |
169 client_(client), | 169 client_(client), |
170 delegate_(delegate), | 170 delegate_(delegate), |
171 defer_load_cb_(params.defer_load_cb()), | 171 defer_load_cb_(params.defer_load_cb()), |
172 accelerated_compositing_reported_(false), | |
173 incremented_externally_allocated_memory_(false), | 172 incremented_externally_allocated_memory_(false), |
174 gpu_factories_(RenderThreadImpl::current()->GetGpuFactories()), | 173 gpu_factories_(RenderThreadImpl::current()->GetGpuFactories()), |
175 supports_save_(true), | 174 supports_save_(true), |
176 chunk_demuxer_(NULL), | 175 chunk_demuxer_(NULL), |
177 // Threaded compositing isn't enabled universally yet. | 176 // Threaded compositing isn't enabled universally yet. |
178 compositor_task_runner_( | 177 compositor_task_runner_( |
179 RenderThreadImpl::current()->compositor_message_loop_proxy() | 178 RenderThreadImpl::current()->compositor_message_loop_proxy() |
180 ? RenderThreadImpl::current()->compositor_message_loop_proxy() | 179 ? RenderThreadImpl::current()->compositor_message_loop_proxy() |
181 : base::MessageLoopProxy::current()), | 180 : base::MessageLoopProxy::current()), |
182 compositor_(new VideoFrameCompositor( | 181 compositor_(new VideoFrameCompositor( |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 bool data_progress = buffered_data_source_host_.DidLoadingProgress(); | 513 bool data_progress = buffered_data_source_host_.DidLoadingProgress(); |
515 return pipeline_progress || data_progress; | 514 return pipeline_progress || data_progress; |
516 } | 515 } |
517 | 516 |
518 void WebMediaPlayerImpl::paint(WebCanvas* canvas, | 517 void WebMediaPlayerImpl::paint(WebCanvas* canvas, |
519 const WebRect& rect, | 518 const WebRect& rect, |
520 unsigned char alpha) { | 519 unsigned char alpha) { |
521 DCHECK(main_loop_->BelongsToCurrentThread()); | 520 DCHECK(main_loop_->BelongsToCurrentThread()); |
522 TRACE_EVENT0("media", "WebMediaPlayerImpl:paint"); | 521 TRACE_EVENT0("media", "WebMediaPlayerImpl:paint"); |
523 | 522 |
524 if (!accelerated_compositing_reported_) { | |
525 accelerated_compositing_reported_ = true; | |
526 // Normally paint() is only called in non-accelerated rendering, but there | |
527 // are exceptions such as webgl where compositing is used in the WebView but | |
528 // video frames are still rendered to a canvas. | |
529 UMA_HISTOGRAM_BOOLEAN( | |
530 "Media.AcceleratedCompositingActive", | |
531 frame_->view()->isAcceleratedCompositingActive()); | |
532 } | |
533 | |
534 // TODO(scherkus): Clarify paint() API contract to better understand when and | 523 // TODO(scherkus): Clarify paint() API contract to better understand when and |
535 // why it's being called. For example, today paint() is called when: | 524 // why it's being called. For example, today paint() is called when: |
536 // - We haven't reached HAVE_CURRENT_DATA and need to paint black | 525 // - We haven't reached HAVE_CURRENT_DATA and need to paint black |
537 // - We're painting to a canvas | 526 // - We're painting to a canvas |
538 // See http://crbug.com/341225 http://crbug.com/342621 for details. | 527 // See http://crbug.com/341225 http://crbug.com/342621 for details. |
539 scoped_refptr<media::VideoFrame> video_frame = | 528 scoped_refptr<media::VideoFrame> video_frame = |
540 GetCurrentFrameFromCompositor(); | 529 GetCurrentFrameFromCompositor(); |
541 | 530 |
542 gfx::Rect gfx_rect(rect); | 531 gfx::Rect gfx_rect(rect); |
543 skcanvas_video_renderer_.Paint(video_frame.get(), canvas, gfx_rect, alpha); | 532 skcanvas_video_renderer_.Paint(video_frame.get(), canvas, gfx_rect, alpha); |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 compositor_task_runner_->PostTask(FROM_HERE, | 1350 compositor_task_runner_->PostTask(FROM_HERE, |
1362 base::Bind(&GetCurrentFrameAndSignal, | 1351 base::Bind(&GetCurrentFrameAndSignal, |
1363 base::Unretained(compositor_), | 1352 base::Unretained(compositor_), |
1364 &video_frame, | 1353 &video_frame, |
1365 &event)); | 1354 &event)); |
1366 event.Wait(); | 1355 event.Wait(); |
1367 return video_frame; | 1356 return video_frame; |
1368 } | 1357 } |
1369 | 1358 |
1370 } // namespace content | 1359 } // namespace content |
OLD | NEW |