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

Unified Diff: content/renderer/media/android/webmediaplayer_android.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/android/webmediaplayer_android.cc
diff --git a/content/renderer/media/android/webmediaplayer_android.cc b/content/renderer/media/android/webmediaplayer_android.cc
index 5187d3f81d6358f24b0d326fbd2a8fca54d73c2e..616967921a3544689ff86e23029b67cc4bd60f09 100644
--- a/content/renderer/media/android/webmediaplayer_android.cc
+++ b/content/renderer/media/android/webmediaplayer_android.cc
@@ -637,8 +637,9 @@ void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas,
unsigned textureId = static_cast<unsigned>(
(bitmap_.getTexture())->getTextureHandle());
- if (!copyVideoTextureToPlatformTexture(context3D, textureId,
- GL_RGBA, GL_UNSIGNED_BYTE, true, false)) {
+ if (!copyVideoTextureToPlatformTexture(context3D, GL_TEXTURE_2D, textureId,
+ GL_RGBA, GL_UNSIGNED_BYTE, 0, true,
+ false)) {
return;
}
@@ -663,6 +664,51 @@ bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture(
unsigned int type,
bool premultiply_alpha,
bool flip_y) {
+ return copyVideoTextureToPlatformTexture(web_graphics_context, GL_TEXTURE_2D,
+ texture, internal_format, type, 0,
+ premultiply_alpha, flip_y);
+}
+
+bool WebMediaPlayerAndroid::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) {
+ return CopyVideoTextureToPlatformTextureInternal(
+ web_graphics_context, true, target, texture, internal_format, type, level,
+ 0, 0, premultiply_alpha, flip_y);
+}
+
+bool WebMediaPlayerAndroid::copyVideoSubTextureToPlatformTexture(
+ blink::WebGraphicsContext3D* web_graphics_context,
+ unsigned int target,
+ unsigned int texture,
+ int level,
+ int xoffset,
+ int yoffset,
+ bool premultiply_alpha,
+ bool flip_y) {
+ return CopyVideoTextureToPlatformTextureInternal(
+ web_graphics_context, false, target, texture, GL_FALSE, GL_FALSE, level,
+ xoffset, yoffset, premultiply_alpha, flip_y);
+}
+
+bool WebMediaPlayerAndroid::CopyVideoTextureToPlatformTextureInternal(
+ blink::WebGraphicsContext3D* web_graphics_context,
+ bool is_full_copy,
+ unsigned int target,
+ unsigned int texture,
+ unsigned int internal_format,
+ unsigned int type,
+ int level,
+ int xoffset,
+ int yoffset,
+ bool premultiply_alpha,
+ bool flip_y) {
DCHECK(main_thread_checker_.CalledOnValidThread());
// Don't allow clients to copy an encrypted video frame.
if (needs_external_surface_)
@@ -694,9 +740,16 @@ bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture(
// 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->copyTextureCHROMIUM(
- GL_TEXTURE_2D, src_texture, texture, internal_format, type,
- flip_y, premultiply_alpha, false);
+ if (is_full_copy) {
piman 2015/09/04 17:34:29 nit: maybe DCHECK that xoffset/yoffset are 0 here?
+ web_graphics_context->copyTextureCHROMIUM(target, src_texture, texture,
+ internal_format, type, flip_y,
+ premultiply_alpha, false);
+ } else {
+ web_graphics_context->copySubTextureCHROMIUM(
+ target, src_texture, texture, xoffset, yoffset, 0, 0,
+ video_frame->natural_size().width(),
+ video_frame->natural_size().height(), flip_y, premultiply_alpha, false);
+ }
web_graphics_context->deleteTexture(src_texture);
web_graphics_context->flush();

Powered by Google App Engine
This is Rietveld 408576698