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

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

Powered by Google App Engine
This is Rietveld 408576698