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 "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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 } | 613 } |
614 | 614 |
615 bool WebMediaPlayerAndroid::didLoadingProgress() { | 615 bool WebMediaPlayerAndroid::didLoadingProgress() { |
616 bool ret = did_loading_progress_; | 616 bool ret = did_loading_progress_; |
617 did_loading_progress_ = false; | 617 did_loading_progress_ = false; |
618 return ret; | 618 return ret; |
619 } | 619 } |
620 | 620 |
621 void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas, | 621 void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas, |
622 const blink::WebRect& rect, | 622 const blink::WebRect& rect, |
623 unsigned char alpha, | 623 SkPaint& paint) { |
624 SkXfermode::Mode mode) { | |
625 DCHECK(main_thread_checker_.CalledOnValidThread()); | 624 DCHECK(main_thread_checker_.CalledOnValidThread()); |
626 std::unique_ptr<blink::WebGraphicsContext3DProvider> provider( | 625 std::unique_ptr<blink::WebGraphicsContext3DProvider> provider( |
627 blink::Platform::current() | 626 blink::Platform::current() |
628 ->createSharedOffscreenGraphicsContext3DProvider()); | 627 ->createSharedOffscreenGraphicsContext3DProvider()); |
629 if (!provider) | 628 if (!provider) |
630 return; | 629 return; |
631 gpu::gles2::GLES2Interface* gl = provider->contextGL(); | 630 gpu::gles2::GLES2Interface* gl = provider->contextGL(); |
632 | 631 |
633 scoped_refptr<VideoFrame> video_frame; | 632 scoped_refptr<VideoFrame> video_frame; |
634 { | 633 { |
(...skipping 27 matching lines...) Expand all Loading... |
662 kOpaque_SkAlphaType)); | 661 kOpaque_SkAlphaType)); |
663 if (!image) | 662 if (!image) |
664 return; | 663 return; |
665 | 664 |
666 // Draw the texture based image onto the Canvas. If the canvas is | 665 // Draw the texture based image onto the Canvas. If the canvas is |
667 // hardware based, this will do a GPU-GPU texture copy. | 666 // hardware based, this will do a GPU-GPU texture copy. |
668 // If the canvas is software based, the texture based bitmap will be | 667 // If the canvas is software based, the texture based bitmap will be |
669 // readbacked to system memory then draw onto the canvas. | 668 // readbacked to system memory then draw onto the canvas. |
670 SkRect dest; | 669 SkRect dest; |
671 dest.set(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); | 670 dest.set(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); |
672 SkPaint paint; | 671 SkPaint video_paint; |
673 paint.setAlpha(alpha); | 672 video_paint.setAlpha(paint.getAlpha()); |
674 paint.setXfermodeMode(mode); | 673 SkXfermode::Mode mode; |
| 674 if (!SkXfermode::AsMode(paint.getXfermode(), &mode)) |
| 675 mode = SkXfermode::kSrcOver_Mode; |
| 676 video_paint.setXfermodeMode(mode); |
675 // It is not necessary to pass the dest into the drawBitmap call since all | 677 // It is not necessary to pass the dest into the drawBitmap call since all |
676 // the context have been set up before calling paintCurrentFrameInContext. | 678 // the context have been set up before calling paintCurrentFrameInContext. |
677 canvas->drawImageRect(image, dest, &paint); | 679 canvas->drawImageRect(image, dest, &video_paint); |
678 | 680 |
679 // Ensure the Skia draw of the GL texture is flushed to GL, delete the | 681 // Ensure the Skia draw of the GL texture is flushed to GL, delete the |
680 // mailboxed texture from this context, and then signal that we're done with | 682 // mailboxed texture from this context, and then signal that we're done with |
681 // the video frame. | 683 // the video frame. |
682 canvas->flush(); | 684 canvas->flush(); |
683 gl->DeleteTextures(1, &src_texture); | 685 gl->DeleteTextures(1, &src_texture); |
684 gl->Flush(); | 686 gl->Flush(); |
685 SyncTokenClientImpl client(gl); | 687 SyncTokenClientImpl client(gl); |
686 video_frame->UpdateReleaseSyncToken(&client); | 688 video_frame->UpdateReleaseSyncToken(&client); |
687 } | 689 } |
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1707 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1709 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
1708 switches::kDisableMediaSuspend)) { | 1710 switches::kDisableMediaSuspend)) { |
1709 return false; | 1711 return false; |
1710 } | 1712 } |
1711 | 1713 |
1712 return base::FeatureList::IsEnabled(media::kResumeBackgroundVideo) && | 1714 return base::FeatureList::IsEnabled(media::kResumeBackgroundVideo) && |
1713 hasAudio() && !isRemote() && delegate_ && delegate_->IsHidden(); | 1715 hasAudio() && !isRemote() && delegate_ && delegate_->IsHidden(); |
1714 } | 1716 } |
1715 | 1717 |
1716 } // namespace content | 1718 } // namespace content |
OLD | NEW |