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 "media/blink/webmediaplayer_impl.h" | 5 #include "media/blink/webmediaplayer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 unsigned char alpha, | 503 unsigned char alpha, |
504 SkXfermode::Mode mode) { | 504 SkXfermode::Mode mode) { |
505 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 505 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
506 TRACE_EVENT0("media", "WebMediaPlayerImpl:paint"); | 506 TRACE_EVENT0("media", "WebMediaPlayerImpl:paint"); |
507 | 507 |
508 // TODO(scherkus): Clarify paint() API contract to better understand when and | 508 // TODO(scherkus): Clarify paint() API contract to better understand when and |
509 // why it's being called. For example, today paint() is called when: | 509 // why it's being called. For example, today paint() is called when: |
510 // - We haven't reached HAVE_CURRENT_DATA and need to paint black | 510 // - We haven't reached HAVE_CURRENT_DATA and need to paint black |
511 // - We're painting to a canvas | 511 // - We're painting to a canvas |
512 // See http://crbug.com/341225 http://crbug.com/342621 for details. | 512 // See http://crbug.com/341225 http://crbug.com/342621 for details. |
513 scoped_refptr<VideoFrame> video_frame = | 513 scoped_refptr<VideoFrame> video_frame = GetCurrentFrameFromCompositor(); |
514 GetCurrentFrameFromCompositor(); | |
515 | 514 |
516 gfx::Rect gfx_rect(rect); | 515 gfx::Rect gfx_rect(rect); |
517 Context3D context_3d; | 516 Context3D context_3d; |
518 if (video_frame.get() && | 517 if (video_frame.get() && |
519 video_frame->format() == VideoFrame::NATIVE_TEXTURE) { | 518 video_frame->storage_type() == VideoFrame::STORAGE_TEXTURE) { |
520 if (!context_3d_cb_.is_null()) { | 519 if (!context_3d_cb_.is_null()) |
521 context_3d = context_3d_cb_.Run(); | 520 context_3d = context_3d_cb_.Run(); |
522 } | |
523 // GPU Process crashed. | 521 // GPU Process crashed. |
524 if (!context_3d.gl) | 522 if (!context_3d.gl) |
525 return; | 523 return; |
526 } | 524 } |
527 skcanvas_video_renderer_.Paint(video_frame, canvas, gfx_rect, alpha, mode, | 525 skcanvas_video_renderer_.Paint(video_frame, canvas, gfx_rect, alpha, mode, |
528 pipeline_metadata_.video_rotation, context_3d); | 526 pipeline_metadata_.video_rotation, context_3d); |
529 } | 527 } |
530 | 528 |
531 bool WebMediaPlayerImpl::hasSingleSecurityOrigin() const { | 529 bool WebMediaPlayerImpl::hasSingleSecurityOrigin() const { |
532 if (data_source_) | 530 if (data_source_) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 | 585 |
588 bool WebMediaPlayerImpl::copyVideoTextureToPlatformTexture( | 586 bool WebMediaPlayerImpl::copyVideoTextureToPlatformTexture( |
589 blink::WebGraphicsContext3D* web_graphics_context, | 587 blink::WebGraphicsContext3D* web_graphics_context, |
590 unsigned int texture, | 588 unsigned int texture, |
591 unsigned int internal_format, | 589 unsigned int internal_format, |
592 unsigned int type, | 590 unsigned int type, |
593 bool premultiply_alpha, | 591 bool premultiply_alpha, |
594 bool flip_y) { | 592 bool flip_y) { |
595 TRACE_EVENT0("media", "WebMediaPlayerImpl:copyVideoTextureToPlatformTexture"); | 593 TRACE_EVENT0("media", "WebMediaPlayerImpl:copyVideoTextureToPlatformTexture"); |
596 | 594 |
597 scoped_refptr<VideoFrame> video_frame = | 595 scoped_refptr<VideoFrame> video_frame = GetCurrentFrameFromCompositor(); |
598 GetCurrentFrameFromCompositor(); | |
599 | 596 |
600 if (!video_frame.get() || | 597 if (!video_frame.get() || |
601 video_frame->format() != VideoFrame::NATIVE_TEXTURE) { | 598 video_frame->storage_type() != VideoFrame::STORAGE_TEXTURE) { |
602 return false; | 599 return false; |
603 } | 600 } |
604 | 601 |
605 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to | 602 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to |
606 // GLES2Interface. | 603 // GLES2Interface. |
607 gpu::gles2::GLES2Interface* gl = | 604 gpu::gles2::GLES2Interface* gl = |
608 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context) | 605 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context) |
609 ->GetGLInterface(); | 606 ->GetGLInterface(); |
610 SkCanvasVideoRenderer::CopyVideoFrameTextureToGLTexture( | 607 SkCanvasVideoRenderer::CopyVideoFrameTextureToGLTexture( |
611 gl, video_frame.get(), texture, internal_format, type, premultiply_alpha, | 608 gl, video_frame.get(), texture, internal_format, type, premultiply_alpha, |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 | 1008 |
1012 // pause() may be called after playback has ended and the HTMLMediaElement | 1009 // pause() may be called after playback has ended and the HTMLMediaElement |
1013 // requires that currentTime() == duration() after ending. We want to ensure | 1010 // requires that currentTime() == duration() after ending. We want to ensure |
1014 // |paused_time_| matches currentTime() in this case or a future seek() may | 1011 // |paused_time_| matches currentTime() in this case or a future seek() may |
1015 // incorrectly discard what it thinks is a seek to the existing time. | 1012 // incorrectly discard what it thinks is a seek to the existing time. |
1016 paused_time_ = | 1013 paused_time_ = |
1017 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); | 1014 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); |
1018 } | 1015 } |
1019 | 1016 |
1020 } // namespace media | 1017 } // namespace media |
OLD | NEW |