| 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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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->deleteTexture(source_texture); |
| 631 |
| 632 // The flush() operation is not necessary here. It is kept since the |
| 633 // performance will be better when it is added than not. |
| 634 web_graphics_context->flush(); |
| 635 return true; |
| 617 } | 636 } |
| 618 | 637 |
| 619 // Helper functions to report media EME related stats to UMA. They follow the | 638 // Helper functions to report media EME related stats to UMA. They follow the |
| 620 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and | 639 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and |
| 621 // UMA_HISTOGRAM_COUNTS. The reason that we cannot use those macros directly is | 640 // 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' | 641 // that UMA_* macros require the names to be constant throughout the process' |
| 623 // lifetime. | 642 // lifetime. |
| 624 static void EmeUMAHistogramEnumeration(const std::string& key_system, | 643 static void EmeUMAHistogramEnumeration(const std::string& key_system, |
| 625 const std::string& method, | 644 const std::string& method, |
| 626 int sample, | 645 int sample, |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 | 1228 |
| 1210 if (pending_repaint_) | 1229 if (pending_repaint_) |
| 1211 return; | 1230 return; |
| 1212 | 1231 |
| 1213 pending_repaint_ = true; | 1232 pending_repaint_ = true; |
| 1214 main_loop_->PostTask(FROM_HERE, base::Bind( | 1233 main_loop_->PostTask(FROM_HERE, base::Bind( |
| 1215 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); | 1234 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); |
| 1216 } | 1235 } |
| 1217 | 1236 |
| 1218 } // namespace webkit_media | 1237 } // namespace webkit_media |
| OLD | NEW |