Index: content/renderer/render_view_impl.cc |
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc |
index 181b273f6f4075fdd0ab19f3cceb9564ad91c74e..a964f447bb4ca1d20611944fcbce10a29ec5a1a7 100644 |
--- a/content/renderer/render_view_impl.cc |
+++ b/content/renderer/render_view_impl.cc |
@@ -2498,8 +2498,42 @@ WebMediaPlayer* RenderViewImpl::createMediaPlayer( |
const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
#if defined(OS_ANDROID) |
- // TODO(qinmin): upstream the implementation of getting WebGraphicsContext3D |
- // and GpuChannelHost here to replace the NULL params. |
+ // Leak |resource_context| similar to SharedGraphicsContext3D to avoid |
+ // shutdown races. |
+ // TODO(sievers): Expose the shared context from webkit to be used here. |
jamesr
2012/09/22 00:42:22
the shared context is exposed from WebKit. Specif
qinmin
2012/09/22 01:45:28
Done.
|
+ static WebGraphicsContext3DCommandBufferImpl* resource_context = NULL; |
+ if (!resource_context) { |
+ // Create a main-thread context for resource allocation. |
+ int surface = 0; |
+ GURL url; |
+ base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client; |
+ |
+ resource_context = new WebGraphicsContext3DCommandBufferImpl( |
+ surface, url, RenderThreadImpl::current(), swap_client); |
+ WebKit::WebGraphicsContext3D::Attributes attributes; |
+ attributes.antialias = false; |
+ attributes.shareResources = true; |
+ attributes.depth = false; |
+ attributes.stencil = false; |
+ if (!resource_context->Initialize( |
+ attributes, |
+ false, |
+ content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE)) { |
+ delete resource_context; |
+ resource_context = NULL; |
+ LOG(ERROR) << "Failed to create graphics context for video resources"; |
+ return NULL; |
+ } |
+ } |
+ |
+ GpuChannelHost* gpu_channel_host = |
+ RenderThreadImpl::current()->EstablishGpuChannelSync( |
+ content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); |
+ if (!gpu_channel_host) { |
+ LOG(ERROR) << "Failed to establish GPU channel for media player"; |
+ return NULL; |
+ } |
+ |
if (cmd_line->HasSwitch(switches::kMediaPlayerInRenderProcess)) { |
if (!media_bridge_manager_.get()) { |
media_bridge_manager_.reset( |
@@ -2512,7 +2546,7 @@ WebMediaPlayer* RenderViewImpl::createMediaPlayer( |
media_player_manager_.get(), |
media_bridge_manager_.get(), |
new content::StreamTextureFactoryImpl( |
- NULL, NULL, routing_id_), |
+ resource_context, gpu_channel_host, routing_id_), |
cmd_line->HasSwitch(switches::kDisableMediaHistoryLogging)); |
} |
if (!media_player_proxy_) { |
@@ -2525,7 +2559,7 @@ WebMediaPlayer* RenderViewImpl::createMediaPlayer( |
media_player_manager_.get(), |
media_player_proxy_, |
new content::StreamTextureFactoryImpl( |
- NULL, NULL, routing_id_)); |
+ resource_context, gpu_channel_host, routing_id_)); |
#endif |
media::MessageLoopFactory* message_loop_factory = |