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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 DPLOG_IF(ERROR, register_error != kCGErrorSuccess) | 79 DPLOG_IF(ERROR, register_error != kCGErrorSuccess) |
80 << "CGDisplayRegisterReconfigurationCallback: " | 80 << "CGDisplayRegisterReconfigurationCallback: " |
81 << register_error; | 81 << register_error; |
82 } | 82 } |
83 display_map_.Get().insert(std::make_pair(display_id_, this)); | 83 display_map_.Get().insert(std::make_pair(display_id_, this)); |
84 } | 84 } |
85 | 85 |
86 DisplayLinkMac::~DisplayLinkMac() { | 86 DisplayLinkMac::~DisplayLinkMac() { |
87 StopDisplayLink(); | 87 StopDisplayLink(); |
88 | 88 |
89 // Usually |display_link_| holds the last reference to CVDisplayLinkRef, but | |
90 // that's not guaranteed, so it might not free all resources after the | |
91 // destructor completes. Ensure the callback is cleared out regardless. | |
ccameron
2016/01/25 18:04:17
Maybe reference a bug # for the crashes?
tapted
2016/01/26 23:36:49
Done.
| |
92 CVReturn ret = | |
93 CVDisplayLinkSetOutputCallback(display_link_, nullptr, nullptr); | |
94 DCHECK_EQ(kCGErrorSuccess, ret); | |
95 | |
89 DisplayMap::iterator found = display_map_.Get().find(display_id_); | 96 DisplayMap::iterator found = display_map_.Get().find(display_id_); |
90 DCHECK(found != display_map_.Get().end()); | 97 DCHECK(found != display_map_.Get().end()); |
91 DCHECK(found->second == this); | 98 DCHECK(found->second == this); |
92 display_map_.Get().erase(found); | 99 display_map_.Get().erase(found); |
93 if (display_map_.Get().empty()) { | 100 if (display_map_.Get().empty()) { |
94 CGError remove_error = CGDisplayRemoveReconfigurationCallback( | 101 CGError remove_error = CGDisplayRemoveReconfigurationCallback( |
95 DisplayReconfigurationCallBack, nullptr); | 102 DisplayReconfigurationCallBack, nullptr); |
96 DPLOG_IF(ERROR, remove_error != kCGErrorSuccess) | 103 DPLOG_IF(ERROR, remove_error != kCGErrorSuccess) |
97 << "CGDisplayRemoveReconfigurationCallback: " | 104 << "CGDisplayRemoveReconfigurationCallback: " |
98 << remove_error; | 105 << remove_error; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 DisplayLinkMac* display_link_mac = found->second; | 196 DisplayLinkMac* display_link_mac = found->second; |
190 display_link_mac->timebase_and_interval_valid_ = false; | 197 display_link_mac->timebase_and_interval_valid_ = false; |
191 } | 198 } |
192 | 199 |
193 // static | 200 // static |
194 base::LazyInstance<DisplayLinkMac::DisplayMap> | 201 base::LazyInstance<DisplayLinkMac::DisplayMap> |
195 DisplayLinkMac::display_map_ = LAZY_INSTANCE_INITIALIZER; | 202 DisplayLinkMac::display_map_ = LAZY_INSTANCE_INITIALIZER; |
196 | 203 |
197 } // ui | 204 } // ui |
198 | 205 |
OLD | NEW |