summaryrefslogtreecommitdiffstats
path: root/content/renderer/media
diff options
context:
space:
mode:
authorshouqun.liu@intel.com <shouqun.liu@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-25 08:50:52 +0000
committershouqun.liu@intel.com <shouqun.liu@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-25 08:50:52 +0000
commit1aec355886f0ca1619f3e109402469940361668b (patch)
tree67872e7782c75e37bb846027453c8092c47a9c6d /content/renderer/media
parent06357eeac361a34b6d2439e0bbe9512863738bf9 (diff)
downloadchromium_src-1aec355886f0ca1619f3e109402469940361668b.zip
chromium_src-1aec355886f0ca1619f3e109402469940361668b.tar.gz
chromium_src-1aec355886f0ca1619f3e109402469940361668b.tar.bz2
For Android, fix hidden video element can't paint to canvas and WebGL issue.
Hidden video element (with style display:none) can't be paint to canvas or WebGL, which blocks WebGL conformance test (textures/texture-npot-video.html): https://www.khronos.org/registry/webgl/sdk/tests/conformance/textures/texture-npot-video.html BUG=138226,243295 TEST=Visit: https://www.khronos.org/registry/webgl/sdk/tests/conformance/textures/texture-npot-video.html Review URL: https://chromiumcodereview.appspot.com/15875003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208456 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/media')
-rw-r--r--content/renderer/media/android/stream_texture_factory_android.cc13
-rw-r--r--content/renderer/media/android/stream_texture_factory_android.h7
-rw-r--r--content/renderer/media/android/webmediaplayer_android.cc20
-rw-r--r--content/renderer/media/android/webmediaplayer_android.h3
4 files changed, 34 insertions, 9 deletions
diff --git a/content/renderer/media/android/stream_texture_factory_android.cc b/content/renderer/media/android/stream_texture_factory_android.cc
index de73978..715183e 100644
--- a/content/renderer/media/android/stream_texture_factory_android.cc
+++ b/content/renderer/media/android/stream_texture_factory_android.cc
@@ -31,11 +31,9 @@ void StreamTextureProxy::SetClient(cc::VideoFrameProvider::Client* client) {
client_ = client;
}
-void StreamTextureProxy::BindToCurrentThread(int stream_id,
- int width,
- int height) {
+void StreamTextureProxy::BindToCurrentThread(int stream_id) {
loop_ = base::MessageLoopProxy::current();
- host_->Initialize(stream_id, gfx::Size(width, height));
+ host_->Initialize(stream_id);
}
void StreamTextureProxy::OnFrameAvailable() {
@@ -67,7 +65,7 @@ StreamTextureProxy* StreamTextureFactory::CreateProxy() {
return new StreamTextureProxy(host);
}
-void StreamTextureFactory::EstablishPeer(int stream_id, int player_id) {
+void StreamTextureFactory::EstablishPeer(int32 stream_id, int player_id) {
DCHECK(channel_.get());
channel_->Send(
new GpuChannelMsg_EstablishStreamTexture(stream_id, view_id_, player_id));
@@ -91,4 +89,9 @@ void StreamTextureFactory::DestroyStreamTexture(unsigned texture_id) {
}
}
+void StreamTextureFactory::SetStreamTextureSize(
+ int32 stream_id, const gfx::Size& size) {
+ channel_->Send(new GpuChannelMsg_SetStreamTextureSize(stream_id, size));
+}
+
} // namespace content
diff --git a/content/renderer/media/android/stream_texture_factory_android.h b/content/renderer/media/android/stream_texture_factory_android.h
index d3c88e5..d74c14d 100644
--- a/content/renderer/media/android/stream_texture_factory_android.h
+++ b/content/renderer/media/android/stream_texture_factory_android.h
@@ -24,7 +24,7 @@ class StreamTextureProxy : public StreamTextureHost::Listener {
// Initialize and bind to the current thread, which becomes the thread that
// a connected client will receive callbacks on.
- void BindToCurrentThread(int stream_id, int width, int height);
+ void BindToCurrentThread(int32 stream_id);
bool IsBoundToThread() { return loop_.get() != NULL; }
@@ -71,7 +71,7 @@ class StreamTextureFactory {
// object for the given stream_id. After the the surface is created,
// it will be passed back to the WebMediaPlayerAndroid object identified by
// the player_id.
- void EstablishPeer(int stream_id, int player_id);
+ void EstablishPeer(int32 stream_id, int player_id);
// Create the streamTexture and return the stream Id and set the texture id.
unsigned CreateStreamTexture(unsigned* texture_id);
@@ -79,6 +79,9 @@ class StreamTextureFactory {
// Destroy the streamTexture for the given texture Id.
void DestroyStreamTexture(unsigned texture_id);
+ // Set the streamTexture size for the given stream Id.
+ void SetStreamTextureSize(int32 texture_id, const gfx::Size& size);
+
private:
WebKit::WebGraphicsContext3D* context_;
scoped_refptr<GpuChannelHost> channel_;
diff --git a/content/renderer/media/android/webmediaplayer_android.cc b/content/renderer/media/android/webmediaplayer_android.cc
index 17a6501..c148f43 100644
--- a/content/renderer/media/android/webmediaplayer_android.cc
+++ b/content/renderer/media/android/webmediaplayer_android.cc
@@ -435,6 +435,19 @@ bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture(
if (!texture_id_)
return false;
+ // For hidden video element (with style "display:none"), ensure the texture
+ // size is set.
+ if (cached_stream_texture_size_.width != natural_size_.width ||
+ cached_stream_texture_size_.height != natural_size_.height) {
+ stream_texture_factory_->SetStreamTextureSize(
+ stream_id_, gfx::Size(natural_size_.width, natural_size_.height));
+ cached_stream_texture_size_ = natural_size_;
+ }
+
+ // Ensure the target of texture is set before copyTextureCHROMIUM, otherwise
+ // an invalid texture target may be used for copy texture.
+ web_graphics_context->bindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id_);
+
// The video is stored in an unmultiplied format, so premultiply if
// necessary.
web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
@@ -451,6 +464,8 @@ bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture(
web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false);
web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
false);
+
+ web_graphics_context->bindTexture(GL_TEXTURE_EXTERNAL_OES, 0);
return true;
}
@@ -799,9 +814,10 @@ scoped_refptr<media::VideoFrame> WebMediaPlayerAndroid::GetCurrentFrame() {
if (!stream_texture_proxy_initialized_ && stream_texture_proxy_ &&
stream_id_ && !needs_external_surface_) {
gfx::Size natural_size = current_frame_->natural_size();
- stream_texture_proxy_->BindToCurrentThread(
- stream_id_, natural_size.width(), natural_size.height());
+ stream_texture_proxy_->BindToCurrentThread(stream_id_);
+ stream_texture_factory_->SetStreamTextureSize(stream_id_, natural_size);
stream_texture_proxy_initialized_ = true;
+ cached_stream_texture_size_ = natural_size;
}
return current_frame_;
}
diff --git a/content/renderer/media/android/webmediaplayer_android.h b/content/renderer/media/android/webmediaplayer_android.h
index 00f0444..b9006b9 100644
--- a/content/renderer/media/android/webmediaplayer_android.h
+++ b/content/renderer/media/android/webmediaplayer_android.h
@@ -293,6 +293,9 @@ class WebMediaPlayerAndroid
// Size of the video.
WebKit::WebSize natural_size_;
+ // Size that has been sent to StreamTexture.
+ WebKit::WebSize cached_stream_texture_size_;
+
// The video frame object used for rendering by the compositor.
scoped_refptr<media::VideoFrame> current_frame_;