| 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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 | 533 |
| 534 // TODO(scherkus): Clarify paint() API contract to better understand when and | 534 // TODO(scherkus): Clarify paint() API contract to better understand when and |
| 535 // why it's being called. For example, today paint() is called when: | 535 // 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 | 536 // - We haven't reached HAVE_CURRENT_DATA and need to paint black |
| 537 // - We're painting to a canvas | 537 // - We're painting to a canvas |
| 538 // See http://crbug.com/341225 http://crbug.com/342621 for details. | 538 // See http://crbug.com/341225 http://crbug.com/342621 for details. |
| 539 scoped_refptr<media::VideoFrame> video_frame = | 539 scoped_refptr<media::VideoFrame> video_frame = |
| 540 GetCurrentFrameFromCompositor(); | 540 GetCurrentFrameFromCompositor(); |
| 541 | 541 |
| 542 gfx::Rect gfx_rect(rect); | 542 gfx::Rect gfx_rect(rect); |
| 543 |
| 544 if (pipeline_metadata_.video_rotation == media::VIDEO_ROTATION_90 || |
| 545 pipeline_metadata_.video_rotation == media::VIDEO_ROTATION_270) |
| 546 gfx_rect.set_size( |
| 547 gfx::Size(gfx_rect.size().height(), gfx_rect.size().width())); |
| 548 |
| 543 skcanvas_video_renderer_.Paint(video_frame.get(), canvas, gfx_rect, alpha); | 549 skcanvas_video_renderer_.Paint(video_frame.get(), canvas, gfx_rect, alpha); |
| 544 } | 550 } |
| 545 | 551 |
| 546 bool WebMediaPlayerImpl::hasSingleSecurityOrigin() const { | 552 bool WebMediaPlayerImpl::hasSingleSecurityOrigin() const { |
| 547 if (data_source_) | 553 if (data_source_) |
| 548 return data_source_->HasSingleOrigin(); | 554 return data_source_->HasSingleOrigin(); |
| 549 return true; | 555 return true; |
| 550 } | 556 } |
| 551 | 557 |
| 552 bool WebMediaPlayerImpl::didPassCORSAccessCheck() const { | 558 bool WebMediaPlayerImpl::didPassCORSAccessCheck() const { |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 | 969 |
| 964 pipeline_metadata_ = metadata; | 970 pipeline_metadata_ = metadata; |
| 965 | 971 |
| 966 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", | 972 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", |
| 967 metadata.video_rotation, | 973 metadata.video_rotation, |
| 968 media::VIDEO_ROTATION_MAX + 1); | 974 media::VIDEO_ROTATION_MAX + 1); |
| 969 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 975 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
| 970 | 976 |
| 971 if (hasVideo()) { | 977 if (hasVideo()) { |
| 972 DCHECK(!video_weblayer_); | 978 DCHECK(!video_weblayer_); |
| 973 video_weblayer_.reset( | 979 scoped_refptr<cc::VideoLayer> layer = cc::VideoLayer::Create(compositor_); |
| 974 new WebLayerImpl(cc::VideoLayer::Create(compositor_))); | 980 layer->set_video_rotation(pipeline_metadata_.video_rotation); |
| 981 |
| 982 if (pipeline_metadata_.video_rotation == media::VIDEO_ROTATION_90 || |
| 983 pipeline_metadata_.video_rotation == media::VIDEO_ROTATION_270) { |
| 984 gfx::Size size = pipeline_metadata_.natural_size; |
| 985 pipeline_metadata_.natural_size = gfx::Size(size.height(), size.width()); |
| 986 } |
| 987 |
| 988 video_weblayer_.reset(new WebLayerImpl(layer)); |
| 975 video_weblayer_->setOpaque(opaque_); | 989 video_weblayer_->setOpaque(opaque_); |
| 976 client_->setWebLayer(video_weblayer_.get()); | 990 client_->setWebLayer(video_weblayer_.get()); |
| 977 } | 991 } |
| 978 | 992 |
| 979 // TODO(scherkus): This should be handled by HTMLMediaElement and controls | 993 // TODO(scherkus): This should be handled by HTMLMediaElement and controls |
| 980 // should know when to invalidate themselves http://crbug.com/337015 | 994 // should know when to invalidate themselves http://crbug.com/337015 |
| 981 InvalidateOnMainThread(); | 995 InvalidateOnMainThread(); |
| 982 } | 996 } |
| 983 | 997 |
| 984 void WebMediaPlayerImpl::OnPipelineBufferingStateChanged( | 998 void WebMediaPlayerImpl::OnPipelineBufferingStateChanged( |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 compositor_task_runner_->PostTask(FROM_HERE, | 1375 compositor_task_runner_->PostTask(FROM_HERE, |
| 1362 base::Bind(&GetCurrentFrameAndSignal, | 1376 base::Bind(&GetCurrentFrameAndSignal, |
| 1363 base::Unretained(compositor_), | 1377 base::Unretained(compositor_), |
| 1364 &video_frame, | 1378 &video_frame, |
| 1365 &event)); | 1379 &event)); |
| 1366 event.Wait(); | 1380 event.Wait(); |
| 1367 return video_frame; | 1381 return video_frame; |
| 1368 } | 1382 } |
| 1369 | 1383 |
| 1370 } // namespace content | 1384 } // namespace content |
| OLD | NEW |