summaryrefslogtreecommitdiffstats
path: root/webkit/media
diff options
context:
space:
mode:
authorhkuang@chromium.org <hkuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-18 05:41:37 +0000
committerhkuang@chromium.org <hkuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-18 05:41:37 +0000
commit5394a4100728fe8775379cbc82b03d21d0e3a05a (patch)
treec7f5565dfae9d60cb006180b2cbda72d9dce09d4 /webkit/media
parent4f60d80fe11923a832b5d1dfca1373debde321db (diff)
downloadchromium_src-5394a4100728fe8775379cbc82b03d21d0e3a05a.zip
chromium_src-5394a4100728fe8775379cbc82b03d21d0e3a05a.tar.gz
chromium_src-5394a4100728fe8775379cbc82b03d21d0e3a05a.tar.bz2
Enable video painting on Canvas for Chrome on Android. This change should land after another patch landing in https://codereview.chromium.org/13685002.
BUG=147265 TEST=visited the following site: http://html5doctor.com/demos/video-canvas-magic/demo1.html Visit http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_canvas_drawimage_video. Change different parameters of the canvas and video. Compare the result between desktop chrome and android chrome to see if video painting results are the same. Canvas 500X400 ctx.drawImage(v,60,60,320,176) PASS Canvas 500X400 ctx.drawImage(v,0,0,320,176) PASS Canvas 200X100 ctx.drawImage(v,0,0,320,176) PASS Canvas 200X100 ctx.drawImage(v,50,50,320,176) PASS Canvas 500X400 ctx.drawImage(v,0,0,30,30,5,5,260,125) PASS Canvas 500X400 ctx.drawImage(v,0,0) PASS Canvas 600x700 ctx.drawImage(v,90,90,80,80,100,100,260,125) PASS TODO: More complex and mixed 2D Canvas operation to see if the painting result is right(Need to learn some more JS for that). Review URL: https://chromiumcodereview.appspot.com/13620008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194785 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/media')
-rw-r--r--webkit/media/android/webmediaplayer_android.cc29
-rw-r--r--webkit/media/android/webmediaplayer_android.h9
2 files changed, 38 insertions, 0 deletions
diff --git a/webkit/media/android/webmediaplayer_android.cc b/webkit/media/android/webmediaplayer_android.cc
index 5a03822..78461ce 100644
--- a/webkit/media/android/webmediaplayer_android.cc
+++ b/webkit/media/android/webmediaplayer_android.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "cc/layers/video_layer.h"
+#include "gpu/GLES2/gl2extchromium.h"
#include "media/base/android/media_player_bridge.h"
#include "media/base/video_frame.h"
#include "net/base/mime_util.h"
@@ -270,6 +271,34 @@ void WebMediaPlayerAndroid::paint(WebKit::WebCanvas* canvas,
NOTIMPLEMENTED();
}
+bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture(
+ WebKit::WebGraphicsContext3D* web_graphics_context,
+ unsigned int texture,
+ unsigned int level,
+ unsigned int internal_format,
+ bool premultiply_alpha,
+ bool flip_y) {
+ if (!texture_id_)
+ return false;
+
+ // The video is stored in an 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, texture_id_,
+ texture, level, internal_format);
+ web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false);
+ web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
+ false);
+ return true;
+}
+
bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const {
return false;
}
diff --git a/webkit/media/android/webmediaplayer_android.h b/webkit/media/android/webmediaplayer_android.h
index 371513c..22c3895 100644
--- a/webkit/media/android/webmediaplayer_android.h
+++ b/webkit/media/android/webmediaplayer_android.h
@@ -13,6 +13,7 @@
#include "base/message_loop.h"
#include "base/time.h"
#include "cc/layers/video_frame_provider.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h"
@@ -65,6 +66,14 @@ class WebMediaPlayerAndroid
const WebKit::WebRect& rect,
uint8_t alpha);
+ virtual bool copyVideoTextureToPlatformTexture(
+ WebKit::WebGraphicsContext3D* web_graphics_context,
+ unsigned int texture,
+ unsigned int level,
+ unsigned int internal_format,
+ bool premultiply_alpha,
+ bool flip_y);
+
// True if the loaded media has a playable video/audio track.
virtual bool hasVideo() const;
virtual bool hasAudio() const;