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 "ui/accelerated_widget_mac/display_link_mac.h" | 5 #include "ui/accelerated_widget_mac/display_link_mac.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 | 10 |
11 namespace base { | 11 namespace base { |
12 | 12 |
13 template<> | 13 template<> |
14 struct ScopedTypeRefTraits<CVDisplayLinkRef> { | 14 struct ScopedTypeRefTraits<CVDisplayLinkRef> { |
15 static void Retain(CVDisplayLinkRef object) { | 15 static void Retain(CVDisplayLinkRef object) { |
16 CVDisplayLinkRetain(object); | 16 CVDisplayLinkRetain(object); |
17 } | 17 } |
18 static void Release(CVDisplayLinkRef object) { | 18 static void Release(CVDisplayLinkRef object) { |
19 CVDisplayLinkRelease(object); | 19 CVDisplayLinkRelease(object); |
20 } | 20 } |
21 }; | 21 }; |
22 | 22 |
23 } // namespace base | 23 } // namespace base |
24 | 24 |
25 namespace ui { | 25 namespace ui { |
26 | 26 |
27 // static | 27 // static |
28 scoped_refptr<DisplayLinkMac> DisplayLinkMac::GetForDisplay( | 28 scoped_refptr<DisplayLinkMac> DisplayLinkMac::GetForDisplay( |
29 CGDirectDisplayID display_id) { | 29 CGDirectDisplayID display_id) { |
30 if (!display_id) | |
31 return NULL; | |
tapted
2015/08/06 00:56:49
nit: nullptr
ccameron
2015/08/06 01:42:47
Done.
| |
32 | |
30 // Return the existing display link for this display, if it exists. | 33 // Return the existing display link for this display, if it exists. |
31 DisplayMap::iterator found = display_map_.Get().find(display_id); | 34 DisplayMap::iterator found = display_map_.Get().find(display_id); |
32 if (found != display_map_.Get().end()) { | 35 if (found != display_map_.Get().end()) { |
33 return found->second; | 36 return found->second; |
34 } | 37 } |
35 | 38 |
36 CVReturn ret = kCVReturnSuccess; | 39 CVReturn ret = kCVReturnSuccess; |
37 | 40 |
38 base::ScopedTypeRef<CVDisplayLinkRef> display_link; | 41 base::ScopedTypeRef<CVDisplayLinkRef> display_link; |
39 ret = CVDisplayLinkCreateWithCGDisplay( | 42 ret = CVDisplayLinkCreateWithCGDisplay( |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 DisplayLinkMac* display_link_mac = found->second; | 178 DisplayLinkMac* display_link_mac = found->second; |
176 display_link_mac->timebase_and_interval_valid_ = false; | 179 display_link_mac->timebase_and_interval_valid_ = false; |
177 } | 180 } |
178 | 181 |
179 // static | 182 // static |
180 base::LazyInstance<DisplayLinkMac::DisplayMap> | 183 base::LazyInstance<DisplayLinkMac::DisplayMap> |
181 DisplayLinkMac::display_map_ = LAZY_INSTANCE_INITIALIZER; | 184 DisplayLinkMac::display_map_ = LAZY_INSTANCE_INITIALIZER; |
182 | 185 |
183 } // ui | 186 } // ui |
184 | 187 |
OLD | NEW |