Chromium Code Reviews| 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& s, bool i) | |
| 26 : size(s), interlaced(i) { | |
|
Daniel Erat
2013/07/31 17:34:05
nit: one member per line if they don't all fit on
oshima
2013/07/31 21:59:49
Done.
| |
| 27 } | |
| 28 | |
| 25 // satic | 29 // satic |
| 26 DisplayInfo DisplayInfo::CreateFromSpec(const std::string& spec) { | 30 DisplayInfo DisplayInfo::CreateFromSpec(const std::string& spec) { |
| 27 return CreateFromSpecWithID(spec, gfx::Display::kInvalidDisplayID); | 31 return CreateFromSpecWithID(spec, gfx::Display::kInvalidDisplayID); |
| 28 } | 32 } |
| 29 | 33 |
| 30 // static | 34 // static |
| 31 DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec, | 35 DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec, |
| 32 int64 id) { | 36 int64 id) { |
| 33 // Default bounds for a display. | 37 // Default bounds for a display. |
| 34 const int kDefaultHostWindowX = 200; | 38 const int kDefaultHostWindowX = 200; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 | 145 |
| 142 void DisplayInfo::Copy(const DisplayInfo& native_info) { | 146 void DisplayInfo::Copy(const DisplayInfo& native_info) { |
| 143 DCHECK(id_ == native_info.id_); | 147 DCHECK(id_ == native_info.id_); |
| 144 name_ = native_info.name_; | 148 name_ = native_info.name_; |
| 145 has_overscan_ = native_info.has_overscan_; | 149 has_overscan_ = native_info.has_overscan_; |
| 146 | 150 |
| 147 DCHECK(!native_info.bounds_in_pixel_.IsEmpty()); | 151 DCHECK(!native_info.bounds_in_pixel_.IsEmpty()); |
| 148 bounds_in_pixel_ = native_info.bounds_in_pixel_; | 152 bounds_in_pixel_ = native_info.bounds_in_pixel_; |
| 149 size_in_pixel_ = native_info.size_in_pixel_; | 153 size_in_pixel_ = native_info.size_in_pixel_; |
| 150 device_scale_factor_ = native_info.device_scale_factor_; | 154 device_scale_factor_ = native_info.device_scale_factor_; |
| 155 resolutions_ = native_info.resolutions_; | |
| 151 | 156 |
| 152 // Copy overscan_insets_in_dip_ if it's not empty. This is for test | 157 // 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 | 158 // cases which use "/o" annotation which sets the overscan inset |
| 154 // to native, and that overscan has to be propagated. This does not | 159 // to native, and that overscan has to be propagated. This does not |
| 155 // happen on the real environment. | 160 // happen on the real environment. |
| 156 if (!native_info.overscan_insets_in_dip_.empty()) | 161 if (!native_info.overscan_insets_in_dip_.empty()) |
| 157 overscan_insets_in_dip_ = native_info.overscan_insets_in_dip_; | 162 overscan_insets_in_dip_ = native_info.overscan_insets_in_dip_; |
| 158 | 163 |
| 159 // Rotation_ and ui_scale_ are given by preference, or unit | 164 // Rotation_ and ui_scale_ are given by preference, or unit |
| 160 // tests. Don't copy if this native_info came from | 165 // 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", | 212 "overscan=%s, rotation=%d, ui-scale=%f", |
| 208 static_cast<long long int>(id_), | 213 static_cast<long long int>(id_), |
| 209 bounds_in_pixel_.ToString().c_str(), | 214 bounds_in_pixel_.ToString().c_str(), |
| 210 size_in_pixel_.ToString().c_str(), | 215 size_in_pixel_.ToString().c_str(), |
| 211 device_scale_factor_, | 216 device_scale_factor_, |
| 212 overscan_insets_in_dip_.ToString().c_str(), | 217 overscan_insets_in_dip_.ToString().c_str(), |
| 213 rotation_degree, | 218 rotation_degree, |
| 214 ui_scale_); | 219 ui_scale_); |
| 215 } | 220 } |
| 216 | 221 |
| 222 std::string DisplayInfo::ToFullString() const { | |
| 223 std::string resolutions_str; | |
| 224 std::vector<Resolution>::const_iterator iter = resolutions_.begin(); | |
| 225 for (; iter != resolutions_.end(); ++iter) { | |
| 226 resolutions_str += "," + iter->size.ToString(); | |
|
Daniel Erat
2013/07/31 17:34:05
shouldn't you test for !resolutions_str.empty() be
oshima
2013/07/31 21:59:49
Done.
| |
| 227 if (iter->interlaced) | |
| 228 resolutions_str += "(i)"; | |
| 229 } | |
| 230 return ToString() + ", resolutions=" + resolutions_str; | |
| 231 } | |
| 232 | |
| 217 } // namespace internal | 233 } // namespace internal |
| 218 } // namespace ash | 234 } // namespace ash |
| OLD | NEW |