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

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

Issue 371463009: Making use of bindless variants mailbox produce/consume on remainders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix cc tests Created 6 years, 5 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 <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
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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 VideoFrame::CreateHoleFrame(natural_size_); 1010 VideoFrame::CreateHoleFrame(natural_size_);
1018 SetCurrentFrameInternal(new_frame); 1011 SetCurrentFrameInternal(new_frame);
1019 // Force the client to grab the hole frame. 1012 // Force the client to grab the hole frame.
1020 client_->repaint(); 1013 client_->repaint();
1021 } 1014 }
1022 #else 1015 #else
1023 NOTIMPLEMENTED() << "Hole punching not supported without VIDEO_HOLE flag"; 1016 NOTIMPLEMENTED() << "Hole punching not supported without VIDEO_HOLE flag";
1024 #endif // defined(VIDEO_HOLE) 1017 #endif // defined(VIDEO_HOLE)
1025 } else if (!is_remote_ && texture_id_) { 1018 } else if (!is_remote_ && texture_id_) {
1026 GLES2Interface* gl = stream_texture_factory_->ContextGL(); 1019 GLES2Interface* gl = stream_texture_factory_->ContextGL();
1027 GLuint texture_id_ref = 0;
1028 gl->GenTextures(1, &texture_id_ref);
1029 GLuint texture_target = kGLTextureExternalOES; 1020 GLuint texture_target = kGLTextureExternalOES;
1030 gl->BindTexture(texture_target, texture_id_ref); 1021 GLuint texture_id_ref = gl->CreateAndConsumeTextureCHROMIUM(
1031 gl->ConsumeTextureCHROMIUM(texture_target, texture_mailbox_.name); 1022 texture_target, texture_mailbox_.name);
1032 gl->Flush(); 1023 gl->Flush();
1033 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM(); 1024 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM();
1034 1025
1035 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture( 1026 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture(
1036 make_scoped_ptr(new gpu::MailboxHolder( 1027 make_scoped_ptr(new gpu::MailboxHolder(
1037 texture_mailbox_, texture_target, texture_mailbox_sync_point)), 1028 texture_mailbox_, texture_target, texture_mailbox_sync_point)),
1038 media::BindToCurrentLoop(base::Bind( 1029 media::BindToCurrentLoop(base::Bind(
1039 &OnReleaseTexture, stream_texture_factory_, texture_id_ref)), 1030 &OnReleaseTexture, stream_texture_factory_, texture_id_ref)),
1040 natural_size_, 1031 natural_size_,
1041 gfx::Rect(natural_size_), 1032 gfx::Rect(natural_size_),
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 player_manager_->EnterFullscreen(player_id_, frame_); 1528 player_manager_->EnterFullscreen(player_id_, frame_);
1538 SetNeedsEstablishPeer(false); 1529 SetNeedsEstablishPeer(false);
1539 } 1530 }
1540 } 1531 }
1541 1532
1542 bool WebMediaPlayerAndroid::canEnterFullscreen() const { 1533 bool WebMediaPlayerAndroid::canEnterFullscreen() const {
1543 return player_manager_->CanEnterFullscreen(frame_); 1534 return player_manager_->CanEnterFullscreen(frame_);
1544 } 1535 }
1545 1536
1546 } // namespace content 1537 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698