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_view_private_mac.h" | 9 #include "content/browser/compositor/browser_compositor_view_private_mac.h" |
10 | 10 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 swap(g_recyclable_cocoa_view.Get(), cocoa_view_); | 69 swap(g_recyclable_cocoa_view.Get(), cocoa_view_); |
70 | 70 |
71 // If there are no placeholders allocated, destroy the recyclable | 71 // If there are no placeholders allocated, destroy the recyclable |
72 // BrowserCompositorViewCocoa that we just populated. | 72 // BrowserCompositorViewCocoa that we just populated. |
73 if (!g_placeholder_count) { | 73 if (!g_placeholder_count) { |
74 [g_recyclable_cocoa_view.Get() destroyCompositor]; | 74 [g_recyclable_cocoa_view.Get() destroyCompositor]; |
75 g_recyclable_cocoa_view.Get().reset(); | 75 g_recyclable_cocoa_view.Get().reset(); |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 NSView* BrowserCompositorViewMac::GetView() const { | |
80 return cocoa_view_; | |
81 } | |
82 | |
83 ui::Compositor* BrowserCompositorViewMac::GetCompositor() const { | 79 ui::Compositor* BrowserCompositorViewMac::GetCompositor() const { |
| 80 DCHECK(cocoa_view_); |
84 return [cocoa_view_ compositor]; | 81 return [cocoa_view_ compositor]; |
85 } | 82 } |
86 | 83 |
87 bool BrowserCompositorViewMac::HasFrameWithSizeInDIP( | |
88 const gfx::Size& desired_size_in_dip) const { | |
89 return [cocoa_view_ hasFrameWithSizeInDIP:desired_size_in_dip]; | |
90 } | |
91 | |
92 //////////////////////////////////////////////////////////////////////////////// | 84 //////////////////////////////////////////////////////////////////////////////// |
93 // BrowserCompositorViewPlaceholderMac | 85 // BrowserCompositorViewPlaceholderMac |
94 | 86 |
95 BrowserCompositorViewPlaceholderMac::BrowserCompositorViewPlaceholderMac() { | 87 BrowserCompositorViewPlaceholderMac::BrowserCompositorViewPlaceholderMac() { |
96 g_placeholder_count += 1; | 88 g_placeholder_count += 1; |
97 } | 89 } |
98 | 90 |
99 BrowserCompositorViewPlaceholderMac::~BrowserCompositorViewPlaceholderMac() { | 91 BrowserCompositorViewPlaceholderMac::~BrowserCompositorViewPlaceholderMac() { |
100 DCHECK_GT(g_placeholder_count, 0u); | 92 DCHECK_GT(g_placeholder_count, 0u); |
101 g_placeholder_count -= 1; | 93 g_placeholder_count -= 1; |
102 | 94 |
103 // If there are no placeholders allocated, destroy the recyclable | 95 // If there are no placeholders allocated, destroy the recyclable |
104 // BrowserCompositorViewCocoa. | 96 // BrowserCompositorViewCocoa. |
105 if (!g_placeholder_count) { | 97 if (!g_placeholder_count) { |
106 [g_recyclable_cocoa_view.Get() destroyCompositor]; | 98 [g_recyclable_cocoa_view.Get() destroyCompositor]; |
107 g_recyclable_cocoa_view.Get().reset(); | 99 g_recyclable_cocoa_view.Get().reset(); |
108 } | 100 } |
109 } | 101 } |
110 | 102 |
111 } // namespace content | 103 } // namespace content |
OLD | NEW |