| 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 <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 // For hidden video element (with style "display:none"), ensure the texture | 499 // For hidden video element (with style "display:none"), ensure the texture |
| 500 // size is set. | 500 // size is set. |
| 501 if (!is_remote_ && | 501 if (!is_remote_ && |
| 502 (cached_stream_texture_size_.width != natural_size_.width || | 502 (cached_stream_texture_size_.width != natural_size_.width || |
| 503 cached_stream_texture_size_.height != natural_size_.height)) { | 503 cached_stream_texture_size_.height != natural_size_.height)) { |
| 504 stream_texture_factory_->SetStreamTextureSize( | 504 stream_texture_factory_->SetStreamTextureSize( |
| 505 stream_id_, gfx::Size(natural_size_.width, natural_size_.height)); | 505 stream_id_, gfx::Size(natural_size_.width, natural_size_.height)); |
| 506 cached_stream_texture_size_ = natural_size_; | 506 cached_stream_texture_size_ = natural_size_; |
| 507 } | 507 } |
| 508 | 508 |
| 509 uint32 source_texture = web_graphics_context->createTexture(); | |
| 510 web_graphics_context->waitSyncPoint(mailbox_holder->sync_point); | 509 web_graphics_context->waitSyncPoint(mailbox_holder->sync_point); |
| 511 | 510 |
| 512 // Ensure the target of texture is set before copyTextureCHROMIUM, otherwise | 511 // Ensure the target of texture is set before copyTextureCHROMIUM, otherwise |
| 513 // an invalid texture target may be used for copy texture. | 512 // an invalid texture target may be used for copy texture. |
| 514 web_graphics_context->bindTexture(mailbox_holder->texture_target, | 513 uint32 source_texture = web_graphics_context->createAndConsumeTextureCHROMIUM( |
| 515 source_texture); | 514 mailbox_holder->texture_target, mailbox_holder->mailbox.name); |
| 516 web_graphics_context->consumeTextureCHROMIUM(mailbox_holder->texture_target, | |
| 517 mailbox_holder->mailbox.name); | |
| 518 | 515 |
| 519 // The video is stored in an unmultiplied format, so premultiply if | 516 // The video is stored in an unmultiplied format, so premultiply if |
| 520 // necessary. | 517 // necessary. |
| 521 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | 518 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, |
| 522 premultiply_alpha); | 519 premultiply_alpha); |
| 523 | 520 |
| 524 // Application itself needs to take care of setting the right flip_y | 521 // Application itself needs to take care of setting the right flip_y |
| 525 // value down to get the expected result. | 522 // value down to get the expected result. |
| 526 // flip_y==true means to reverse the video orientation while | 523 // flip_y==true means to reverse the video orientation while |
| 527 // flip_y==false means to keep the intrinsic orientation. | 524 // flip_y==false means to keep the intrinsic orientation. |
| 528 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); | 525 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); |
| 529 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, source_texture, | 526 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, source_texture, |
| 530 texture, level, internal_format, | 527 texture, level, internal_format, |
| 531 type); | 528 type); |
| 532 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); | 529 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); |
| 533 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | 530 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, |
| 534 false); | 531 false); |
| 535 | 532 |
| 536 if (mailbox_holder->texture_target == GL_TEXTURE_EXTERNAL_OES) | |
| 537 web_graphics_context->bindTexture(GL_TEXTURE_EXTERNAL_OES, 0); | |
| 538 else | |
| 539 web_graphics_context->bindTexture(GL_TEXTURE_2D, texture); | |
| 540 web_graphics_context->deleteTexture(source_texture); | 533 web_graphics_context->deleteTexture(source_texture); |
| 541 web_graphics_context->flush(); | 534 web_graphics_context->flush(); |
| 542 video_frame->AppendReleaseSyncPoint(web_graphics_context->insertSyncPoint()); | 535 video_frame->AppendReleaseSyncPoint(web_graphics_context->insertSyncPoint()); |
| 543 return true; | 536 return true; |
| 544 } | 537 } |
| 545 | 538 |
| 546 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const { | 539 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const { |
| 547 if (info_loader_) | 540 if (info_loader_) |
| 548 return info_loader_->HasSingleOrigin(); | 541 return info_loader_->HasSingleOrigin(); |
| 549 // The info loader may have failed. | 542 // The info loader may have failed. |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 VideoFrame::CreateHoleFrame(natural_size_); | 1015 VideoFrame::CreateHoleFrame(natural_size_); |
| 1023 SetCurrentFrameInternal(new_frame); | 1016 SetCurrentFrameInternal(new_frame); |
| 1024 // Force the client to grab the hole frame. | 1017 // Force the client to grab the hole frame. |
| 1025 client_->repaint(); | 1018 client_->repaint(); |
| 1026 } | 1019 } |
| 1027 #else | 1020 #else |
| 1028 NOTIMPLEMENTED() << "Hole punching not supported without VIDEO_HOLE flag"; | 1021 NOTIMPLEMENTED() << "Hole punching not supported without VIDEO_HOLE flag"; |
| 1029 #endif // defined(VIDEO_HOLE) | 1022 #endif // defined(VIDEO_HOLE) |
| 1030 } else if (!is_remote_ && texture_id_) { | 1023 } else if (!is_remote_ && texture_id_) { |
| 1031 GLES2Interface* gl = stream_texture_factory_->ContextGL(); | 1024 GLES2Interface* gl = stream_texture_factory_->ContextGL(); |
| 1032 GLuint texture_id_ref = 0; | |
| 1033 gl->GenTextures(1, &texture_id_ref); | |
| 1034 GLuint texture_target = kGLTextureExternalOES; | 1025 GLuint texture_target = kGLTextureExternalOES; |
| 1035 gl->BindTexture(texture_target, texture_id_ref); | 1026 GLuint texture_id_ref = gl->CreateAndConsumeTextureCHROMIUM( |
| 1036 gl->ConsumeTextureCHROMIUM(texture_target, texture_mailbox_.name); | 1027 texture_target, texture_mailbox_.name); |
| 1037 gl->Flush(); | 1028 gl->Flush(); |
| 1038 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM(); | 1029 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM(); |
| 1039 | 1030 |
| 1040 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture( | 1031 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture( |
| 1041 make_scoped_ptr(new gpu::MailboxHolder( | 1032 make_scoped_ptr(new gpu::MailboxHolder( |
| 1042 texture_mailbox_, texture_target, texture_mailbox_sync_point)), | 1033 texture_mailbox_, texture_target, texture_mailbox_sync_point)), |
| 1043 media::BindToCurrentLoop(base::Bind( | 1034 media::BindToCurrentLoop(base::Bind( |
| 1044 &OnReleaseTexture, stream_texture_factory_, texture_id_ref)), | 1035 &OnReleaseTexture, stream_texture_factory_, texture_id_ref)), |
| 1045 natural_size_, | 1036 natural_size_, |
| 1046 gfx::Rect(natural_size_), | 1037 gfx::Rect(natural_size_), |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 | 1537 |
| 1547 void WebMediaPlayerAndroid::exitFullscreen() { | 1538 void WebMediaPlayerAndroid::exitFullscreen() { |
| 1548 player_manager_->ExitFullscreen(player_id_); | 1539 player_manager_->ExitFullscreen(player_id_); |
| 1549 } | 1540 } |
| 1550 | 1541 |
| 1551 bool WebMediaPlayerAndroid::canEnterFullscreen() const { | 1542 bool WebMediaPlayerAndroid::canEnterFullscreen() const { |
| 1552 return player_manager_->CanEnterFullscreen(frame_); | 1543 return player_manager_->CanEnterFullscreen(frame_); |
| 1553 } | 1544 } |
| 1554 | 1545 |
| 1555 } // namespace content | 1546 } // namespace content |
| OLD | NEW |