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 |
79 ui::Compositor* BrowserCompositorViewMac::GetCompositor() const { | 83 ui::Compositor* BrowserCompositorViewMac::GetCompositor() const { |
80 DCHECK(cocoa_view_); | |
81 return [cocoa_view_ compositor]; | 84 return [cocoa_view_ compositor]; |
82 } | 85 } |
83 | 86 |
| 87 bool BrowserCompositorViewMac::HasFrameWithSizeInDIP( |
| 88 const gfx::Size& desired_size_in_dip) const { |
| 89 return [cocoa_view_ hasFrameWithSizeInDIP:desired_size_in_dip]; |
| 90 } |
| 91 |
84 //////////////////////////////////////////////////////////////////////////////// | 92 //////////////////////////////////////////////////////////////////////////////// |
85 // BrowserCompositorViewPlaceholderMac | 93 // BrowserCompositorViewPlaceholderMac |
86 | 94 |
87 BrowserCompositorViewPlaceholderMac::BrowserCompositorViewPlaceholderMac() { | 95 BrowserCompositorViewPlaceholderMac::BrowserCompositorViewPlaceholderMac() { |
88 g_placeholder_count += 1; | 96 g_placeholder_count += 1; |
89 } | 97 } |
90 | 98 |
91 BrowserCompositorViewPlaceholderMac::~BrowserCompositorViewPlaceholderMac() { | 99 BrowserCompositorViewPlaceholderMac::~BrowserCompositorViewPlaceholderMac() { |
92 DCHECK_GT(g_placeholder_count, 0u); | 100 DCHECK_GT(g_placeholder_count, 0u); |
93 g_placeholder_count -= 1; | 101 g_placeholder_count -= 1; |
94 | 102 |
95 // If there are no placeholders allocated, destroy the recyclable | 103 // If there are no placeholders allocated, destroy the recyclable |
96 // BrowserCompositorViewCocoa. | 104 // BrowserCompositorViewCocoa. |
97 if (!g_placeholder_count) { | 105 if (!g_placeholder_count) { |
98 [g_recyclable_cocoa_view.Get() destroyCompositor]; | 106 [g_recyclable_cocoa_view.Get() destroyCompositor]; |
99 g_recyclable_cocoa_view.Get().reset(); | 107 g_recyclable_cocoa_view.Get().reset(); |
100 } | 108 } |
101 } | 109 } |
102 | 110 |
103 } // namespace content | 111 } // namespace content |
OLD | NEW |