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> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/message_loop_proxy.h" | 14 #include "base/message_loop_proxy.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
18 #include "gpu/GLES2/gl2extchromium.h" | |
18 #include "media/audio/null_audio_sink.h" | 19 #include "media/audio/null_audio_sink.h" |
19 #include "media/base/bind_to_loop.h" | 20 #include "media/base/bind_to_loop.h" |
20 #include "media/base/filter_collection.h" | 21 #include "media/base/filter_collection.h" |
21 #include "media/base/limits.h" | 22 #include "media/base/limits.h" |
22 #include "media/base/media_log.h" | 23 #include "media/base/media_log.h" |
23 #include "media/base/pipeline.h" | 24 #include "media/base/pipeline.h" |
24 #include "media/base/video_frame.h" | 25 #include "media/base/video_frame.h" |
25 #include "media/filters/audio_renderer_impl.h" | 26 #include "media/filters/audio_renderer_impl.h" |
26 #include "media/filters/chunk_demuxer.h" | 27 #include "media/filters/chunk_demuxer.h" |
27 #include "media/filters/video_renderer_base.h" | 28 #include "media/filters/video_renderer_base.h" |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
663 void WebMediaPlayerImpl::putCurrentFrame( | 664 void WebMediaPlayerImpl::putCurrentFrame( |
664 WebKit::WebVideoFrame* web_video_frame) { | 665 WebKit::WebVideoFrame* web_video_frame) { |
665 if (!accelerated_compositing_reported_) { | 666 if (!accelerated_compositing_reported_) { |
666 accelerated_compositing_reported_ = true; | 667 accelerated_compositing_reported_ = true; |
667 DCHECK(frame_->view()->isAcceleratedCompositingActive()); | 668 DCHECK(frame_->view()->isAcceleratedCompositingActive()); |
668 UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive", true); | 669 UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive", true); |
669 } | 670 } |
670 delete web_video_frame; | 671 delete web_video_frame; |
671 } | 672 } |
672 | 673 |
674 bool WebMediaPlayerImpl::copyVideoTextureToPlatformTexture( | |
675 WebKit::WebGraphicsContext3D* web_graphics_context, | |
676 unsigned int texture, | |
677 unsigned int level, | |
678 unsigned int internal_format, | |
679 bool premultiply_alpha, | |
680 bool flip_y) { | |
681 scoped_refptr<media::VideoFrame> video_frame; | |
682 { | |
683 base::AutoLock auto_lock(lock_); | |
684 video_frame = current_frame_; | |
685 } | |
686 if (video_frame && | |
687 video_frame->format() == media::VideoFrame::NATIVE_TEXTURE && | |
688 video_frame->texture_target() == GL_TEXTURE_2D) { | |
689 uint32 source_texture = video_frame->texture_id(); | |
690 // The video is stored in a unmultiplied format, so premultiply | |
691 // if necessary. | |
692 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | |
693 premultiply_alpha); | |
694 // Application itself needs to take care of setting the right flip_y | |
695 // value down to get the expected result. | |
696 // flip_y==true means to reverse the video orientation while | |
697 // flip_y==false means to keep the intrinsic orientation. | |
698 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); | |
699 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, | |
700 source_texture, texture, level, internal_format); | |
701 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); | |
702 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | |
703 false); | |
704 web_graphics_context->flush(); | |
Ken Russell (switch to Gerrit)
2013/03/12 02:08:13
This flush shouldn't be necessary.
Jun Jiang
2013/03/12 13:38:38
Could we keep the flush operation since the flush
Ken Russell (switch to Gerrit)
2013/03/12 22:17:46
Leaving it is fine, but please add a comment indic
| |
705 return true; | |
706 } | |
707 return false; | |
708 } | |
709 | |
673 // Helper enum for reporting generateKeyRequest/addKey histograms. | 710 // Helper enum for reporting generateKeyRequest/addKey histograms. |
674 enum MediaKeyException { | 711 enum MediaKeyException { |
675 kUnknownResultId, | 712 kUnknownResultId, |
676 kSuccess, | 713 kSuccess, |
677 kKeySystemNotSupported, | 714 kKeySystemNotSupported, |
678 kInvalidPlayerState, | 715 kInvalidPlayerState, |
679 kMaxMediaKeyException | 716 kMaxMediaKeyException |
680 }; | 717 }; |
681 | 718 |
682 static MediaKeyException MediaKeyExceptionForUMA( | 719 static MediaKeyException MediaKeyExceptionForUMA( |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1158 | 1195 |
1159 if (pending_repaint_) | 1196 if (pending_repaint_) |
1160 return; | 1197 return; |
1161 | 1198 |
1162 pending_repaint_ = true; | 1199 pending_repaint_ = true; |
1163 main_loop_->PostTask(FROM_HERE, base::Bind( | 1200 main_loop_->PostTask(FROM_HERE, base::Bind( |
1164 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); | 1201 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); |
1165 } | 1202 } |
1166 | 1203 |
1167 } // namespace webkit_media | 1204 } // namespace webkit_media |
OLD | NEW |