| 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/renderer_host/browser_compositor_view_mac.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
| 13 #include "content/browser/compositor/image_transport_factory.h" | 13 #include "content/browser/compositor/image_transport_factory.h" |
| 14 #include "content/public/browser/context_factory.h" | 14 #include "content/public/browser/context_factory.h" |
| 15 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" | 15 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" |
| 16 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" | 16 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" |
| 17 | 17 |
| 18 //////////////////////////////////////////////////////////////////////////////// | 18 //////////////////////////////////////////////////////////////////////////////// |
| 19 // BrowserCompositorMac | 19 // BrowserCompositorMac |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // Set when no browser compositors should remain alive. | 25 // Set when no browser compositors should remain alive. |
| 26 bool g_has_shut_down = false; | 26 bool g_has_shut_down = false; |
| 27 | 27 |
| 28 // The number of placeholder objects allocated. If this reaches zero, then | 28 // The number of placeholder objects allocated. If this reaches zero, then |
| 29 // the BrowserCompositorMac being held on to for recycling, | 29 // the BrowserCompositorMac being held on to for recycling, |
| 30 // |g_recyclable_browser_compositor|, will be freed. | 30 // |g_recyclable_browser_compositor|, will be freed. |
| 31 uint32_t g_placeholder_count = 0; | 31 uint32_t g_placeholder_count = 0; |
| 32 | 32 |
| 33 // A spare BrowserCompositorMac kept around for recycling. | 33 // A spare BrowserCompositorMac kept around for recycling. |
| 34 base::LazyInstance<scoped_ptr<BrowserCompositorMac>> | 34 base::LazyInstance<scoped_ptr<BrowserCompositorMac>> |
| 35 g_recyclable_browser_compositor; | 35 g_recyclable_browser_compositor; |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 BrowserCompositorMac::BrowserCompositorMac() | 39 BrowserCompositorMac::BrowserCompositorMac() |
| 40 : accelerated_widget_mac_(new ui::AcceleratedWidgetMac()), | 40 : accelerated_widget_mac_(new ui::AcceleratedWidgetMac()), |
| 41 compositor_(content::GetContextFactory(), | 41 compositor_(content::GetContextFactory(), |
| 42 ui::WindowResizeHelperMac::Get()->task_runner()) { | 42 ui::WindowResizeHelperMac::Get()->task_runner()) { |
| 43 compositor_.SetAcceleratedWidget( | 43 compositor_.SetAcceleratedWidget( |
| 44 accelerated_widget_mac_->accelerated_widget()); | 44 accelerated_widget_mac_->accelerated_widget()); |
| 45 compositor_.SetLocksWillTimeOut(false); | 45 compositor_.SetLocksWillTimeOut(false); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 DCHECK_GT(g_placeholder_count, 0u); | 111 DCHECK_GT(g_placeholder_count, 0u); |
| 112 g_placeholder_count -= 1; | 112 g_placeholder_count -= 1; |
| 113 | 113 |
| 114 // If there are no placeholders allocated, destroy the recyclable | 114 // If there are no placeholders allocated, destroy the recyclable |
| 115 // BrowserCompositorMac. | 115 // BrowserCompositorMac. |
| 116 if (!g_placeholder_count) | 116 if (!g_placeholder_count) |
| 117 g_recyclable_browser_compositor.Get().reset(); | 117 g_recyclable_browser_compositor.Get().reset(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace content | 120 } // namespace content |
| OLD | NEW |