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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 } | 626 } |
627 | 627 |
628 bool WebMediaPlayerImpl::copyVideoTextureToPlatformTexture( | 628 bool WebMediaPlayerImpl::copyVideoTextureToPlatformTexture( |
629 blink::WebGraphicsContext3D* web_graphics_context, | 629 blink::WebGraphicsContext3D* web_graphics_context, |
630 unsigned int texture, | 630 unsigned int texture, |
631 unsigned int internal_format, | 631 unsigned int internal_format, |
632 unsigned int type, | 632 unsigned int type, |
633 bool premultiply_alpha, | 633 bool premultiply_alpha, |
634 bool flip_y) { | 634 bool flip_y) { |
635 TRACE_EVENT0("media", "WebMediaPlayerImpl:copyVideoTextureToPlatformTexture"); | 635 TRACE_EVENT0("media", "WebMediaPlayerImpl:copyVideoTextureToPlatformTexture"); |
| 636 // TODO(dshwang): not include gl2.h because this method will be removed soon. |
| 637 const unsigned int GL_TEXTURE_2D = 0x0DE1; |
| 638 return copyVideoTextureToPlatformTexture(web_graphics_context, GL_TEXTURE_2D, |
| 639 texture, internal_format, type, 0, |
| 640 premultiply_alpha, flip_y); |
| 641 } |
| 642 |
| 643 bool WebMediaPlayerImpl::copyVideoTextureToPlatformTexture( |
| 644 blink::WebGraphicsContext3D* web_graphics_context, |
| 645 unsigned int target, |
| 646 unsigned int texture, |
| 647 unsigned int internal_format, |
| 648 unsigned int type, |
| 649 int level, |
| 650 bool premultiply_alpha, |
| 651 bool flip_y) { |
| 652 TRACE_EVENT0("media", "WebMediaPlayerImpl:copyVideoTextureToPlatformTexture"); |
636 | 653 |
637 scoped_refptr<VideoFrame> video_frame = GetCurrentFrameFromCompositor(); | 654 scoped_refptr<VideoFrame> video_frame = GetCurrentFrameFromCompositor(); |
638 | 655 |
639 if (!video_frame.get() || !video_frame->HasTextures() || | 656 if (!video_frame.get() || !video_frame->HasTextures() || |
640 media::VideoFrame::NumPlanes(video_frame->format()) != 1) { | 657 media::VideoFrame::NumPlanes(video_frame->format()) != 1) { |
641 return false; | 658 return false; |
642 } | 659 } |
643 | 660 |
644 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to | 661 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to |
645 // GLES2Interface. | 662 // GLES2Interface. |
646 gpu::gles2::GLES2Interface* gl = | 663 gpu::gles2::GLES2Interface* gl = |
647 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context) | 664 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context) |
648 ->GetGLInterface(); | 665 ->GetGLInterface(); |
649 SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture( | 666 SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture( |
650 gl, video_frame.get(), texture, internal_format, type, premultiply_alpha, | 667 gl, video_frame.get(), target, texture, internal_format, type, level, |
651 flip_y); | 668 premultiply_alpha, flip_y); |
652 return true; | 669 return true; |
653 } | 670 } |
654 | 671 |
| 672 bool WebMediaPlayerImpl::copyVideoSubTextureToPlatformTexture( |
| 673 blink::WebGraphicsContext3D* web_graphics_context, |
| 674 unsigned int target, |
| 675 unsigned int texture, |
| 676 int level, |
| 677 int xoffset, |
| 678 int yoffset, |
| 679 bool premultiply_alpha, |
| 680 bool flip_y) { |
| 681 TRACE_EVENT0("media", |
| 682 "WebMediaPlayerImpl:copyVideoSubTextureToPlatformTexture"); |
| 683 |
| 684 scoped_refptr<VideoFrame> video_frame = GetCurrentFrameFromCompositor(); |
| 685 |
| 686 if (!video_frame.get() || !video_frame->HasTextures() || |
| 687 media::VideoFrame::NumPlanes(video_frame->format()) != 1) { |
| 688 return false; |
| 689 } |
| 690 |
| 691 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to |
| 692 // GLES2Interface. |
| 693 gpu::gles2::GLES2Interface* gl = |
| 694 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context) |
| 695 ->GetGLInterface(); |
| 696 SkCanvasVideoRenderer::CopySubVideoFrameSingleTextureToGLTexture( |
| 697 gl, video_frame.get(), target, texture, level, xoffset, yoffset, |
| 698 premultiply_alpha, flip_y); |
| 699 return true; |
| 700 } |
| 701 |
655 WebMediaPlayer::MediaKeyException | 702 WebMediaPlayer::MediaKeyException |
656 WebMediaPlayerImpl::generateKeyRequest(const WebString& key_system, | 703 WebMediaPlayerImpl::generateKeyRequest(const WebString& key_system, |
657 const unsigned char* init_data, | 704 const unsigned char* init_data, |
658 unsigned init_data_length) { | 705 unsigned init_data_length) { |
659 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 706 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
660 | 707 |
661 return encrypted_media_support_.GenerateKeyRequest( | 708 return encrypted_media_support_.GenerateKeyRequest( |
662 frame_, key_system, init_data, init_data_length); | 709 frame_, key_system, init_data, init_data_length); |
663 } | 710 } |
664 | 711 |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 | 1106 |
1060 // pause() may be called after playback has ended and the HTMLMediaElement | 1107 // pause() may be called after playback has ended and the HTMLMediaElement |
1061 // requires that currentTime() == duration() after ending. We want to ensure | 1108 // requires that currentTime() == duration() after ending. We want to ensure |
1062 // |paused_time_| matches currentTime() in this case or a future seek() may | 1109 // |paused_time_| matches currentTime() in this case or a future seek() may |
1063 // incorrectly discard what it thinks is a seek to the existing time. | 1110 // incorrectly discard what it thinks is a seek to the existing time. |
1064 paused_time_ = | 1111 paused_time_ = |
1065 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); | 1112 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); |
1066 } | 1113 } |
1067 | 1114 |
1068 } // namespace media | 1115 } // namespace media |
OLD | NEW |