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

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

Issue 105743004: Add gpu::MailboxHolder to hold state for a gpu::Mailbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: c301e01d Rebase. Created 6 years, 11 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 "content/renderer/media/webmediaplayer_impl.h" 5 #include "content/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 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 base::AutoLock auto_lock(lock_); 627 base::AutoLock auto_lock(lock_);
628 video_frame = current_frame_; 628 video_frame = current_frame_;
629 } 629 }
630 630
631 TRACE_EVENT0("media", "WebMediaPlayerImpl:copyVideoTextureToPlatformTexture"); 631 TRACE_EVENT0("media", "WebMediaPlayerImpl:copyVideoTextureToPlatformTexture");
632 632
633 if (!video_frame) 633 if (!video_frame)
634 return false; 634 return false;
635 if (video_frame->format() != media::VideoFrame::NATIVE_TEXTURE) 635 if (video_frame->format() != media::VideoFrame::NATIVE_TEXTURE)
636 return false; 636 return false;
637 if (video_frame->texture_target() != GL_TEXTURE_2D) 637
638 gpu::MailboxHolder* mailbox_holder = video_frame->mailbox_holder();
639 if (mailbox_holder->texture_target != GL_TEXTURE_2D)
638 return false; 640 return false;
639 641
640 // Since this method changes which texture is bound to the TEXTURE_2D target, 642 // Since this method changes which texture is bound to the TEXTURE_2D target,
641 // ideally it would restore the currently-bound texture before returning. 643 // ideally it would restore the currently-bound texture before returning.
642 // The cost of getIntegerv is sufficiently high, however, that we want to 644 // The cost of getIntegerv is sufficiently high, however, that we want to
643 // avoid it in user builds. As a result assume (below) that |texture| is 645 // avoid it in user builds. As a result assume (below) that |texture| is
644 // bound when this method is called, and only verify this fact when 646 // bound when this method is called, and only verify this fact when
645 // DCHECK_IS_ON. 647 // DCHECK_IS_ON.
646 if (DCHECK_IS_ON()) { 648 if (DCHECK_IS_ON()) {
647 GLint bound_texture = 0; 649 GLint bound_texture = 0;
648 web_graphics_context->getIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); 650 web_graphics_context->getIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture);
649 DCHECK_EQ(static_cast<GLuint>(bound_texture), texture); 651 DCHECK_EQ(static_cast<GLuint>(bound_texture), texture);
650 } 652 }
651 653
652 media::VideoFrame::MailboxHolder* mailbox_holder =
653 video_frame->texture_mailbox();
654
655 uint32 source_texture = web_graphics_context->createTexture(); 654 uint32 source_texture = web_graphics_context->createTexture();
656 655
657 web_graphics_context->waitSyncPoint(mailbox_holder->sync_point()); 656 web_graphics_context->waitSyncPoint(mailbox_holder->sync_point);
658 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture); 657 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture);
659 web_graphics_context->consumeTextureCHROMIUM(GL_TEXTURE_2D, 658 web_graphics_context->consumeTextureCHROMIUM(GL_TEXTURE_2D,
660 mailbox_holder->mailbox().name); 659 mailbox_holder->mailbox.name);
661 660
662 // The video is stored in a unmultiplied format, so premultiply 661 // The video is stored in a unmultiplied format, so premultiply
663 // if necessary. 662 // if necessary.
664 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, 663 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
665 premultiply_alpha); 664 premultiply_alpha);
666 // Application itself needs to take care of setting the right flip_y 665 // Application itself needs to take care of setting the right flip_y
667 // value down to get the expected result. 666 // value down to get the expected result.
668 // flip_y==true means to reverse the video orientation while 667 // flip_y==true means to reverse the video orientation while
669 // flip_y==false means to keep the intrinsic orientation. 668 // flip_y==false means to keep the intrinsic orientation.
670 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); 669 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y);
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 // The |current_frame_| wasn't painted, it is being replaced, and we haven't 1301 // The |current_frame_| wasn't painted, it is being replaced, and we haven't
1303 // even gotten the chance to request a repaint for it yet. Mark it as dropped. 1302 // even gotten the chance to request a repaint for it yet. Mark it as dropped.
1304 TRACE_EVENT0("media", "WebMediaPlayerImpl:frameDropped"); 1303 TRACE_EVENT0("media", "WebMediaPlayerImpl:frameDropped");
1305 DVLOG(1) << "Frame dropped before being painted: " 1304 DVLOG(1) << "Frame dropped before being painted: "
1306 << current_frame_->GetTimestamp().InSecondsF(); 1305 << current_frame_->GetTimestamp().InSecondsF();
1307 if (frames_dropped_before_paint_ < kuint32max) 1306 if (frames_dropped_before_paint_ < kuint32max)
1308 frames_dropped_before_paint_++; 1307 frames_dropped_before_paint_++;
1309 } 1308 }
1310 1309
1311 } // namespace content 1310 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698