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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
540 | 540 |
541 // TODO(scherkus): Clarify paint() API contract to better understand when and | 541 // TODO(scherkus): Clarify paint() API contract to better understand when and |
542 // why it's being called. For example, today paint() is called when: | 542 // why it's being called. For example, today paint() is called when: |
543 // - We haven't reached HAVE_CURRENT_DATA and need to paint black | 543 // - We haven't reached HAVE_CURRENT_DATA and need to paint black |
544 // - We're painting to a canvas | 544 // - We're painting to a canvas |
545 // See http://crbug.com/341225 http://crbug.com/342621 for details. | 545 // See http://crbug.com/341225 http://crbug.com/342621 for details. |
546 scoped_refptr<media::VideoFrame> video_frame = | 546 scoped_refptr<media::VideoFrame> video_frame = |
547 GetCurrentFrameFromCompositor(); | 547 GetCurrentFrameFromCompositor(); |
548 | 548 |
549 gfx::Rect gfx_rect(rect); | 549 gfx::Rect gfx_rect(rect); |
550 | |
551 if (pipeline_metadata_.video_rotation == media::VIDEO_ROTATION_90 || | |
552 pipeline_metadata_.video_rotation == media::VIDEO_ROTATION_270) | |
553 gfx_rect.set_size( | |
scherkus (not reviewing)
2014/08/06 23:06:42
nit: for if-statements that are >1 line please use
suderman
2014/08/07 00:31:31
Done.
| |
554 gfx::Size(gfx_rect.size().height(), gfx_rect.size().width())); | |
555 | |
550 skcanvas_video_renderer_.Paint(video_frame.get(), canvas, gfx_rect, alpha); | 556 skcanvas_video_renderer_.Paint(video_frame.get(), canvas, gfx_rect, alpha); |
551 } | 557 } |
552 | 558 |
553 bool WebMediaPlayerImpl::hasSingleSecurityOrigin() const { | 559 bool WebMediaPlayerImpl::hasSingleSecurityOrigin() const { |
554 if (data_source_) | 560 if (data_source_) |
555 return data_source_->HasSingleOrigin(); | 561 return data_source_->HasSingleOrigin(); |
556 return true; | 562 return true; |
557 } | 563 } |
558 | 564 |
559 bool WebMediaPlayerImpl::didPassCORSAccessCheck() const { | 565 bool WebMediaPlayerImpl::didPassCORSAccessCheck() const { |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
939 | 945 |
940 pipeline_metadata_ = metadata; | 946 pipeline_metadata_ = metadata; |
941 | 947 |
942 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", | 948 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", |
943 metadata.video_rotation, | 949 metadata.video_rotation, |
944 media::VIDEO_ROTATION_MAX + 1); | 950 media::VIDEO_ROTATION_MAX + 1); |
945 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 951 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
946 | 952 |
947 if (hasVideo()) { | 953 if (hasVideo()) { |
948 DCHECK(!video_weblayer_); | 954 DCHECK(!video_weblayer_); |
949 video_weblayer_.reset( | 955 scoped_refptr<cc::VideoLayer> layer = |
950 new WebLayerImpl(cc::VideoLayer::Create(compositor_))); | 956 cc::VideoLayer::Create(compositor_, pipeline_metadata_.video_rotation); |
957 | |
958 if (pipeline_metadata_.video_rotation == media::VIDEO_ROTATION_90 || | |
959 pipeline_metadata_.video_rotation == media::VIDEO_ROTATION_270) { | |
960 gfx::Size size = pipeline_metadata_.natural_size; | |
961 pipeline_metadata_.natural_size = gfx::Size(size.height(), size.width()); | |
962 } | |
963 | |
964 video_weblayer_.reset(new WebLayerImpl(layer)); | |
951 video_weblayer_->setOpaque(opaque_); | 965 video_weblayer_->setOpaque(opaque_); |
952 client_->setWebLayer(video_weblayer_.get()); | 966 client_->setWebLayer(video_weblayer_.get()); |
953 } | 967 } |
954 } | 968 } |
955 | 969 |
956 void WebMediaPlayerImpl::OnPipelineBufferingStateChanged( | 970 void WebMediaPlayerImpl::OnPipelineBufferingStateChanged( |
957 media::BufferingState buffering_state) { | 971 media::BufferingState buffering_state) { |
958 DVLOG(1) << __FUNCTION__ << "(" << buffering_state << ")"; | 972 DVLOG(1) << __FUNCTION__ << "(" << buffering_state << ")"; |
959 | 973 |
960 // Ignore buffering state changes until we've completed all outstanding seeks. | 974 // Ignore buffering state changes until we've completed all outstanding seeks. |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1325 compositor_task_runner_->PostTask(FROM_HERE, | 1339 compositor_task_runner_->PostTask(FROM_HERE, |
1326 base::Bind(&GetCurrentFrameAndSignal, | 1340 base::Bind(&GetCurrentFrameAndSignal, |
1327 base::Unretained(compositor_), | 1341 base::Unretained(compositor_), |
1328 &video_frame, | 1342 &video_frame, |
1329 &event)); | 1343 &event)); |
1330 event.Wait(); | 1344 event.Wait(); |
1331 return video_frame; | 1345 return video_frame; |
1332 } | 1346 } |
1333 | 1347 |
1334 } // namespace content | 1348 } // namespace content |
OLD | NEW |