Add a new API in WebMediaPlayer to do a GPU-GPU textures copy if possible.
Signed-off-by: Jun Jiang <jun.a.jiang@intel.com> BUG=179754 Review URL: https://chromiumcodereview.appspot.com/12412007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187827 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
1
AUTHORS
1
AUTHORS
@ -230,3 +230,4 @@ Opera Software ASA <*@opera.com>
|
||||
Johannes Rudolph <johannes.rudolph@googlemail.com>
|
||||
Aaron Jacobs <samusaaron3@gmail.com>
|
||||
Sam Larison <qufighter@gmail.com>
|
||||
Jun Jiang <jun.a.jiang@intel.com>
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "base/metrics/histogram.h"
|
||||
#include "base/string_number_conversions.h"
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
#include "gpu/GLES2/gl2extchromium.h"
|
||||
#include "media/audio/null_audio_sink.h"
|
||||
#include "media/base/bind_to_loop.h"
|
||||
#include "media/base/filter_collection.h"
|
||||
@ -670,6 +671,44 @@ void WebMediaPlayerImpl::putCurrentFrame(
|
||||
delete web_video_frame;
|
||||
}
|
||||
|
||||
bool WebMediaPlayerImpl::copyVideoTextureToPlatformTexture(
|
||||
WebKit::WebGraphicsContext3D* web_graphics_context,
|
||||
unsigned int texture,
|
||||
unsigned int level,
|
||||
unsigned int internal_format,
|
||||
bool premultiply_alpha,
|
||||
bool flip_y) {
|
||||
scoped_refptr<media::VideoFrame> video_frame;
|
||||
{
|
||||
base::AutoLock auto_lock(lock_);
|
||||
video_frame = current_frame_;
|
||||
}
|
||||
if (video_frame &&
|
||||
video_frame->format() == media::VideoFrame::NATIVE_TEXTURE &&
|
||||
video_frame->texture_target() == GL_TEXTURE_2D) {
|
||||
uint32 source_texture = video_frame->texture_id();
|
||||
// The video is stored in a unmultiplied format, so premultiply
|
||||
// if necessary.
|
||||
web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
|
||||
premultiply_alpha);
|
||||
// Application itself needs to take care of setting the right flip_y
|
||||
// value down to get the expected result.
|
||||
// flip_y==true means to reverse the video orientation while
|
||||
// flip_y==false means to keep the intrinsic orientation.
|
||||
web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y);
|
||||
web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D,
|
||||
source_texture, texture, level, internal_format);
|
||||
web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false);
|
||||
web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
|
||||
false);
|
||||
// The flush() operation is not necessary here. It is kept since the
|
||||
// performance will be better when it is added than not.
|
||||
web_graphics_context->flush();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Helper enum for reporting generateKeyRequest/addKey histograms.
|
||||
enum MediaKeyException {
|
||||
kUnknownResultId,
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "media/base/pipeline.h"
|
||||
#include "media/filters/skcanvas_video_renderer.h"
|
||||
#include "skia/ext/platform_canvas.h"
|
||||
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvider.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerClient.h"
|
||||
@ -143,6 +144,14 @@ class WebMediaPlayerImpl
|
||||
virtual WebKit::WebVideoFrame* getCurrentFrame();
|
||||
virtual void putCurrentFrame(WebKit::WebVideoFrame* web_video_frame);
|
||||
|
||||
virtual bool copyVideoTextureToPlatformTexture(
|
||||
WebKit::WebGraphicsContext3D* web_graphics_context,
|
||||
unsigned int texture,
|
||||
unsigned int level,
|
||||
unsigned int internal_format,
|
||||
bool premultiply_alpha,
|
||||
bool flip_y);
|
||||
|
||||
virtual WebKit::WebAudioSourceProvider* audioSourceProvider();
|
||||
|
||||
virtual MediaKeyException generateKeyRequest(
|
||||
|
Reference in New Issue
Block a user