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

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: Ifdefed 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
« media/base/video_frame.h ('K') | « media/video/picture.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 bool premultiply_alpha, 734 bool premultiply_alpha,
735 bool flip_y) { 735 bool flip_y) {
736 scoped_refptr<media::VideoFrame> video_frame; 736 scoped_refptr<media::VideoFrame> video_frame;
737 { 737 {
738 base::AutoLock auto_lock(lock_); 738 base::AutoLock auto_lock(lock_);
739 video_frame = current_frame_; 739 video_frame = current_frame_;
740 } 740 }
741 if (video_frame && 741 if (video_frame &&
742 video_frame->format() == media::VideoFrame::NATIVE_TEXTURE && 742 video_frame->format() == media::VideoFrame::NATIVE_TEXTURE &&
743 video_frame->texture_target() == GL_TEXTURE_2D) { 743 video_frame->texture_target() == GL_TEXTURE_2D) {
744 #ifndef VIDEO_FRAME_MAILBOX
744 uint32 source_texture = video_frame->texture_id(); 745 uint32 source_texture = video_frame->texture_id();
746 #else
747 uint32 source_texture = web_graphics_context->createTexture();
748
749 web_graphics_context->waitSyncPoint(
750 video_frame->texture_mailbox_sync_point());
751 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture);
752 web_graphics_context->consumeTextureCHROMIUM(
753 GL_TEXTURE_2D, video_frame->texture_mailbox().name);
754 #endif
755
745 // The video is stored in a unmultiplied format, so premultiply 756 // The video is stored in a unmultiplied format, so premultiply
746 // if necessary. 757 // if necessary.
747 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, 758 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
748 premultiply_alpha); 759 premultiply_alpha);
749 // Application itself needs to take care of setting the right flip_y 760 // Application itself needs to take care of setting the right flip_y
750 // value down to get the expected result. 761 // value down to get the expected result.
751 // flip_y==true means to reverse the video orientation while 762 // flip_y==true means to reverse the video orientation while
752 // flip_y==false means to keep the intrinsic orientation. 763 // flip_y==false means to keep the intrinsic orientation.
753 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); 764 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y);
754 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, 765 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D,
755 source_texture, texture, level, internal_format); 766 source_texture, texture, level, internal_format);
756 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); 767 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false);
757 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, 768 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
758 false); 769 false);
770
771 #ifdef VIDEO_FRAME_MAILBOX
scherkus (not reviewing) 2013/04/17 20:09:34 nit: doesn't chromium prefer #if defined(FOO) / #i
danakj 2013/04/17 20:12:37 Does it? The google style guide and chromium style
scherkus (not reviewing) 2013/04/17 20:16:58 yeah I don't really care enough to have it changed
772 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture);
773 web_graphics_context->produceTextureCHROMIUM(
774 GL_TEXTURE_2D, video_frame->texture_mailbox().name);
775 web_graphics_context->deleteTexture(source_texture);
776 #endif
777
759 // The flush() operation is not necessary here. It is kept since the 778 // The flush() operation is not necessary here. It is kept since the
760 // performance will be better when it is added than not. 779 // performance will be better when it is added than not.
761 web_graphics_context->flush(); 780 web_graphics_context->flush();
762 return true; 781 return true;
763 } 782 }
764 return false; 783 return false;
765 } 784 }
766 785
767 // Helper functions to report media EME related stats to UMA. They follow the 786 // Helper functions to report media EME related stats to UMA. They follow the
768 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and 787 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 1289
1271 if (pending_repaint_) 1290 if (pending_repaint_)
1272 return; 1291 return;
1273 1292
1274 pending_repaint_ = true; 1293 pending_repaint_ = true;
1275 main_loop_->PostTask(FROM_HERE, base::Bind( 1294 main_loop_->PostTask(FROM_HERE, base::Bind(
1276 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); 1295 &WebMediaPlayerImpl::Repaint, AsWeakPtr()));
1277 } 1296 }
1278 1297
1279 } // namespace webkit_media 1298 } // namespace webkit_media
OLDNEW
« media/base/video_frame.h ('K') | « media/video/picture.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698