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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/media/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/media/webmediaplayer_impl.cc
diff --git a/webkit/media/webmediaplayer_impl.cc b/webkit/media/webmediaplayer_impl.cc
index 804135b658bcfefad732d60d2c56c35e0580e914..a4bfe397248e9feb02e4b5dc46c83605228a566c 100644
--- a/webkit/media/webmediaplayer_impl.cc
+++ b/webkit/media/webmediaplayer_impl.cc
@@ -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,
« 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