Chromium Code Reviews| Index: content/renderer/render_view_impl.cc |
| diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc |
| index 843d7e703a59af80f2520ea2c0f62eaa1e40864a..fa5adf9851777d0be6c72613dc15d736e22ae3af 100644 |
| --- a/content/renderer/render_view_impl.cc |
| +++ b/content/renderer/render_view_impl.cc |
| @@ -52,6 +52,8 @@ |
| #include "content/renderer/devtools_agent.h" |
| #include "content/renderer/external_popup_menu.h" |
| #include "content/renderer/geolocation_dispatcher.h" |
| +#include "content/renderer/gpu/command_buffer_proxy.h" |
| +#include "content/renderer/gpu/gpu_channel_host.h" |
| #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" |
| #include "content/renderer/idle_user_detector.h" |
| #include "content/renderer/intents_dispatcher.h" |
| @@ -77,9 +79,11 @@ |
| #include "content/renderer/web_ui_bindings.h" |
| #include "content/renderer/webplugin_delegate_proxy.h" |
| #include "content/renderer/websharedworker_proxy.h" |
| +#include "gpu/command_buffer/client/gles2_implementation.h" |
| #include "media/base/filter_collection.h" |
| #include "media/base/media_switches.h" |
| #include "media/base/message_loop_factory_impl.h" |
| +#include "media/filters/gpu_video_decoder.h" |
| #include "net/base/escape.h" |
| #include "net/base/net_errors.h" |
| #include "net/http/http_util.h" |
| @@ -145,7 +149,6 @@ |
| #include "webkit/glue/webkit_constants.h" |
| #include "webkit/glue/webkit_glue.h" |
| #include "webkit/glue/weburlloader_impl.h" |
| -#include "webkit/media/video_renderer_impl.h" |
| #include "webkit/media/webmediaplayer_impl.h" |
| #include "webkit/plugins/npapi/default_plugin_shared.h" |
| #include "webkit/plugins/npapi/plugin_list.h" |
| @@ -1901,6 +1904,57 @@ WebSharedWorker* RenderViewImpl::createSharedWorker( |
| } |
| } |
| +// Glue code to expose functionality needed by media::GpuVideoDecoder. |
|
Ami GONE FROM CHROMIUM
2011/11/30 00:08:37
This could as well have lived in a separate file,
|
| +class GpuVideoDecoderFactories : public media::GpuVideoDecoder::Factories { |
| + public: |
| + virtual ~GpuVideoDecoderFactories() {} |
| + // Doesn't take ownership of arguments. |
| + GpuVideoDecoderFactories(GpuChannelHost* gpu_channel_host, |
| + gpu::gles2::GLES2Implementation* gles2, int route_id) |
| + : gpu_channel_host_(gpu_channel_host), |
| + gles2_(gles2), route_id_(route_id) { |
| + } |
| + |
| + media::VideoDecodeAccelerator* CreateVideoDecodeAccelerator( |
| + media::VideoDecodeAccelerator::Profile profile, |
| + media::VideoDecodeAccelerator::Client* client) { |
| + return gpu_channel_host_->CreateVideoDecoder(route_id_, profile, client); |
| + } |
| + |
| + bool CreateTextures(int32 count, const gfx::Size& size, |
| + std::vector<uint32>* texture_ids) { |
| + texture_ids->resize(count); |
| + gles2_->GenTextures(count, &texture_ids->at(0)); |
| + for (int i = 0; i < count; ++i) { |
| + gles2_->ActiveTexture(GL_TEXTURE0); |
| + uint32 texture_id = texture_ids->at(i); |
| + gles2_->BindTexture(GL_TEXTURE_2D, texture_id); |
| + gles2_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| + gles2_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| + gles2_->TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| + gles2_->TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| + gles2_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width(), size.height(), |
| + 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); |
| + } |
| + return gles2_->GetError() == GL_NO_ERROR; |
| + } |
| + |
| + bool DeleteTexture(uint32 texture_id) { |
| + gles2_->DeleteTextures(1, &texture_id); |
| + return gles2_->GetError() == GL_NO_ERROR; |
| + } |
| + |
| + base::SharedMemory* CreateSharedMemory(size_t size) { |
| + return ChildThread::current()->AllocateSharedMemory(size); |
| + } |
| + |
| + private: |
| + GpuChannelHost* gpu_channel_host_; |
| + gpu::gles2::GLES2Implementation* gles2_; |
| + int route_id_; |
| + DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecoderFactories); |
| +}; |
| + |
| WebMediaPlayer* RenderViewImpl::createMediaPlayer( |
| WebFrame* frame, WebMediaPlayerClient* client) { |
| FOR_EACH_OBSERVER( |
| @@ -1918,6 +1972,27 @@ WebMediaPlayer* RenderViewImpl::createMediaPlayer( |
| collection->AddAudioRenderer(new AudioRendererImpl()); |
| } |
| +#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| + // Currently only cros/arm has any HW video decode support in |
| + // GpuVideoDecodeAccelerator so we don't even try to use it on other |
| + // platforms. This is a startup-time optimization. When new VDA |
| + // implementations are added, relax the #if above. |
| + WebKit::WebGraphicsContext3D* wk_context3d = webview()->graphicsContext3D(); |
| + if (wk_context3d) { |
| + WebGraphicsContext3DCommandBufferImpl* context3d = |
| + static_cast<WebGraphicsContext3DCommandBufferImpl*>(wk_context3d); |
| + int route_id = context3d->context()->GetCommandBufferProxy()->route_id(); |
| + gpu::gles2::GLES2Implementation* gles2 = |
| + context3d->context()->GetImplementation(); |
| + GpuChannelHost* gpu_channel_host = |
| + RenderThreadImpl::current()->EstablishGpuChannelSync( |
| + content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); |
| + collection->AddVideoDecoder(new media::GpuVideoDecoder( |
| + message_loop_factory->GetMessageLoop("GpuVideoDecoderThread"), |
| + new GpuVideoDecoderFactories(gpu_channel_host, gles2, route_id))); |
| + } |
| +#endif |
| + |
| scoped_ptr<webkit_media::WebMediaPlayerImpl> result( |
| new webkit_media::WebMediaPlayerImpl(client, |
| AsWeakPtr(), |