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

Unified Diff: content/renderer/media/webmediaplayer_ms.cc

Issue 1315323006: webgl: optimize webgl.texSubImage2D(video) path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
Index: content/renderer/media/webmediaplayer_ms.cc
diff --git a/content/renderer/media/webmediaplayer_ms.cc b/content/renderer/media/webmediaplayer_ms.cc
index 53119fe3ff12be25683882e8e86a8d2b462cac81..a5de6808720033529fa1304109711af228bf0ad2 100644
--- a/content/renderer/media/webmediaplayer_ms.cc
+++ b/content/renderer/media/webmediaplayer_ms.cc
@@ -422,6 +422,23 @@ bool WebMediaPlayerMS::copyVideoTextureToPlatformTexture(
bool premultiply_alpha,
bool flip_y) {
TRACE_EVENT0("media", "WebMediaPlayerMS:copyVideoTextureToPlatformTexture");
+ // TODO(dshwang): not include gl2.h because this method will be removed soon.
+ const unsigned int GL_TEXTURE_2D = 0x0DE1;
+ return copyVideoTextureToPlatformTexture(web_graphics_context, GL_TEXTURE_2D,
+ texture, internal_format, type, 0,
+ premultiply_alpha, flip_y);
+}
+
+bool WebMediaPlayerMS::copyVideoTextureToPlatformTexture(
+ blink::WebGraphicsContext3D* web_graphics_context,
+ unsigned int target,
+ unsigned int texture,
+ unsigned int internal_format,
+ unsigned int type,
+ int level,
+ bool premultiply_alpha,
+ bool flip_y) {
+ TRACE_EVENT0("media", "WebMediaPlayerMS:copyVideoTextureToPlatformTexture");
DCHECK(thread_checker_.CalledOnValidThread());
scoped_refptr<media::VideoFrame> video_frame;
@@ -441,8 +458,43 @@ bool WebMediaPlayerMS::copyVideoTextureToPlatformTexture(
static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context)
->GetGLInterface();
media::SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture(
- gl, video_frame.get(), texture, internal_format, type, premultiply_alpha,
- flip_y);
+ gl, video_frame.get(), target, texture, internal_format, type, level,
+ premultiply_alpha, flip_y);
+ return true;
+}
+
+bool WebMediaPlayerMS::copyVideoSubTextureToPlatformTexture(
+ blink::WebGraphicsContext3D* web_graphics_context,
+ unsigned int target,
+ unsigned int texture,
+ int level,
+ int xoffset,
+ int yoffset,
+ bool premultiply_alpha,
+ bool flip_y) {
+ TRACE_EVENT0("media",
+ "WebMediaPlayerMS:copyVideoSubTextureToPlatformTexture");
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ scoped_refptr<media::VideoFrame> video_frame;
+ {
+ base::AutoLock auto_lock(current_frame_lock_);
+ video_frame = current_frame_;
+ }
+
+ if (!video_frame.get() || video_frame->HasTextures() ||
+ media::VideoFrame::NumPlanes(video_frame->format()) != 1) {
+ return false;
+ }
+
+ // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to
+ // GLES2Interface.
+ gpu::gles2::GLES2Interface* gl =
+ static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context)
+ ->GetGLInterface();
+ media::SkCanvasVideoRenderer::CopySubVideoFrameSingleTextureToGLTexture(
+ gl, video_frame.get(), target, texture, level, xoffset, yoffset,
+ premultiply_alpha, flip_y);
return true;
}

Powered by Google App Engine
This is Rietveld 408576698