diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-22 22:49:34 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-22 22:49:34 +0000 |
commit | d92bec4353b077c5fef2d77d13ba7b3ae5e1d248 (patch) | |
tree | 0465e1ca7e24b75d17c23bea9c929ada64e54484 /chrome/plugin | |
parent | 921720c8059acd219da442611d226330d9537083 (diff) | |
download | chromium_src-d92bec4353b077c5fef2d77d13ba7b3ae5e1d248.zip chromium_src-d92bec4353b077c5fef2d77d13ba7b3ae5e1d248.tar.gz chromium_src-d92bec4353b077c5fef2d77d13ba7b3ae5e1d248.tar.bz2 |
Make accelerated Mac plugins handle GL initialization failure instead of crashing
BUG=62565
TEST=Run with --use-gl=osmesa on 10.6, and open a YouTube video. The plugin should not crash, and audion should still play (but without video).
Review URL: http://codereview.chromium.org/5233005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67016 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin')
-rw-r--r-- | chrome/plugin/webplugin_accelerated_surface_proxy_mac.cc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/chrome/plugin/webplugin_accelerated_surface_proxy_mac.cc b/chrome/plugin/webplugin_accelerated_surface_proxy_mac.cc index 6e3540e..9dcacb9 100644 --- a/chrome/plugin/webplugin_accelerated_surface_proxy_mac.cc +++ b/chrome/plugin/webplugin_accelerated_surface_proxy_mac.cc @@ -15,7 +15,13 @@ WebPluginAcceleratedSurfaceProxy::WebPluginAcceleratedSurfaceProxy( : plugin_proxy_(plugin_proxy), window_handle_(NULL) { surface_ = new AcceleratedSurface; - surface_->Initialize(NULL, true); + // It's possible for OpenGL to fail to initialze (e.g., if an incompatible + // mode is forced via flags), so handle that gracefully. + if (!surface_->Initialize(NULL, true)) { + delete surface_; + surface_ = NULL; + return; + } // Only used for 10.5 support, but harmless on 10.6+. surface_->SetTransportDIBAllocAndFree( @@ -37,6 +43,9 @@ void WebPluginAcceleratedSurfaceProxy::SetWindowHandle( } void WebPluginAcceleratedSurfaceProxy::SetSize(const gfx::Size& size) { + if (!surface_) + return; + uint64 io_surface_id = surface_->SetSurfaceSize(size); if (io_surface_id) { plugin_proxy_->SetAcceleratedSurface(window_handle_, size, io_surface_id); @@ -49,15 +58,21 @@ void WebPluginAcceleratedSurfaceProxy::SetSize(const gfx::Size& size) { } CGLContextObj WebPluginAcceleratedSurfaceProxy::context() { - return surface_->context(); + return surface_ ? surface_->context() : NULL; } void WebPluginAcceleratedSurfaceProxy::StartDrawing() { + if (!surface_) + return; + surface_->MakeCurrent(); surface_->Clear(gfx::Rect(surface_->GetSize())); } void WebPluginAcceleratedSurfaceProxy::EndDrawing() { + if (!surface_) + return; + surface_->SwapBuffers(); plugin_proxy_->AcceleratedFrameBuffersDidSwap( window_handle_, surface_->GetSurfaceId()); |