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..09dab3bf07a5c7121a13abff21f06cd6881fabf3 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/public/browser/gpu_data_manager.h" |
Zhenyao Mo
2014/04/09 22:24:24
Usually inside content side, we directly use gpu_d
ccameron
2014/04/09 22:37:28
Done.
|
#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)); |
+ |
+ content::GpuDataManager::GetInstance()->AddObserver(this); |
Zhenyao Mo
2014/04/09 22:24:24
nit:no need for content namespace, and use GpuData
ccameron
2014/04/09 22:37:28
Done.
|
} |
CompositingIOSurfaceContext::~CompositingIOSurfaceContext() { |
+ content::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() { |