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

Side by Side Diff: webkit/media/webmediaplayer_impl.cc

Issue 12412007: Add a new API in WebMediaPlayer to do a GPU-GPU textures copy if possible (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 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
« no previous file with comments | « webkit/media/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "media/audio/null_audio_sink.h" 18 #include "media/audio/null_audio_sink.h"
19 #include "media/base/bind_to_loop.h" 19 #include "media/base/bind_to_loop.h"
20 #include "media/base/filter_collection.h" 20 #include "media/base/filter_collection.h"
21 #include "media/base/limits.h" 21 #include "media/base/limits.h"
22 #include "media/base/media_log.h" 22 #include "media/base/media_log.h"
23 #include "media/base/pipeline.h" 23 #include "media/base/pipeline.h"
24 #include "media/base/video_frame.h" 24 #include "media/base/video_frame.h"
25 #include "media/filters/audio_renderer_impl.h" 25 #include "media/filters/audio_renderer_impl.h"
26 #include "media/filters/chunk_demuxer.h" 26 #include "media/filters/chunk_demuxer.h"
27 #include "media/filters/video_renderer_base.h" 27 #include "media/filters/video_renderer_base.h"
28 #include "third_party/khronos/GLES2/gl2.h"
28 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" 29 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h"
29 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" 30 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
30 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" 31 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
31 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" 32 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h"
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h"
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
34 #include "v8/include/v8.h" 35 #include "v8/include/v8.h"
35 #include "webkit/media/buffered_data_source.h" 36 #include "webkit/media/buffered_data_source.h"
36 #include "webkit/media/filter_helpers.h" 37 #include "webkit/media/filter_helpers.h"
37 #include "webkit/media/webaudiosourceprovider_impl.h" 38 #include "webkit/media/webaudiosourceprovider_impl.h"
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 void WebMediaPlayerImpl::putCurrentFrame( 649 void WebMediaPlayerImpl::putCurrentFrame(
649 WebKit::WebVideoFrame* web_video_frame) { 650 WebKit::WebVideoFrame* web_video_frame) {
650 if (!accelerated_compositing_reported_) { 651 if (!accelerated_compositing_reported_) {
651 accelerated_compositing_reported_ = true; 652 accelerated_compositing_reported_ = true;
652 DCHECK(frame_->view()->isAcceleratedCompositingActive()); 653 DCHECK(frame_->view()->isAcceleratedCompositingActive());
653 UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive", true); 654 UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive", true);
654 } 655 }
655 delete web_video_frame; 656 delete web_video_frame;
656 } 657 }
657 658
659 bool WebMediaPlayerImpl::videoDecodeAcceleratedByGpu()
scherkus (not reviewing) 2013/03/06 21:37:37 chromium style has { on the same line as functions
Jun Jiang 2013/03/07 13:55:04 Thanks for sharing the coding-style for chromium.
scherkus (not reviewing) 2013/03/07 23:46:09 cpplint.py should be part of depot_tools and it wi
660 {
661 scoped_refptr<media::VideoFrame> video_frame;
662 {
663 base::AutoLock auto_lock(lock_);
664 video_frame = current_frame_;
665 }
666
667 if (video_frame)
668 return video_frame->format() == media::VideoFrame::NATIVE_TEXTURE && video_f rame->texture_target() == GL_TEXTURE_2D;
669 return false;
670 }
671
672 bool WebMediaPlayerImpl::copyVideoTextureToPlatformTexture(WebKit::WebGraphicsCo ntext3D* webGraphicsContext, unsigned int texture, unsigned int internalFormat)
scherkus (not reviewing) 2013/03/06 21:37:37 In your WK patch you call videoDecodeAcceleratedBy
Ken Russell (switch to Gerrit) 2013/03/07 00:13:23 I agree; it looks redundant.
Jun Jiang 2013/03/07 13:55:04 Yes, looking at the code alone in WebMediaPlayerIm
scherkus (not reviewing) 2013/03/07 23:46:09 My preference is to keep it to one function for no
Jun Jiang 2013/03/08 01:53:28 Seeing this, it seems we'd better drop off the fun
scherkus (not reviewing) 2013/03/08 01:58:45 My preference is to always try copyVideoTextureToP
673 {
674 if (!webGraphicsContext)
scherkus (not reviewing) 2013/03/06 21:37:37 is this possible or is this programmer error?
Jun Jiang 2013/03/07 13:55:04 It is basically not possible to happen in current
675 return false;
676 scoped_refptr<media::VideoFrame> video_frame;
677 {
678 base::AutoLock auto_lock(lock_);
679 video_frame = current_frame_;
680 }
681 if (video_frame && video_frame->format() == media::VideoFrame::NATIVE_TEXTURE && video_frame->texture_target() == GL_TEXTURE_2D){
682 uint32 sourceTexture = video_frame->texture_id();
683 webGraphicsContext->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, textur e, 0, internalFormat);
684 return true;
685 }
686 return false;
687 }
688
658 #define COMPILE_ASSERT_MATCHING_STATUS_ENUM(webkit_name, chromium_name) \ 689 #define COMPILE_ASSERT_MATCHING_STATUS_ENUM(webkit_name, chromium_name) \
659 COMPILE_ASSERT(static_cast<int>(WebMediaPlayer::webkit_name) == \ 690 COMPILE_ASSERT(static_cast<int>(WebMediaPlayer::webkit_name) == \
660 static_cast<int>(media::ChunkDemuxer::chromium_name), \ 691 static_cast<int>(media::ChunkDemuxer::chromium_name), \
661 mismatching_status_enums) 692 mismatching_status_enums)
662 COMPILE_ASSERT_MATCHING_STATUS_ENUM(AddIdStatusOk, kOk); 693 COMPILE_ASSERT_MATCHING_STATUS_ENUM(AddIdStatusOk, kOk);
663 COMPILE_ASSERT_MATCHING_STATUS_ENUM(AddIdStatusNotSupported, kNotSupported); 694 COMPILE_ASSERT_MATCHING_STATUS_ENUM(AddIdStatusNotSupported, kNotSupported);
664 COMPILE_ASSERT_MATCHING_STATUS_ENUM(AddIdStatusReachedIdLimit, kReachedIdLimit); 695 COMPILE_ASSERT_MATCHING_STATUS_ENUM(AddIdStatusReachedIdLimit, kReachedIdLimit);
665 #undef COMPILE_ASSERT_MATCHING_ENUM 696 #undef COMPILE_ASSERT_MATCHING_ENUM
666 697
667 WebMediaPlayer::AddIdStatus WebMediaPlayerImpl::sourceAddId( 698 WebMediaPlayer::AddIdStatus WebMediaPlayerImpl::sourceAddId(
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 1257
1227 if (pending_repaint_) 1258 if (pending_repaint_)
1228 return; 1259 return;
1229 1260
1230 pending_repaint_ = true; 1261 pending_repaint_ = true;
1231 main_loop_->PostTask(FROM_HERE, base::Bind( 1262 main_loop_->PostTask(FROM_HERE, base::Bind(
1232 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); 1263 &WebMediaPlayerImpl::Repaint, AsWeakPtr()));
1233 } 1264 }
1234 1265
1235 } // namespace webkit_media 1266 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698