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 "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "content/browser/compositor/browser_compositor_ca_layer_tree_mac.h" | 9 #include "content/browser/gpu/gpu_data_manager_impl.h" |
10 #include "content/browser/renderer_host/render_widget_resize_helper.h" | 10 #include "content/browser/renderer_host/render_widget_resize_helper.h" |
11 #include "content/public/browser/context_factory.h" | 11 #include "content/public/browser/context_factory.h" |
| 12 #include "gpu/config/gpu_driver_bug_workaround_type.h" |
| 13 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" |
12 | 14 |
13 //////////////////////////////////////////////////////////////////////////////// | 15 //////////////////////////////////////////////////////////////////////////////// |
14 // BrowserCompositorMac | 16 // BrowserCompositorMac |
15 | 17 |
16 namespace content { | 18 namespace content { |
17 | 19 |
18 namespace { | 20 namespace { |
19 | 21 |
20 // The number of placeholder objects allocated. If this reaches zero, then | 22 // The number of placeholder objects allocated. If this reaches zero, then |
21 // the BrowserCompositorMac being held on to for recycling, | 23 // the BrowserCompositorMac being held on to for recycling, |
22 // |g_recyclable_browser_compositor|, will be freed. | 24 // |g_recyclable_browser_compositor|, will be freed. |
23 uint32 g_placeholder_count = 0; | 25 uint32 g_placeholder_count = 0; |
24 | 26 |
25 // A spare BrowserCompositorMac kept around for recycling. | 27 // A spare BrowserCompositorMac kept around for recycling. |
26 base::LazyInstance<scoped_ptr<BrowserCompositorMac>> | 28 base::LazyInstance<scoped_ptr<BrowserCompositorMac>> |
27 g_recyclable_browser_compositor; | 29 g_recyclable_browser_compositor; |
28 | 30 |
| 31 bool WidgetNeedsGLFinishWorkaround() { |
| 32 return GpuDataManagerImpl::GetInstance()->IsDriverBugWorkaroundActive( |
| 33 gpu::FORCE_GL_FINISH_AFTER_COMPOSITING); |
| 34 } |
| 35 |
29 } // namespace | 36 } // namespace |
30 | 37 |
31 BrowserCompositorMac::BrowserCompositorMac() | 38 BrowserCompositorMac::BrowserCompositorMac() |
32 : compositor_( | 39 : accelerated_widget_mac_(WidgetNeedsGLFinishWorkaround()), |
| 40 compositor_( |
33 accelerated_widget_mac_.accelerated_widget(), | 41 accelerated_widget_mac_.accelerated_widget(), |
34 content::GetContextFactory(), | 42 content::GetContextFactory(), |
35 RenderWidgetResizeHelper::Get()->task_runner()) { | 43 RenderWidgetResizeHelper::Get()->task_runner()) { |
36 compositor_.SetVisible(false); | 44 compositor_.SetVisible(false); |
37 } | 45 } |
38 | 46 |
39 // static | 47 // static |
40 scoped_ptr<BrowserCompositorMac> BrowserCompositorMac::Create() { | 48 scoped_ptr<BrowserCompositorMac> BrowserCompositorMac::Create() { |
41 if (g_recyclable_browser_compositor.Get()) | 49 if (g_recyclable_browser_compositor.Get()) |
42 return g_recyclable_browser_compositor.Get().Pass(); | 50 return g_recyclable_browser_compositor.Get().Pass(); |
(...skipping 25 matching lines...) Expand all Loading... |
68 DCHECK_GT(g_placeholder_count, 0u); | 76 DCHECK_GT(g_placeholder_count, 0u); |
69 g_placeholder_count -= 1; | 77 g_placeholder_count -= 1; |
70 | 78 |
71 // If there are no placeholders allocated, destroy the recyclable | 79 // If there are no placeholders allocated, destroy the recyclable |
72 // BrowserCompositorMac. | 80 // BrowserCompositorMac. |
73 if (!g_placeholder_count) | 81 if (!g_placeholder_count) |
74 g_recyclable_browser_compositor.Get().reset(); | 82 g_recyclable_browser_compositor.Get().reset(); |
75 } | 83 } |
76 | 84 |
77 } // namespace content | 85 } // namespace content |
OLD | NEW |