Index: content/browser/renderer_host/compositing_iosurface_context_mac.mm |
diff --git a/content/browser/renderer_host/compositing_iosurface_context_mac.mm b/content/browser/renderer_host/compositing_iosurface_context_mac.mm |
index 95620367b0e3c74bf442be7eae6e0f51eb924050..fecab509325fd0c1f8d6cd3cb840afdf488ae973 100644 |
--- a/content/browser/renderer_host/compositing_iosurface_context_mac.mm |
+++ b/content/browser/renderer_host/compositing_iosurface_context_mac.mm |
@@ -12,6 +12,7 @@ |
#include "base/debug/trace_event.h" |
#include "base/logging.h" |
#include "content/browser/renderer_host/compositing_iosurface_shader_programs_mac.h" |
+#include "content/browser/gpu/gpu_data_manager_impl.h" |
#include "ui/base/ui_base_switches.h" |
#include "ui/gl/gl_switches.h" |
#include "ui/gl/gpu_switching_manager.h" |
@@ -182,9 +183,13 @@ CompositingIOSurfaceContext::CompositingIOSurfaceContext( |
poisoned_(false) { |
DCHECK(window_map()->find(window_number_) == window_map()->end()); |
window_map()->insert(std::make_pair(window_number_, this)); |
+ |
+ GpuDataManager::GetInstance()->AddObserver(this); |
} |
CompositingIOSurfaceContext::~CompositingIOSurfaceContext() { |
+ GpuDataManager::GetInstance()->RemoveObserver(this); |
+ |
{ |
gfx::ScopedCGLSetCurrentContext scoped_set_current_context(cgl_context_); |
shader_program_cache_->Reset(); |
@@ -206,6 +211,13 @@ NSOpenGLContext* CompositingIOSurfaceContext::nsgl_context() const { |
return nsgl_context_; |
} |
+void CompositingIOSurfaceContext::OnGpuSwitching() { |
+ // Recreate all browser-side GL contexts whenever the GPU switches. If this |
+ // is not done, performance will suffer. |
+ // http://crbug.com/361493 |
+ PoisonContextAndSharegroup(); |
+} |
+ |
// static |
CompositingIOSurfaceContext::WindowMap* |
CompositingIOSurfaceContext::window_map() { |