diff options
author | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-18 21:31:16 +0000 |
---|---|---|
committer | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-18 21:31:16 +0000 |
commit | 3b2afc30b0f653e1dd36af177e08da3aa9247057 (patch) | |
tree | ce13ce0d267910307daf4cd3224e6df4ef4fc08b | |
parent | 68670d65153bdcd60136979ebffa3e0e57567928 (diff) | |
download | chromium_src-3b2afc30b0f653e1dd36af177e08da3aa9247057.zip chromium_src-3b2afc30b0f653e1dd36af177e08da3aa9247057.tar.gz chromium_src-3b2afc30b0f653e1dd36af177e08da3aa9247057.tar.bz2 |
Re-enable HW decode on CrOS now that the flashing bug is fixed.
BUG=129103
Review URL: https://chromiumcodereview.appspot.com/10559017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142817 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/login/login_utils.cc | 1 | ||||
-rw-r--r-- | content/browser/gpu/gpu_process_host.cc | 3 | ||||
-rw-r--r-- | content/browser/renderer_host/render_process_host_impl.cc | 1 | ||||
-rw-r--r-- | content/common/gpu/media/gpu_video_decode_accelerator.h | 3 | ||||
-rw-r--r-- | content/common/gpu/media/vaapi_video_decode_accelerator.cc | 10 | ||||
-rw-r--r-- | content/public/common/content_switches.cc | 5 | ||||
-rw-r--r-- | content/public/common/content_switches.h | 2 | ||||
-rw-r--r-- | content/renderer/media/renderer_gpu_video_decoder_factories.cc | 16 | ||||
-rw-r--r-- | content/renderer/media/renderer_gpu_video_decoder_factories.h | 5 | ||||
-rw-r--r-- | content/renderer/render_thread_impl.cc | 21 | ||||
-rw-r--r-- | content/renderer/render_thread_impl.h | 10 | ||||
-rw-r--r-- | content/renderer/render_view_impl.cc | 18 |
12 files changed, 56 insertions, 39 deletions
diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc index 636605d..95c1a6c 100644 --- a/chrome/browser/chromeos/login/login_utils.cc +++ b/chrome/browser/chromeos/login/login_utils.cc @@ -720,6 +720,7 @@ std::string LoginUtilsImpl::GetOffTheRecordCommandLine( ::switches::kDisableSeccompFilterSandbox, ::switches::kDisableSeccompSandbox, ::switches::kDisableThreadedAnimation, + ::switches::kEnableAcceleratedVideoDecode, ::switches::kEnableDevicePolicy, ::switches::kEnableGView, ::switches::kEnableLogging, diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc index b81e494..a696bf9 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc @@ -745,9 +745,6 @@ bool GpuProcessHost::LaunchGpuProcess(const std::string& channel_id) { #if defined(OS_MACOSX) switches::kEnableSandboxLogging, #endif -#if defined(OS_CHROMEOS) - switches::kEnableVaapi, -#endif switches::kGpuNoContextLost, switches::kGpuStartupDialog, switches::kLoggingLevel, diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index c8aaa1c..67bf8b98 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -674,6 +674,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( switches::kDisableWebAudio, switches::kDisableWebSockets, switches::kDomAutomationController, + switches::kEnableAcceleratedVideoDecode, switches::kEnableAccessibilityLogging, switches::kEnableDCHECK, switches::kEnableEncryptedMedia, diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.h b/content/common/gpu/media/gpu_video_decode_accelerator.h index 12c81f0..e76a8ba 100644 --- a/content/common/gpu/media/gpu_video_decode_accelerator.h +++ b/content/common/gpu/media/gpu_video_decode_accelerator.h @@ -21,6 +21,9 @@ class GpuVideoDecodeAccelerator public IPC::Message::Sender, public media::VideoDecodeAccelerator::Client { public: + // Each of the arguments to the constructor must outlive this object. + // |stub->decoder()| will be made current around any operation that touches + // the underlying VDA so that it can make GL calls safely. GpuVideoDecodeAccelerator(IPC::Message::Sender* sender, int32 host_route_id, GpuCommandBufferStub* stub); diff --git a/content/common/gpu/media/vaapi_video_decode_accelerator.cc b/content/common/gpu/media/vaapi_video_decode_accelerator.cc index 29cc375..11ab9ccb 100644 --- a/content/common/gpu/media/vaapi_video_decode_accelerator.cc +++ b/content/common/gpu/media/vaapi_video_decode_accelerator.cc @@ -74,14 +74,7 @@ bool VaapiVideoDecodeAccelerator::Initialize( DCHECK_EQ(state_, kUninitialized); DVLOG(2) << "Initializing VAVDA, profile: " << profile; - // TODO(posciak): try moving the flag check up to higher layers, possibly - // out of the GPU process. - bool res = CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableVaapi); - RETURN_AND_NOTIFY_ON_FAILURE(res, "Vaapi HW acceleration disabled", - PLATFORM_FAILURE, false); - - res = decoder_.Initialize( + bool res = decoder_.Initialize( profile, x_display_, glx_context_, make_context_current_, base::Bind(&VaapiVideoDecodeAccelerator::OutputPicCallback, this)); RETURN_AND_NOTIFY_ON_FAILURE(res, "Failed initializing decoder", @@ -572,4 +565,3 @@ void VaapiVideoDecodeAccelerator::OutputPicCallback(int32 input_id, base::Bind(&VaapiVideoDecodeAccelerator::SyncAndNotifyPictureReady, this, input_id, output_id)); } - diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index 1ae248c..05dca82 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -360,9 +360,8 @@ const char kDisableThreadedCompositing[] = "disable-threaded-compositing"; // SYN packet. const char kEnableTcpFastOpen[] = "enable-tcp-fastopen"; -// Enables hardware acceleration for video decode on ChromeOS -// on Intel CPUs (mostly Sandy Bridge+) using VAAPI. -const char kEnableVaapi[] = "enable-vaapi"; +// Enables hardware acceleration of video decode, where available. +const char kEnableAcceleratedVideoDecode[] = "enable-accelerated-video-decode"; // Enables support for video tracks. Current implementation is // incomplete and this flag is used for development and testing. diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index b9dfd35..030ced9 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -118,7 +118,7 @@ extern const char kEnableStrictSiteIsolation[]; CONTENT_EXPORT extern const char kEnableThreadedCompositing[]; CONTENT_EXPORT extern const char kDisableThreadedCompositing[]; CONTENT_EXPORT extern const char kEnableTcpFastOpen[]; -CONTENT_EXPORT extern const char kEnableVaapi[]; +CONTENT_EXPORT extern const char kEnableAcceleratedVideoDecode[]; CONTENT_EXPORT extern const char kEnableVideoTrack[]; extern const char kEnableViewport[]; CONTENT_EXPORT extern const char kExperimentalLocationFeatures[]; diff --git a/content/renderer/media/renderer_gpu_video_decoder_factories.cc b/content/renderer/media/renderer_gpu_video_decoder_factories.cc index 305ef99..adf8a44 100644 --- a/content/renderer/media/renderer_gpu_video_decoder_factories.cc +++ b/content/renderer/media/renderer_gpu_video_decoder_factories.cc @@ -15,11 +15,14 @@ RendererGpuVideoDecoderFactories::~RendererGpuVideoDecoderFactories() {} RendererGpuVideoDecoderFactories::RendererGpuVideoDecoderFactories( GpuChannelHost* gpu_channel_host, MessageLoop* message_loop, - WebGraphicsContext3DCommandBufferImpl* wgc3dcbi) + const base::WeakPtr<WebGraphicsContext3DCommandBufferImpl>& context) : message_loop_(message_loop), - gpu_channel_host_(gpu_channel_host) { + gpu_channel_host_(gpu_channel_host), + context_(context) { + DCHECK(context_); + context_->DetachFromThread(); if (MessageLoop::current() == message_loop_) { - AsyncGetContext(wgc3dcbi, NULL); + AsyncGetContext(NULL); return; } // Threaded compositor requires us to wait for the context to be acquired. @@ -29,15 +32,14 @@ RendererGpuVideoDecoderFactories::RendererGpuVideoDecoderFactories( // Unretained to avoid ref/deref'ing |*this|, which is not yet stored in a // scoped_refptr. Safe because the Wait() below keeps us alive until this // task completes. - base::Unretained(this), wgc3dcbi, &waiter)); + base::Unretained(this), &waiter)); waiter.Wait(); } void RendererGpuVideoDecoderFactories::AsyncGetContext( - WebGraphicsContext3DCommandBufferImpl* wgc3dcbi, base::WaitableEvent* waiter) { - wgc3dcbi->makeContextCurrent(); - context_ = wgc3dcbi->AsWeakPtr(); + if (context_) + context_->makeContextCurrent(); if (waiter) waiter->Signal(); } diff --git a/content/renderer/media/renderer_gpu_video_decoder_factories.h b/content/renderer/media/renderer_gpu_video_decoder_factories.h index c4386f2..f22d75d 100644 --- a/content/renderer/media/renderer_gpu_video_decoder_factories.h +++ b/content/renderer/media/renderer_gpu_video_decoder_factories.h @@ -38,7 +38,7 @@ class CONTENT_EXPORT RendererGpuVideoDecoderFactories RendererGpuVideoDecoderFactories( GpuChannelHost* gpu_channel_host, MessageLoop* message_loop, - WebGraphicsContext3DCommandBufferImpl* wgc3dcbi); + const base::WeakPtr<WebGraphicsContext3DCommandBufferImpl>& wgc3dcbi); virtual media::VideoDecodeAccelerator* CreateVideoDecodeAccelerator( media::VideoCodecProfile profile, @@ -59,8 +59,7 @@ class CONTENT_EXPORT RendererGpuVideoDecoderFactories private: // Helper for the constructor to acquire the ContentGLContext on the // compositor thread (when it is enabled). - void AsyncGetContext(WebGraphicsContext3DCommandBufferImpl* wgc3dcbi, - base::WaitableEvent* waiter); + void AsyncGetContext(base::WaitableEvent* waiter); // Async versions of the public methods. They use output parameters instead // of return values and each takes a WaitableEvent* param to signal completion diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index 03d56c3..2e3c8f53 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -724,6 +724,27 @@ void RenderThreadImpl::PostponeIdleNotification() { idle_notifications_to_skip_ = 2; } +base::WeakPtr<WebGraphicsContext3DCommandBufferImpl> +RenderThreadImpl::GetGpuVDAContext3D() { + // If we already handed out a pointer to a context and it's been lost, create + // a new one. + if (gpu_vda_context3d_.get() && + gpu_vda_context3d_->IsCommandBufferContextLost()) { + if (compositor_thread()) { + compositor_thread()->GetWebThread()->message_loop()->DeleteSoon( + FROM_HERE, gpu_vda_context3d_.release()); + } else { + gpu_vda_context3d_.reset(); + } + } + if (!gpu_vda_context3d_.get()) { + gpu_vda_context3d_.reset( + WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( + this, WebKit::WebGraphicsContext3D::Attributes())); + } + return gpu_vda_context3d_->AsWeakPtr(); +} + #if defined(OS_WIN) void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) { Send(new ChildProcessHostMsg_PreCacheFont(log_font)); diff --git a/content/renderer/render_thread_impl.h b/content/renderer/render_thread_impl.h index 62584c2..8a23dde 100644 --- a/content/renderer/render_thread_impl.h +++ b/content/renderer/render_thread_impl.h @@ -38,6 +38,7 @@ class SkBitmap; class VideoCaptureImplManager; struct ViewMsg_New_Params; class WebDatabaseObserverImpl; +class WebGraphicsContext3DCommandBufferImpl; namespace WebKit { class WebMediaStreamCenter; @@ -216,6 +217,13 @@ class CONTENT_EXPORT RenderThreadImpl : public content::RenderThread, // not sent for at least one notification delay. void PostponeIdleNotification(); + // Returns a graphics context shared among all + // RendererGpuVideoDecoderFactories, or NULL on error. Context remains owned + // by this class and must be null-tested before each use to detect context + // loss. The returned WeakPtr<> is only valid on the compositor thread when + // threaded compositing is enabled. + base::WeakPtr<WebGraphicsContext3DCommandBufferImpl> GetGpuVDAContext3D(); + private: virtual bool OnControlMessageReceived(const IPC::Message& msg) OVERRIDE; @@ -294,6 +302,8 @@ class CONTENT_EXPORT RenderThreadImpl : public content::RenderThread, ObserverList<content::RenderProcessObserver> observers_; + scoped_ptr<WebGraphicsContext3DCommandBufferImpl> gpu_vda_context3d_; + DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl); }; diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index b4ff5f5..16837b9 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -2358,18 +2358,11 @@ WebMediaPlayer* RenderViewImpl::createMediaPlayer( collection->AddAudioRenderer(audio_renderer); } - // 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. - // TODO(posciak,fischman): Temporarily remove this path as it triggers - // webk.it/88815. -//#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) -#if 0 - WebGraphicsContext3DCommandBufferImpl* context3d = - WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( - RenderThreadImpl::current(), - WebKit::WebGraphicsContext3D::Attributes()); + base::WeakPtr<WebGraphicsContext3DCommandBufferImpl> context3d = + !CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableAcceleratedVideoDecode) ? + base::WeakPtr<WebGraphicsContext3DCommandBufferImpl>() : + RenderThreadImpl::current()->GetGpuVDAContext3D(); if (context3d) { MessageLoop* factories_loop = RenderThreadImpl::current()->compositor_thread() ? @@ -2385,7 +2378,6 @@ WebMediaPlayer* RenderViewImpl::createMediaPlayer( new RendererGpuVideoDecoderFactories( gpu_channel_host, factories_loop, context3d))); } -#endif WebMediaPlayer* media_player = content::GetContentClient()->renderer()->OverrideCreateWebMediaPlayer( |