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

Side by Side Diff: webkit/media/webmediaplayer_impl.cc

Issue 14199002: Send hardware video frames with mailboxes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix linux/windows hardware path Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "webkit/media/webmediaplayer_impl.h" 5 #include "webkit/media/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 bool premultiply_alpha, 708 bool premultiply_alpha,
709 bool flip_y) { 709 bool flip_y) {
710 scoped_refptr<media::VideoFrame> video_frame; 710 scoped_refptr<media::VideoFrame> video_frame;
711 { 711 {
712 base::AutoLock auto_lock(lock_); 712 base::AutoLock auto_lock(lock_);
713 video_frame = current_frame_; 713 video_frame = current_frame_;
714 } 714 }
715 if (video_frame && 715 if (video_frame &&
716 video_frame->format() == media::VideoFrame::NATIVE_TEXTURE && 716 video_frame->format() == media::VideoFrame::NATIVE_TEXTURE &&
717 video_frame->texture_target() == GL_TEXTURE_2D) { 717 video_frame->texture_target() == GL_TEXTURE_2D) {
718 uint32 source_texture = video_frame->texture_id(); 718 uint32 source_texture = web_graphics_context->createTexture();
719
720 web_graphics_context->waitSyncPoint(
721 video_frame->texture_mailbox_sync_point());
722 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture);
723 web_graphics_context->consumeTextureCHROMIUM(
724 GL_TEXTURE_2D, video_frame->texture_mailbox().name);
725
719 // The video is stored in a unmultiplied format, so premultiply 726 // The video is stored in a unmultiplied format, so premultiply
720 // if necessary. 727 // if necessary.
721 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, 728 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
722 premultiply_alpha); 729 premultiply_alpha);
723 // Application itself needs to take care of setting the right flip_y 730 // Application itself needs to take care of setting the right flip_y
724 // value down to get the expected result. 731 // value down to get the expected result.
725 // flip_y==true means to reverse the video orientation while 732 // flip_y==true means to reverse the video orientation while
726 // flip_y==false means to keep the intrinsic orientation. 733 // flip_y==false means to keep the intrinsic orientation.
727 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); 734 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y);
728 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, 735 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D,
729 source_texture, texture, level, internal_format); 736 source_texture, texture, level, internal_format);
730 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); 737 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false);
731 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, 738 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
732 false); 739 false);
740
741 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture);
742 web_graphics_context->produceTextureCHROMIUM(
743 GL_TEXTURE_2D, video_frame->texture_mailbox().name);
744 web_graphics_context->deleteTexture(source_texture);
745
733 // The flush() operation is not necessary here. It is kept since the 746 // The flush() operation is not necessary here. It is kept since the
734 // performance will be better when it is added than not. 747 // performance will be better when it is added than not.
735 web_graphics_context->flush(); 748 web_graphics_context->flush();
736 return true; 749 return true;
737 } 750 }
738 return false; 751 return false;
739 } 752 }
740 753
741 // Helper functions to report media EME related stats to UMA. They follow the 754 // Helper functions to report media EME related stats to UMA. They follow the
742 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and 755 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 set_decryptor_ready_cb, 1335 set_decryptor_ready_cb,
1323 base::Bind(&WebMediaPlayerImpl::FrameReady, base::Unretained(this)), 1336 base::Bind(&WebMediaPlayerImpl::FrameReady, base::Unretained(this)),
1324 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::SetOpaque), 1337 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::SetOpaque),
1325 true)); 1338 true));
1326 filter_collection->SetVideoRenderer(video_renderer.Pass()); 1339 filter_collection->SetVideoRenderer(video_renderer.Pass());
1327 1340
1328 return filter_collection.Pass(); 1341 return filter_collection.Pass();
1329 } 1342 }
1330 1343
1331 } // namespace webkit_media 1344 } // namespace webkit_media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698