| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/compositor/browser_compositor_view_mac.h" | 5 #include "content/browser/compositor/browser_compositor_view_mac.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 8 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| 9 #include "content/browser/compositor/image_transport_factory.h" | 11 #include "content/browser/compositor/image_transport_factory.h" |
| 10 #include "content/browser/gpu/gpu_data_manager_impl.h" | 12 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 11 #include "content/public/browser/context_factory.h" | 13 #include "content/public/browser/context_factory.h" |
| 12 #include "gpu/config/gpu_driver_bug_workaround_type.h" | 14 #include "gpu/config/gpu_driver_bug_workaround_type.h" |
| 13 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" | 15 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" |
| 14 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" | 16 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" |
| 15 | 17 |
| 16 //////////////////////////////////////////////////////////////////////////////// | 18 //////////////////////////////////////////////////////////////////////////////// |
| 17 // BrowserCompositorMac | 19 // BrowserCompositorMac |
| 18 | 20 |
| 19 namespace content { | 21 namespace content { |
| 20 | 22 |
| 21 namespace { | 23 namespace { |
| 22 | 24 |
| 23 // Set when no browser compositors should remain alive. | 25 // Set when no browser compositors should remain alive. |
| 24 bool g_has_shut_down = false; | 26 bool g_has_shut_down = false; |
| 25 | 27 |
| 26 // The number of placeholder objects allocated. If this reaches zero, then | 28 // The number of placeholder objects allocated. If this reaches zero, then |
| 27 // the BrowserCompositorMac being held on to for recycling, | 29 // the BrowserCompositorMac being held on to for recycling, |
| 28 // |g_recyclable_browser_compositor|, will be freed. | 30 // |g_recyclable_browser_compositor|, will be freed. |
| 29 uint32 g_placeholder_count = 0; | 31 uint32_t g_placeholder_count = 0; |
| 30 | 32 |
| 31 // A spare BrowserCompositorMac kept around for recycling. | 33 // A spare BrowserCompositorMac kept around for recycling. |
| 32 base::LazyInstance<scoped_ptr<BrowserCompositorMac>> | 34 base::LazyInstance<scoped_ptr<BrowserCompositorMac>> |
| 33 g_recyclable_browser_compositor; | 35 g_recyclable_browser_compositor; |
| 34 | 36 |
| 35 bool WidgetNeedsGLFinishWorkaround() { | 37 bool WidgetNeedsGLFinishWorkaround() { |
| 36 return GpuDataManagerImpl::GetInstance()->IsDriverBugWorkaroundActive( | 38 return GpuDataManagerImpl::GetInstance()->IsDriverBugWorkaroundActive( |
| 37 gpu::FORCE_GL_FINISH_AFTER_COMPOSITING); | 39 gpu::FORCE_GL_FINISH_AFTER_COMPOSITING); |
| 38 } | 40 } |
| 39 | 41 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 DCHECK_GT(g_placeholder_count, 0u); | 117 DCHECK_GT(g_placeholder_count, 0u); |
| 116 g_placeholder_count -= 1; | 118 g_placeholder_count -= 1; |
| 117 | 119 |
| 118 // If there are no placeholders allocated, destroy the recyclable | 120 // If there are no placeholders allocated, destroy the recyclable |
| 119 // BrowserCompositorMac. | 121 // BrowserCompositorMac. |
| 120 if (!g_placeholder_count) | 122 if (!g_placeholder_count) |
| 121 g_recyclable_browser_compositor.Get().reset(); | 123 g_recyclable_browser_compositor.Get().reset(); |
| 122 } | 124 } |
| 123 | 125 |
| 124 } // namespace content | 126 } // namespace content |
| OLD | NEW |