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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 canvas->flush(); | 569 canvas->flush(); |
570 gl->DeleteTextures(1, &src_texture); | 570 gl->DeleteTextures(1, &src_texture); |
571 gl->Flush(); | 571 gl->Flush(); |
572 SyncTokenClientImpl client(gl); | 572 SyncTokenClientImpl client(gl); |
573 video_frame->UpdateReleaseSyncToken(&client); | 573 video_frame->UpdateReleaseSyncToken(&client); |
574 } | 574 } |
575 | 575 |
576 bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture( | 576 bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture( |
577 gpu::gles2::GLES2Interface* gl, | 577 gpu::gles2::GLES2Interface* gl, |
578 unsigned int texture, | 578 unsigned int texture, |
579 unsigned int internal_format, | |
580 unsigned int type, | |
581 bool premultiply_alpha, | 579 bool premultiply_alpha, |
582 bool flip_y) { | 580 bool flip_y) { |
583 DCHECK(main_thread_checker_.CalledOnValidThread()); | 581 DCHECK(main_thread_checker_.CalledOnValidThread()); |
584 scoped_refptr<VideoFrame> video_frame; | 582 scoped_refptr<VideoFrame> video_frame; |
585 { | 583 { |
586 base::AutoLock auto_lock(current_frame_lock_); | 584 base::AutoLock auto_lock(current_frame_lock_); |
587 video_frame = current_frame_; | 585 video_frame = current_frame_; |
588 } | 586 } |
589 | 587 |
590 if (!video_frame.get() || !video_frame->HasTextures()) | 588 if (!video_frame.get() || !video_frame->HasTextures()) |
591 return false; | 589 return false; |
592 DCHECK_EQ(1u, media::VideoFrame::NumPlanes(video_frame->format())); | 590 DCHECK_EQ(1u, media::VideoFrame::NumPlanes(video_frame->format())); |
593 const gpu::MailboxHolder& mailbox_holder = video_frame->mailbox_holder(0); | 591 const gpu::MailboxHolder& mailbox_holder = video_frame->mailbox_holder(0); |
594 DCHECK((!is_remote_ && | 592 DCHECK((!is_remote_ && |
595 mailbox_holder.texture_target == GL_TEXTURE_EXTERNAL_OES) || | 593 mailbox_holder.texture_target == GL_TEXTURE_EXTERNAL_OES) || |
596 (is_remote_ && mailbox_holder.texture_target == GL_TEXTURE_2D)); | 594 (is_remote_ && mailbox_holder.texture_target == GL_TEXTURE_2D)); |
597 | 595 |
598 gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData()); | 596 gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData()); |
599 | 597 |
600 // Ensure the target of texture is set before copyTextureCHROMIUM, otherwise | 598 // Ensure the target of texture is set before copyTextureCHROMIUM, otherwise |
601 // an invalid texture target may be used for copy texture. | 599 // an invalid texture target may be used for copy texture. |
602 uint32_t src_texture = gl->CreateAndConsumeTextureCHROMIUM( | 600 uint32_t src_texture = gl->CreateAndConsumeTextureCHROMIUM( |
603 mailbox_holder.texture_target, mailbox_holder.mailbox.name); | 601 mailbox_holder.texture_target, mailbox_holder.mailbox.name); |
604 | 602 |
605 // Application itself needs to take care of setting the right flip_y | 603 // Application itself needs to take care of setting the right flip_y |
606 // value down to get the expected result. | 604 // value down to get the expected result. |
607 // flip_y==true means to reverse the video orientation while | 605 // flip_y==true means to reverse the video orientation while |
608 // flip_y==false means to keep the intrinsic orientation. | 606 // flip_y==false means to keep the intrinsic orientation. |
609 gl->CopyTextureCHROMIUM(src_texture, 0, texture, 0, internal_format, type, | |
610 flip_y, premultiply_alpha, false); | |
611 | 607 |
| 608 // The video's texture might be larger than the natural size because |
| 609 // the encoder might have had to round up to the size of a macroblock. |
| 610 // Make sure to only copy the natural size to avoid putting garbage |
| 611 // into the bottom of the destination texture. |
| 612 const gfx::Size& natural_size = video_frame->natural_size(); |
| 613 gl->CopySubTextureCHROMIUM(src_texture, 0, texture, 0, |
| 614 0, 0, 0, 0, |
| 615 natural_size.width(), natural_size.height(), |
| 616 flip_y, premultiply_alpha, false); |
612 gl->DeleteTextures(1, &src_texture); | 617 gl->DeleteTextures(1, &src_texture); |
613 gl->Flush(); | 618 gl->Flush(); |
614 | 619 |
615 SyncTokenClientImpl client(gl); | 620 SyncTokenClientImpl client(gl); |
616 video_frame->UpdateReleaseSyncToken(&client); | 621 video_frame->UpdateReleaseSyncToken(&client); |
617 return true; | 622 return true; |
618 } | 623 } |
619 | 624 |
620 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const { | 625 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const { |
621 DCHECK(main_thread_checker_.CalledOnValidThread()); | 626 DCHECK(main_thread_checker_.CalledOnValidThread()); |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1324 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
1320 switches::kDisableMediaSuspend)) { | 1325 switches::kDisableMediaSuspend)) { |
1321 return false; | 1326 return false; |
1322 } | 1327 } |
1323 | 1328 |
1324 return base::FeatureList::IsEnabled(media::kResumeBackgroundVideo) && | 1329 return base::FeatureList::IsEnabled(media::kResumeBackgroundVideo) && |
1325 hasAudio() && !isRemote() && delegate_ && delegate_->IsHidden(); | 1330 hasAudio() && !isRemote() && delegate_ && delegate_->IsHidden(); |
1326 } | 1331 } |
1327 | 1332 |
1328 } // namespace content | 1333 } // namespace content |
OLD | NEW |