OLD | NEW |
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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 unsigned int level, | 582 unsigned int level, |
583 unsigned int internal_format, | 583 unsigned int internal_format, |
584 unsigned int type, | 584 unsigned int type, |
585 bool premultiply_alpha, | 585 bool premultiply_alpha, |
586 bool flip_y) { | 586 bool flip_y) { |
587 scoped_refptr<media::VideoFrame> video_frame; | 587 scoped_refptr<media::VideoFrame> video_frame; |
588 { | 588 { |
589 base::AutoLock auto_lock(lock_); | 589 base::AutoLock auto_lock(lock_); |
590 video_frame = current_frame_; | 590 video_frame = current_frame_; |
591 } | 591 } |
592 if (video_frame.get() && | 592 |
593 video_frame->format() == media::VideoFrame::NATIVE_TEXTURE && | 593 if (!video_frame.get()) |
594 video_frame->texture_target() == GL_TEXTURE_2D) { | 594 return false; |
595 uint32 source_texture = video_frame->texture_id(); | 595 if (video_frame->format() != media::VideoFrame::NATIVE_TEXTURE) |
596 // The video is stored in a unmultiplied format, so premultiply | 596 return false; |
597 // if necessary. | 597 if (video_frame->texture_target() != GL_TEXTURE_2D) |
598 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | 598 return false; |
599 premultiply_alpha); | 599 |
600 // Application itself needs to take care of setting the right flip_y | 600 scoped_refptr<media::VideoFrame::MailboxHolder> mailbox_holder = |
601 // value down to get the expected result. | 601 video_frame->texture_mailbox(); |
602 // flip_y==true means to reverse the video orientation while | 602 |
603 // flip_y==false means to keep the intrinsic orientation. | 603 uint32 source_texture = web_graphics_context->createTexture(); |
604 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); | 604 |
605 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, | 605 web_graphics_context->waitSyncPoint(mailbox_holder->sync_point()); |
606 source_texture, texture, level, internal_format, type); | 606 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture); |
607 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); | 607 web_graphics_context->consumeTextureCHROMIUM(GL_TEXTURE_2D, |
608 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | 608 mailbox_holder->mailbox().name); |
609 false); | 609 |
610 // The flush() operation is not necessary here. It is kept since the | 610 // The video is stored in a unmultiplied format, so premultiply |
611 // performance will be better when it is added than not. | 611 // if necessary. |
612 web_graphics_context->flush(); | 612 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, |
613 return true; | 613 premultiply_alpha); |
614 } | 614 // Application itself needs to take care of setting the right flip_y |
615 return false; | 615 // value down to get the expected result. |
| 616 // flip_y==true means to reverse the video orientation while |
| 617 // flip_y==false means to keep the intrinsic orientation. |
| 618 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); |
| 619 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, |
| 620 source_texture, |
| 621 texture, |
| 622 level, |
| 623 internal_format, |
| 624 type); |
| 625 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); |
| 626 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, |
| 627 false); |
| 628 |
| 629 web_graphics_context->deleteTexture(source_texture); |
| 630 |
| 631 // The flush() operation is not necessary here. It is kept since the |
| 632 // performance will be better when it is added than not. |
| 633 web_graphics_context->flush(); |
| 634 return true; |
616 } | 635 } |
617 | 636 |
618 // Helper functions to report media EME related stats to UMA. They follow the | 637 // Helper functions to report media EME related stats to UMA. They follow the |
619 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and | 638 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and |
620 // UMA_HISTOGRAM_COUNTS. The reason that we cannot use those macros directly is | 639 // UMA_HISTOGRAM_COUNTS. The reason that we cannot use those macros directly is |
621 // that UMA_* macros require the names to be constant throughout the process' | 640 // that UMA_* macros require the names to be constant throughout the process' |
622 // lifetime. | 641 // lifetime. |
623 static void EmeUMAHistogramEnumeration(const std::string& key_system, | 642 static void EmeUMAHistogramEnumeration(const std::string& key_system, |
624 const std::string& method, | 643 const std::string& method, |
625 int sample, | 644 int sample, |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1198 | 1217 |
1199 if (pending_repaint_) | 1218 if (pending_repaint_) |
1200 return; | 1219 return; |
1201 | 1220 |
1202 pending_repaint_ = true; | 1221 pending_repaint_ = true; |
1203 main_loop_->PostTask(FROM_HERE, base::Bind( | 1222 main_loop_->PostTask(FROM_HERE, base::Bind( |
1204 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); | 1223 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); |
1205 } | 1224 } |
1206 | 1225 |
1207 } // namespace webkit_media | 1226 } // namespace webkit_media |
OLD | NEW |