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

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: Add new APIs in WebMediaPlayer to do a GPU-GPU textures copy if possible. 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 "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
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 // The flush() operation is not necessary here. It is kept since the
705 // performance will be better when it is added than not.
706 web_graphics_context->flush();
707 return true;
708 }
709 return false;
710 }
711
673 // Helper enum for reporting generateKeyRequest/addKey histograms. 712 // Helper enum for reporting generateKeyRequest/addKey histograms.
674 enum MediaKeyException { 713 enum MediaKeyException {
675 kUnknownResultId, 714 kUnknownResultId,
676 kSuccess, 715 kSuccess,
677 kKeySystemNotSupported, 716 kKeySystemNotSupported,
678 kInvalidPlayerState, 717 kInvalidPlayerState,
679 kMaxMediaKeyException 718 kMaxMediaKeyException
680 }; 719 };
681 720
682 static MediaKeyException MediaKeyExceptionForUMA( 721 static MediaKeyException MediaKeyExceptionForUMA(
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 1197
1159 if (pending_repaint_) 1198 if (pending_repaint_)
1160 return; 1199 return;
1161 1200
1162 pending_repaint_ = true; 1201 pending_repaint_ = true;
1163 main_loop_->PostTask(FROM_HERE, base::Bind( 1202 main_loop_->PostTask(FROM_HERE, base::Bind(
1164 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); 1203 &WebMediaPlayerImpl::Repaint, AsWeakPtr()));
1165 } 1204 }
1166 1205
1167 } // namespace webkit_media 1206 } // 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