OLD | NEW |
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 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 bool premultiply_alpha, | 744 bool premultiply_alpha, |
745 bool flip_y) { | 745 bool flip_y) { |
746 scoped_refptr<media::VideoFrame> video_frame; | 746 scoped_refptr<media::VideoFrame> video_frame; |
747 { | 747 { |
748 base::AutoLock auto_lock(lock_); | 748 base::AutoLock auto_lock(lock_); |
749 video_frame = current_frame_; | 749 video_frame = current_frame_; |
750 } | 750 } |
751 if (video_frame && | 751 if (video_frame && |
752 video_frame->format() == media::VideoFrame::NATIVE_TEXTURE && | 752 video_frame->format() == media::VideoFrame::NATIVE_TEXTURE && |
753 video_frame->texture_target() == GL_TEXTURE_2D) { | 753 video_frame->texture_target() == GL_TEXTURE_2D) { |
754 uint32 source_texture = video_frame->texture_id(); | 754 uint32 source_texture = web_graphics_context->createTexture(); |
| 755 |
| 756 web_graphics_context->waitSyncPoint( |
| 757 video_frame->texture_mailbox_sync_point()); |
| 758 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture); |
| 759 web_graphics_context->consumeTextureCHROMIUM( |
| 760 GL_TEXTURE_2D, video_frame->texture_mailbox().name); |
| 761 |
755 // The video is stored in a unmultiplied format, so premultiply | 762 // The video is stored in a unmultiplied format, so premultiply |
756 // if necessary. | 763 // if necessary. |
757 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | 764 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, |
758 premultiply_alpha); | 765 premultiply_alpha); |
759 // Application itself needs to take care of setting the right flip_y | 766 // Application itself needs to take care of setting the right flip_y |
760 // value down to get the expected result. | 767 // value down to get the expected result. |
761 // flip_y==true means to reverse the video orientation while | 768 // flip_y==true means to reverse the video orientation while |
762 // flip_y==false means to keep the intrinsic orientation. | 769 // flip_y==false means to keep the intrinsic orientation. |
763 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); | 770 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); |
764 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, | 771 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, |
765 source_texture, texture, level, internal_format); | 772 source_texture, texture, level, internal_format); |
766 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); | 773 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); |
767 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | 774 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, |
768 false); | 775 false); |
| 776 |
| 777 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture); |
| 778 web_graphics_context->produceTextureCHROMIUM( |
| 779 GL_TEXTURE_2D, video_frame->texture_mailbox().name); |
| 780 web_graphics_context->deleteTexture(source_texture); |
| 781 |
769 // The flush() operation is not necessary here. It is kept since the | 782 // The flush() operation is not necessary here. It is kept since the |
770 // performance will be better when it is added than not. | 783 // performance will be better when it is added than not. |
771 web_graphics_context->flush(); | 784 web_graphics_context->flush(); |
772 return true; | 785 return true; |
773 } | 786 } |
774 return false; | 787 return false; |
775 } | 788 } |
776 | 789 |
777 // Helper functions to report media EME related stats to UMA. They follow the | 790 // Helper functions to report media EME related stats to UMA. They follow the |
778 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and | 791 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 | 1293 |
1281 if (pending_repaint_) | 1294 if (pending_repaint_) |
1282 return; | 1295 return; |
1283 | 1296 |
1284 pending_repaint_ = true; | 1297 pending_repaint_ = true; |
1285 main_loop_->PostTask(FROM_HERE, base::Bind( | 1298 main_loop_->PostTask(FROM_HERE, base::Bind( |
1286 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); | 1299 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); |
1287 } | 1300 } |
1288 | 1301 |
1289 } // namespace webkit_media | 1302 } // namespace webkit_media |
OLD | NEW |