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

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

Issue 1833273002: Remove WebGraphicsContext3D::getGLES2Interface(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: getgles2: rebase Created 4 years, 8 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 bool ret = did_loading_progress_; 641 bool ret = did_loading_progress_;
642 did_loading_progress_ = false; 642 did_loading_progress_ = false;
643 return ret; 643 return ret;
644 } 644 }
645 645
646 void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas, 646 void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas,
647 const blink::WebRect& rect, 647 const blink::WebRect& rect,
648 unsigned char alpha, 648 unsigned char alpha,
649 SkXfermode::Mode mode) { 649 SkXfermode::Mode mode) {
650 DCHECK(main_thread_checker_.CalledOnValidThread()); 650 DCHECK(main_thread_checker_.CalledOnValidThread());
651 scoped_ptr<blink::WebGraphicsContext3DProvider> provider = 651 scoped_ptr<blink::WebGraphicsContext3DProvider> provider(
652 scoped_ptr<blink::WebGraphicsContext3DProvider>(blink::Platform::current( 652 blink::Platform::current()
653 )->createSharedOffscreenGraphicsContext3DProvider()); 653 ->createSharedOffscreenGraphicsContext3DProvider());
654 if (!provider) 654 if (!provider)
655 return; 655 return;
656 blink::WebGraphicsContext3D* context3D = provider->context3d(); 656 gpu::gles2::GLES2Interface* gl = provider->contextGL();
657 if (!context3D)
658 return;
659 657
660 // Copy video texture into a RGBA texture based bitmap first as video texture 658 // Copy video texture into a RGBA texture based bitmap first as video texture
661 // on Android is GL_TEXTURE_EXTERNAL_OES which is not supported by Skia yet. 659 // on Android is GL_TEXTURE_EXTERNAL_OES which is not supported by Skia yet.
662 // The bitmap's size needs to be the same as the video and use naturalSize() 660 // The bitmap's size needs to be the same as the video and use naturalSize()
663 // here. Check if we could reuse existing texture based bitmap. 661 // here. Check if we could reuse existing texture based bitmap.
664 // Otherwise, release existing texture based bitmap and allocate 662 // Otherwise, release existing texture based bitmap and allocate
665 // a new one based on video size. 663 // a new one based on video size.
666 if (!IsSkBitmapProperlySizedTexture(&bitmap_, naturalSize())) { 664 if (!IsSkBitmapProperlySizedTexture(&bitmap_, naturalSize())) {
667 if (!AllocateSkBitmapTexture(provider->grContext(), &bitmap_, 665 if (!AllocateSkBitmapTexture(provider->grContext(), &bitmap_,
668 naturalSize())) { 666 naturalSize())) {
669 return; 667 return;
670 } 668 }
671 } 669 }
672 670
673 unsigned textureId = skia::GrBackendObjectToGrGLTextureInfo( 671 unsigned textureId = skia::GrBackendObjectToGrGLTextureInfo(
674 (bitmap_.getTexture())->getTextureHandle()) 672 (bitmap_.getTexture())->getTextureHandle())
675 ->fID; 673 ->fID;
676 if (!copyVideoTextureToPlatformTexture(context3D, textureId, 674 if (!copyVideoTextureToPlatformTexture(gl, textureId, GL_RGBA,
677 GL_RGBA, GL_UNSIGNED_BYTE, true, false)) { 675 GL_UNSIGNED_BYTE, true, false)) {
678 return; 676 return;
679 } 677 }
680 678
681 // Ensure SkBitmap to make the latest change by external source visible. 679 // Ensure SkBitmap to make the latest change by external source visible.
682 bitmap_.notifyPixelsChanged(); 680 bitmap_.notifyPixelsChanged();
683 681
684 // Draw the texture based bitmap onto the Canvas. If the canvas is 682 // Draw the texture based bitmap onto the Canvas. If the canvas is
685 // hardware based, this will do a GPU-GPU texture copy. 683 // hardware based, this will do a GPU-GPU texture copy.
686 // If the canvas is software based, the texture based bitmap will be 684 // If the canvas is software based, the texture based bitmap will be
687 // readbacked to system memory then draw onto the canvas. 685 // readbacked to system memory then draw onto the canvas.
688 SkRect dest; 686 SkRect dest;
689 dest.set(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); 687 dest.set(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height);
690 SkPaint paint; 688 SkPaint paint;
691 paint.setAlpha(alpha); 689 paint.setAlpha(alpha);
692 paint.setXfermodeMode(mode); 690 paint.setXfermodeMode(mode);
693 // It is not necessary to pass the dest into the drawBitmap call since all 691 // It is not necessary to pass the dest into the drawBitmap call since all
694 // the context have been set up before calling paintCurrentFrameInContext. 692 // the context have been set up before calling paintCurrentFrameInContext.
695 canvas->drawBitmapRect(bitmap_, dest, &paint); 693 canvas->drawBitmapRect(bitmap_, dest, &paint);
696 canvas->flush(); 694 canvas->flush();
697 } 695 }
698 696
699 bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture( 697 bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture(
700 blink::WebGraphicsContext3D* web_graphics_context, 698 gpu::gles2::GLES2Interface* gl,
701 unsigned int texture, 699 unsigned int texture,
702 unsigned int internal_format, 700 unsigned int internal_format,
703 unsigned int type, 701 unsigned int type,
704 bool premultiply_alpha, 702 bool premultiply_alpha,
705 bool flip_y) { 703 bool flip_y) {
706 // TODO(danakj): Pass a GLES2Interface to this method instead.
707 gpu::gles2::GLES2Interface* gl = web_graphics_context->getGLES2Interface();
708 DCHECK(main_thread_checker_.CalledOnValidThread()); 704 DCHECK(main_thread_checker_.CalledOnValidThread());
709 // Don't allow clients to copy an encrypted video frame. 705 // Don't allow clients to copy an encrypted video frame.
710 if (needs_external_surface_) 706 if (needs_external_surface_)
711 return false; 707 return false;
712 708
713 scoped_refptr<VideoFrame> video_frame; 709 scoped_refptr<VideoFrame> video_frame;
714 { 710 {
715 base::AutoLock auto_lock(current_frame_lock_); 711 base::AutoLock auto_lock(current_frame_lock_);
716 video_frame = current_frame_; 712 video_frame = current_frame_;
717 } 713 }
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER; 1671 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER;
1676 } else if (is_hls_url == is_hls) { 1672 } else if (is_hls_url == is_hls) {
1677 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER; 1673 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER;
1678 } 1674 }
1679 UMA_HISTOGRAM_ENUMERATION( 1675 UMA_HISTOGRAM_ENUMERATION(
1680 "Media.Android.IsHttpLiveStreamingMediaPredictionResult", 1676 "Media.Android.IsHttpLiveStreamingMediaPredictionResult",
1681 result, PREDICTION_RESULT_MAX); 1677 result, PREDICTION_RESULT_MAX);
1682 } 1678 }
1683 1679
1684 } // namespace content 1680 } // 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