| 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/location.h" |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 12 | 14 |
| 13 namespace base { | 15 namespace base { |
| 14 | 16 |
| 15 template<> | 17 template<> |
| 16 struct ScopedTypeRefTraits<CVDisplayLinkRef> { | 18 struct ScopedTypeRefTraits<CVDisplayLinkRef> { |
| 17 static CVDisplayLinkRef InvalidValue() { return nullptr; } | 19 static CVDisplayLinkRef InvalidValue() { return nullptr; } |
| 18 static CVDisplayLinkRef Retain(CVDisplayLinkRef object) { | 20 static CVDisplayLinkRef Retain(CVDisplayLinkRef object) { |
| 19 return CVDisplayLinkRetain(object); | 21 return CVDisplayLinkRetain(object); |
| 20 } | 22 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 LOG(ERROR) << "CVDisplayLinkSetOutputCallback failed: " << ret; | 76 LOG(ERROR) << "CVDisplayLinkSetOutputCallback failed: " << ret; |
| 75 return NULL; | 77 return NULL; |
| 76 } | 78 } |
| 77 | 79 |
| 78 return display_link_mac; | 80 return display_link_mac; |
| 79 } | 81 } |
| 80 | 82 |
| 81 DisplayLinkMac::DisplayLinkMac( | 83 DisplayLinkMac::DisplayLinkMac( |
| 82 CGDirectDisplayID display_id, | 84 CGDirectDisplayID display_id, |
| 83 base::ScopedTypeRef<CVDisplayLinkRef> display_link) | 85 base::ScopedTypeRef<CVDisplayLinkRef> display_link) |
| 84 : main_thread_task_runner_( | 86 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 85 base::MessageLoop::current()->task_runner()), | 87 display_id_(display_id), |
| 86 display_id_(display_id), | 88 display_link_(display_link), |
| 87 display_link_(display_link), | 89 timebase_and_interval_valid_(false) { |
| 88 timebase_and_interval_valid_(false) { | |
| 89 DCHECK(display_map_.Get().find(display_id) == display_map_.Get().end()); | 90 DCHECK(display_map_.Get().find(display_id) == display_map_.Get().end()); |
| 90 if (display_map_.Get().empty()) { | 91 if (display_map_.Get().empty()) { |
| 91 CGError register_error = CGDisplayRegisterReconfigurationCallback( | 92 CGError register_error = CGDisplayRegisterReconfigurationCallback( |
| 92 DisplayReconfigurationCallBack, nullptr); | 93 DisplayReconfigurationCallBack, nullptr); |
| 93 DPLOG_IF(ERROR, register_error != kCGErrorSuccess) | 94 DPLOG_IF(ERROR, register_error != kCGErrorSuccess) |
| 94 << "CGDisplayRegisterReconfigurationCallback: " | 95 << "CGDisplayRegisterReconfigurationCallback: " |
| 95 << register_error; | 96 << register_error; |
| 96 } | 97 } |
| 97 display_map_.Get().insert(std::make_pair(display_id_, this)); | 98 display_map_.Get().insert(std::make_pair(display_id_, this)); |
| 98 } | 99 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 DisplayLinkMac* display_link_mac = found->second; | 212 DisplayLinkMac* display_link_mac = found->second; |
| 212 display_link_mac->timebase_and_interval_valid_ = false; | 213 display_link_mac->timebase_and_interval_valid_ = false; |
| 213 } | 214 } |
| 214 | 215 |
| 215 // static | 216 // static |
| 216 base::LazyInstance<DisplayLinkMac::DisplayMap> | 217 base::LazyInstance<DisplayLinkMac::DisplayMap> |
| 217 DisplayLinkMac::display_map_ = LAZY_INSTANCE_INITIALIZER; | 218 DisplayLinkMac::display_map_ = LAZY_INSTANCE_INITIALIZER; |
| 218 | 219 |
| 219 } // ui | 220 } // ui |
| 220 | 221 |
| OLD | NEW |