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

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

Issue 1420843005: Revert of "webgl: optimize webgl.texSubImage2D(video) path." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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( 638 if (!copyVideoTextureToPlatformTexture(context3D, textureId,
639 context3D, 639 GL_RGBA, GL_UNSIGNED_BYTE, true, false)) {
640 CopyVideoTextureParams(CopyVideoTextureParams::FullCopy,
641 GL_TEXTURE_2D, textureId, GL_RGBA,
642 GL_UNSIGNED_BYTE, 0, 0, 0, true, false))) {
643 return; 640 return;
644 } 641 }
645 642
646 // Ensure SkBitmap to make the latest change by external source visible. 643 // Ensure SkBitmap to make the latest change by external source visible.
647 bitmap_.notifyPixelsChanged(); 644 bitmap_.notifyPixelsChanged();
648 645
649 // 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
650 // hardware based, this will do a GPU-GPU texture copy. 647 // hardware based, this will do a GPU-GPU texture copy.
651 // 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
652 // readbacked to system memory then draw onto the canvas. 649 // readbacked to system memory then draw onto the canvas.
653 SkRect dest; 650 SkRect dest;
654 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);
655 SkPaint paint; 652 SkPaint paint;
656 paint.setAlpha(alpha); 653 paint.setAlpha(alpha);
657 paint.setXfermodeMode(mode); 654 paint.setXfermodeMode(mode);
658 // 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
659 // the context have been set up before calling paintCurrentFrameInContext. 656 // the context have been set up before calling paintCurrentFrameInContext.
660 canvas->drawBitmapRect(bitmap_, dest, &paint); 657 canvas->drawBitmapRect(bitmap_, dest, &paint);
661 canvas->flush(); 658 canvas->flush();
662 } 659 }
663 660
664 bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture( 661 bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture(
665 blink::WebGraphicsContext3D* web_graphics_context, 662 blink::WebGraphicsContext3D* web_graphics_context,
666 const CopyVideoTextureParams& params) { 663 unsigned int texture,
664 unsigned int internal_format,
665 unsigned int type,
666 bool premultiply_alpha,
667 bool flip_y) {
667 DCHECK(main_thread_checker_.CalledOnValidThread()); 668 DCHECK(main_thread_checker_.CalledOnValidThread());
668 DCHECK((params.copyType == CopyVideoTextureParams::FullCopy &&
669 !params.xoffset && !params.yoffset) ||
670 (params.copyType == CopyVideoTextureParams::SubCopy &&
671 !params.internalFormat && !params.type));
672 // Don't allow clients to copy an encrypted video frame. 669 // Don't allow clients to copy an encrypted video frame.
673 if (needs_external_surface_) 670 if (needs_external_surface_)
674 return false; 671 return false;
675 672
676 scoped_refptr<VideoFrame> video_frame; 673 scoped_refptr<VideoFrame> video_frame;
677 { 674 {
678 base::AutoLock auto_lock(current_frame_lock_); 675 base::AutoLock auto_lock(current_frame_lock_);
679 video_frame = current_frame_; 676 video_frame = current_frame_;
680 } 677 }
681 678
(...skipping 10 matching lines...) Expand all
692 // Ensure the target of texture is set before copyTextureCHROMIUM, otherwise 689 // Ensure the target of texture is set before copyTextureCHROMIUM, otherwise
693 // an invalid texture target may be used for copy texture. 690 // an invalid texture target may be used for copy texture.
694 uint32 src_texture = 691 uint32 src_texture =
695 web_graphics_context->createAndConsumeTextureCHROMIUM( 692 web_graphics_context->createAndConsumeTextureCHROMIUM(
696 mailbox_holder.texture_target, mailbox_holder.mailbox.name); 693 mailbox_holder.texture_target, mailbox_holder.mailbox.name);
697 694
698 // Application itself needs to take care of setting the right flip_y 695 // Application itself needs to take care of setting the right flip_y
699 // value down to get the expected result. 696 // value down to get the expected result.
700 // flip_y==true means to reverse the video orientation while 697 // flip_y==true means to reverse the video orientation while
701 // flip_y==false means to keep the intrinsic orientation. 698 // flip_y==false means to keep the intrinsic orientation.
702 if (params.copyType == CopyVideoTextureParams::FullCopy) { 699 web_graphics_context->copyTextureCHROMIUM(
703 web_graphics_context->copyTextureCHROMIUM( 700 GL_TEXTURE_2D, src_texture, texture, internal_format, type,
704 params.target, src_texture, params.texture, params.internalFormat, 701 flip_y, premultiply_alpha, false);
705 params.type, params.flipY, params.premultiplyAlpha, false);
706 } else {
707 web_graphics_context->copySubTextureCHROMIUM(
708 params.target, src_texture, params.texture, params.xoffset,
709 params.yoffset, 0, 0, video_frame->natural_size().width(),
710 video_frame->natural_size().height(), params.flipY,
711 params.premultiplyAlpha, false);
712 }
713 702
714 web_graphics_context->deleteTexture(src_texture); 703 web_graphics_context->deleteTexture(src_texture);
715 web_graphics_context->flush(); 704 web_graphics_context->flush();
716 705
717 SyncPointClientImpl client(web_graphics_context); 706 SyncPointClientImpl client(web_graphics_context);
718 video_frame->UpdateReleaseSyncPoint(&client); 707 video_frame->UpdateReleaseSyncPoint(&client);
719 return true; 708 return true;
720 } 709 }
721 710
722 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const { 711 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const {
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 1919
1931 bool is_hls = IsHLSStream(); 1920 bool is_hls = IsHLSStream();
1932 UMA_HISTOGRAM_BOOLEAN("Media.Android.IsHttpLiveStreamingMedia", is_hls); 1921 UMA_HISTOGRAM_BOOLEAN("Media.Android.IsHttpLiveStreamingMedia", is_hls);
1933 if (is_hls) { 1922 if (is_hls) {
1934 media::RecordOriginOfHLSPlayback( 1923 media::RecordOriginOfHLSPlayback(
1935 GURL(frame_->document().securityOrigin().toString())); 1924 GURL(frame_->document().securityOrigin().toString()));
1936 } 1925 }
1937 } 1926 }
1938 1927
1939 } // namespace content 1928 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/android/webmediaplayer_android.h ('k') | content/renderer/media/webmediaplayer_ms.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698