Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: content/renderer/media/android/webmediaplayer_android.cc

Issue 1315323006: webgl: optimize webgl.texSubImage2D(video) path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: don't use c++11 initialize-list Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/android/webmediaplayer_android.h" 5 #include "content/renderer/media/android/webmediaplayer_android.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/android/build_info.h" 9 #include "base/android/build_info.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 // a new one based on video size. 627 // a new one based on video size.
628 if (!IsSkBitmapProperlySizedTexture(&bitmap_, naturalSize())) { 628 if (!IsSkBitmapProperlySizedTexture(&bitmap_, naturalSize())) {
629 if (!AllocateSkBitmapTexture(provider->grContext(), &bitmap_, 629 if (!AllocateSkBitmapTexture(provider->grContext(), &bitmap_,
630 naturalSize())) { 630 naturalSize())) {
631 return; 631 return;
632 } 632 }
633 } 633 }
634 634
635 unsigned textureId = static_cast<unsigned>( 635 unsigned textureId = static_cast<unsigned>(
636 (bitmap_.getTexture())->getTextureHandle()); 636 (bitmap_.getTexture())->getTextureHandle());
637 if (!copyVideoTextureToPlatformTexture(context3D, textureId, 637 if (!copyVideoTextureToPlatformTexture(
638 GL_RGBA, GL_UNSIGNED_BYTE, true, false)) { 638 context3D,
639 CopyVideoTextureParams(CopyVideoTextureParams::FullCopy,
640 GL_TEXTURE_2D, textureId, GL_RGBA,
641 GL_UNSIGNED_BYTE, 0, 0, 0, true, false))) {
639 return; 642 return;
640 } 643 }
641 644
642 // Draw the texture based bitmap onto the Canvas. If the canvas is 645 // Draw the texture based bitmap onto the Canvas. If the canvas is
643 // hardware based, this will do a GPU-GPU texture copy. 646 // hardware based, this will do a GPU-GPU texture copy.
644 // If the canvas is software based, the texture based bitmap will be 647 // If the canvas is software based, the texture based bitmap will be
645 // readbacked to system memory then draw onto the canvas. 648 // readbacked to system memory then draw onto the canvas.
646 SkRect dest; 649 SkRect dest;
647 dest.set(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); 650 dest.set(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height);
648 SkPaint paint; 651 SkPaint paint;
649 paint.setAlpha(alpha); 652 paint.setAlpha(alpha);
650 paint.setXfermodeMode(mode); 653 paint.setXfermodeMode(mode);
651 // It is not necessary to pass the dest into the drawBitmap call since all 654 // It is not necessary to pass the dest into the drawBitmap call since all
652 // the context have been set up before calling paintCurrentFrameInContext. 655 // the context have been set up before calling paintCurrentFrameInContext.
653 canvas->drawBitmapRect(bitmap_, dest, &paint); 656 canvas->drawBitmapRect(bitmap_, dest, &paint);
654 } 657 }
655 658
656 bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture( 659 bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture(
657 blink::WebGraphicsContext3D* web_graphics_context, 660 blink::WebGraphicsContext3D* web_graphics_context,
658 unsigned int texture, 661 const CopyVideoTextureParams& params) {
659 unsigned int internal_format,
660 unsigned int type,
661 bool premultiply_alpha,
662 bool flip_y) {
663 DCHECK(main_thread_checker_.CalledOnValidThread()); 662 DCHECK(main_thread_checker_.CalledOnValidThread());
663 DCHECK((params.copyType == CopyVideoTextureParams::FullCopy &&
664 !params.xoffset && !params.yoffset) ||
665 (params.copyType == CopyVideoTextureParams::SubCopy &&
666 !params.internalFormat && !params.type));
664 // Don't allow clients to copy an encrypted video frame. 667 // Don't allow clients to copy an encrypted video frame.
665 if (needs_external_surface_) 668 if (needs_external_surface_)
666 return false; 669 return false;
667 670
668 scoped_refptr<VideoFrame> video_frame; 671 scoped_refptr<VideoFrame> video_frame;
669 { 672 {
670 base::AutoLock auto_lock(current_frame_lock_); 673 base::AutoLock auto_lock(current_frame_lock_);
671 video_frame = current_frame_; 674 video_frame = current_frame_;
672 } 675 }
673 676
(...skipping 10 matching lines...) Expand all
684 // Ensure the target of texture is set before copyTextureCHROMIUM, otherwise 687 // Ensure the target of texture is set before copyTextureCHROMIUM, otherwise
685 // an invalid texture target may be used for copy texture. 688 // an invalid texture target may be used for copy texture.
686 uint32 src_texture = 689 uint32 src_texture =
687 web_graphics_context->createAndConsumeTextureCHROMIUM( 690 web_graphics_context->createAndConsumeTextureCHROMIUM(
688 mailbox_holder.texture_target, mailbox_holder.mailbox.name); 691 mailbox_holder.texture_target, mailbox_holder.mailbox.name);
689 692
690 // Application itself needs to take care of setting the right flip_y 693 // Application itself needs to take care of setting the right flip_y
691 // value down to get the expected result. 694 // value down to get the expected result.
692 // flip_y==true means to reverse the video orientation while 695 // flip_y==true means to reverse the video orientation while
693 // flip_y==false means to keep the intrinsic orientation. 696 // flip_y==false means to keep the intrinsic orientation.
694 web_graphics_context->copyTextureCHROMIUM( 697 if (params.copyType == CopyVideoTextureParams::FullCopy) {
695 GL_TEXTURE_2D, src_texture, texture, internal_format, type, 698 web_graphics_context->copyTextureCHROMIUM(
696 flip_y, premultiply_alpha, false); 699 params.target, src_texture, params.texture, params.internalFormat,
700 params.type, params.flipY, params.premultiplyAlpha, false);
701 } else {
702 web_graphics_context->copySubTextureCHROMIUM(
703 params.target, src_texture, params.texture, params.xoffset,
704 params.yoffset, 0, 0, video_frame->natural_size().width(),
705 video_frame->natural_size().height(), params.flipY,
706 params.premultiplyAlpha, false);
707 }
697 708
698 web_graphics_context->deleteTexture(src_texture); 709 web_graphics_context->deleteTexture(src_texture);
699 web_graphics_context->flush(); 710 web_graphics_context->flush();
700 711
701 SyncPointClientImpl client(web_graphics_context); 712 SyncPointClientImpl client(web_graphics_context);
702 video_frame->UpdateReleaseSyncPoint(&client); 713 video_frame->UpdateReleaseSyncPoint(&client);
703 return true; 714 return true;
704 } 715 }
705 716
706 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const { 717 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const {
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 1925
1915 bool is_hls = IsHLSStream(); 1926 bool is_hls = IsHLSStream();
1916 UMA_HISTOGRAM_BOOLEAN("Media.Android.IsHttpLiveStreamingMedia", is_hls); 1927 UMA_HISTOGRAM_BOOLEAN("Media.Android.IsHttpLiveStreamingMedia", is_hls);
1917 if (is_hls) { 1928 if (is_hls) {
1918 media::RecordOriginOfHLSPlayback( 1929 media::RecordOriginOfHLSPlayback(
1919 GURL(frame_->document().securityOrigin().toString())); 1930 GURL(frame_->document().securityOrigin().toString()));
1920 } 1931 }
1921 } 1932 }
1922 1933
1923 } // namespace content 1934 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698