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

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

Issue 14199002: Send hardware video frames with mailboxes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: video-mailbox: rebase Created 7 years, 6 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 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 "webkit/renderer/media/webmediaplayer_impl.h" 5 #include "webkit/renderer/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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 unsigned int level, 583 unsigned int level,
584 unsigned int internal_format, 584 unsigned int internal_format,
585 unsigned int type, 585 unsigned int type,
586 bool premultiply_alpha, 586 bool premultiply_alpha,
587 bool flip_y) { 587 bool flip_y) {
588 scoped_refptr<media::VideoFrame> video_frame; 588 scoped_refptr<media::VideoFrame> video_frame;
589 { 589 {
590 base::AutoLock auto_lock(lock_); 590 base::AutoLock auto_lock(lock_);
591 video_frame = current_frame_; 591 video_frame = current_frame_;
592 } 592 }
593 if (video_frame.get() && 593
594 video_frame->format() == media::VideoFrame::NATIVE_TEXTURE && 594 if (!video_frame.get())
595 video_frame->texture_target() == GL_TEXTURE_2D) { 595 return false;
596 uint32 source_texture = video_frame->texture_id(); 596 if (video_frame->format() != media::VideoFrame::NATIVE_TEXTURE)
597 // The video is stored in a unmultiplied format, so premultiply 597 return false;
598 // if necessary. 598 if (video_frame->texture_target() != GL_TEXTURE_2D)
599 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, 599 return false;
600 premultiply_alpha); 600
601 // Application itself needs to take care of setting the right flip_y 601 scoped_refptr<media::VideoFrame::MailboxHolder> mailbox_holder =
602 // value down to get the expected result. 602 video_frame->texture_mailbox();
603 // flip_y==true means to reverse the video orientation while 603
604 // flip_y==false means to keep the intrinsic orientation. 604 uint32 source_texture = web_graphics_context->createTexture();
605 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); 605
606 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, 606 web_graphics_context->waitSyncPoint(mailbox_holder->sync_point());
607 source_texture, texture, level, internal_format, type); 607 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture);
608 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); 608 web_graphics_context->consumeTextureCHROMIUM(GL_TEXTURE_2D,
609 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, 609 mailbox_holder->mailbox().name);
610 false); 610
611 // The flush() operation is not necessary here. It is kept since the 611 // The video is stored in a unmultiplied format, so premultiply
612 // performance will be better when it is added than not. 612 // if necessary.
613 web_graphics_context->flush(); 613 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
614 return true; 614 premultiply_alpha);
615 } 615 // Application itself needs to take care of setting the right flip_y
616 return false; 616 // value down to get the expected result.
617 // flip_y==true means to reverse the video orientation while
618 // flip_y==false means to keep the intrinsic orientation.
619 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y);
620 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D,
621 source_texture,
622 texture,
623 level,
624 internal_format,
625 type);
626 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false);
627 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
628 false);
629
630 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture);
631 web_graphics_context->produceTextureCHROMIUM(GL_TEXTURE_2D,
632 mailbox_holder->mailbox().name);
piman 2013/06/14 21:47:29 no need for this produce (which ends up being a no
danakj 2013/06/14 21:54:39 Done, leftovers from before.
633 web_graphics_context->deleteTexture(source_texture);
634
635 // The flush() operation is not necessary here. It is kept since the
636 // performance will be better when it is added than not.
637 web_graphics_context->flush();
638 return true;
617 } 639 }
618 640
619 // Helper functions to report media EME related stats to UMA. They follow the 641 // Helper functions to report media EME related stats to UMA. They follow the
620 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and 642 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and
621 // UMA_HISTOGRAM_COUNTS. The reason that we cannot use those macros directly is 643 // UMA_HISTOGRAM_COUNTS. The reason that we cannot use those macros directly is
622 // that UMA_* macros require the names to be constant throughout the process' 644 // that UMA_* macros require the names to be constant throughout the process'
623 // lifetime. 645 // lifetime.
624 static void EmeUMAHistogramEnumeration(const std::string& key_system, 646 static void EmeUMAHistogramEnumeration(const std::string& key_system,
625 const std::string& method, 647 const std::string& method,
626 int sample, 648 int sample,
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 1234
1213 if (pending_repaint_) 1235 if (pending_repaint_)
1214 return; 1236 return;
1215 1237
1216 pending_repaint_ = true; 1238 pending_repaint_ = true;
1217 main_loop_->PostTask(FROM_HERE, base::Bind( 1239 main_loop_->PostTask(FROM_HERE, base::Bind(
1218 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); 1240 &WebMediaPlayerImpl::Repaint, AsWeakPtr()));
1219 } 1241 }
1220 1242
1221 } // namespace webkit_media 1243 } // namespace webkit_media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698