OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stdio.h> | 5 #include <stdio.h> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/display/display_info.h" | 9 #include "ash/display/display_info.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "ui/gfx/display.h" | 14 #include "ui/gfx/display.h" |
15 #include "ui/gfx/size_conversions.h" | 15 #include "ui/gfx/size_conversions.h" |
16 #include "ui/gfx/size_f.h" | 16 #include "ui/gfx/size_f.h" |
17 | 17 |
18 #if defined(OS_WIN) | 18 #if defined(OS_WIN) |
19 #include "ui/aura/root_window_host.h" | 19 #include "ui/aura/root_window_host.h" |
20 #endif | 20 #endif |
21 | 21 |
22 namespace ash { | 22 namespace ash { |
23 namespace internal { | 23 namespace internal { |
24 | 24 |
| 25 Resolution::Resolution(const gfx::Size& size, bool interlaced) |
| 26 : size(size), |
| 27 interlaced(interlaced) { |
| 28 } |
| 29 |
25 // satic | 30 // satic |
26 DisplayInfo DisplayInfo::CreateFromSpec(const std::string& spec) { | 31 DisplayInfo DisplayInfo::CreateFromSpec(const std::string& spec) { |
27 return CreateFromSpecWithID(spec, gfx::Display::kInvalidDisplayID); | 32 return CreateFromSpecWithID(spec, gfx::Display::kInvalidDisplayID); |
28 } | 33 } |
29 | 34 |
30 // static | 35 // static |
31 DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec, | 36 DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec, |
32 int64 id) { | 37 int64 id) { |
33 // Default bounds for a display. | 38 // Default bounds for a display. |
34 const int kDefaultHostWindowX = 200; | 39 const int kDefaultHostWindowX = 200; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 146 |
142 void DisplayInfo::Copy(const DisplayInfo& native_info) { | 147 void DisplayInfo::Copy(const DisplayInfo& native_info) { |
143 DCHECK(id_ == native_info.id_); | 148 DCHECK(id_ == native_info.id_); |
144 name_ = native_info.name_; | 149 name_ = native_info.name_; |
145 has_overscan_ = native_info.has_overscan_; | 150 has_overscan_ = native_info.has_overscan_; |
146 | 151 |
147 DCHECK(!native_info.bounds_in_pixel_.IsEmpty()); | 152 DCHECK(!native_info.bounds_in_pixel_.IsEmpty()); |
148 bounds_in_pixel_ = native_info.bounds_in_pixel_; | 153 bounds_in_pixel_ = native_info.bounds_in_pixel_; |
149 size_in_pixel_ = native_info.size_in_pixel_; | 154 size_in_pixel_ = native_info.size_in_pixel_; |
150 device_scale_factor_ = native_info.device_scale_factor_; | 155 device_scale_factor_ = native_info.device_scale_factor_; |
| 156 resolutions_ = native_info.resolutions_; |
151 | 157 |
152 // Copy overscan_insets_in_dip_ if it's not empty. This is for test | 158 // Copy overscan_insets_in_dip_ if it's not empty. This is for test |
153 // cases which use "/o" annotation which sets the overscan inset | 159 // cases which use "/o" annotation which sets the overscan inset |
154 // to native, and that overscan has to be propagated. This does not | 160 // to native, and that overscan has to be propagated. This does not |
155 // happen on the real environment. | 161 // happen on the real environment. |
156 if (!native_info.overscan_insets_in_dip_.empty()) | 162 if (!native_info.overscan_insets_in_dip_.empty()) |
157 overscan_insets_in_dip_ = native_info.overscan_insets_in_dip_; | 163 overscan_insets_in_dip_ = native_info.overscan_insets_in_dip_; |
158 | 164 |
159 // Rotation_ and ui_scale_ are given by preference, or unit | 165 // Rotation_ and ui_scale_ are given by preference, or unit |
160 // tests. Don't copy if this native_info came from | 166 // tests. Don't copy if this native_info came from |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 "overscan=%s, rotation=%d, ui-scale=%f", | 213 "overscan=%s, rotation=%d, ui-scale=%f", |
208 static_cast<long long int>(id_), | 214 static_cast<long long int>(id_), |
209 bounds_in_pixel_.ToString().c_str(), | 215 bounds_in_pixel_.ToString().c_str(), |
210 size_in_pixel_.ToString().c_str(), | 216 size_in_pixel_.ToString().c_str(), |
211 device_scale_factor_, | 217 device_scale_factor_, |
212 overscan_insets_in_dip_.ToString().c_str(), | 218 overscan_insets_in_dip_.ToString().c_str(), |
213 rotation_degree, | 219 rotation_degree, |
214 ui_scale_); | 220 ui_scale_); |
215 } | 221 } |
216 | 222 |
| 223 std::string DisplayInfo::ToFullString() const { |
| 224 std::string resolutions_str; |
| 225 std::vector<Resolution>::const_iterator iter = resolutions_.begin(); |
| 226 for (; iter != resolutions_.end(); ++iter) { |
| 227 if (!resolutions_str.empty()) |
| 228 resolutions_str += ","; |
| 229 resolutions_str += iter->size.ToString(); |
| 230 if (iter->interlaced) |
| 231 resolutions_str += "(i)"; |
| 232 } |
| 233 return ToString() + ", resolutions=" + resolutions_str; |
| 234 } |
| 235 |
217 } // namespace internal | 236 } // namespace internal |
218 } // namespace ash | 237 } // namespace ash |
OLD | NEW |