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" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 DVLOG(1) << "DisplayInfoFromSpec info=" << display_info.ToString() | 131 DVLOG(1) << "DisplayInfoFromSpec info=" << display_info.ToString() |
132 << ", spec=" << spec; | 132 << ", spec=" << spec; |
133 return display_info; | 133 return display_info; |
134 } | 134 } |
135 | 135 |
136 DisplayInfo::DisplayInfo() | 136 DisplayInfo::DisplayInfo() |
137 : id_(gfx::Display::kInvalidDisplayID), | 137 : id_(gfx::Display::kInvalidDisplayID), |
138 has_overscan_(false), | 138 has_overscan_(false), |
139 rotation_(gfx::Display::ROTATE_0), | 139 rotation_(gfx::Display::ROTATE_0), |
| 140 touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), |
140 device_scale_factor_(1.0f), | 141 device_scale_factor_(1.0f), |
141 overscan_insets_in_dip_(0, 0, 0, 0), | 142 overscan_insets_in_dip_(0, 0, 0, 0), |
142 ui_scale_(1.0f), | 143 ui_scale_(1.0f), |
143 native_(false) { | 144 native_(false) { |
144 } | 145 } |
145 | 146 |
146 DisplayInfo::DisplayInfo(int64 id, | 147 DisplayInfo::DisplayInfo(int64 id, |
147 const std::string& name, | 148 const std::string& name, |
148 bool has_overscan) | 149 bool has_overscan) |
149 : id_(id), | 150 : id_(id), |
150 name_(name), | 151 name_(name), |
151 has_overscan_(has_overscan), | 152 has_overscan_(has_overscan), |
152 rotation_(gfx::Display::ROTATE_0), | 153 rotation_(gfx::Display::ROTATE_0), |
| 154 touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), |
153 device_scale_factor_(1.0f), | 155 device_scale_factor_(1.0f), |
154 overscan_insets_in_dip_(0, 0, 0, 0), | 156 overscan_insets_in_dip_(0, 0, 0, 0), |
155 ui_scale_(1.0f), | 157 ui_scale_(1.0f), |
156 native_(false) { | 158 native_(false) { |
157 } | 159 } |
158 | 160 |
159 DisplayInfo::~DisplayInfo() { | 161 DisplayInfo::~DisplayInfo() { |
160 } | 162 } |
161 | 163 |
162 void DisplayInfo::Copy(const DisplayInfo& native_info) { | 164 void DisplayInfo::Copy(const DisplayInfo& native_info) { |
163 DCHECK(id_ == native_info.id_); | 165 DCHECK(id_ == native_info.id_); |
164 name_ = native_info.name_; | 166 name_ = native_info.name_; |
165 has_overscan_ = native_info.has_overscan_; | 167 has_overscan_ = native_info.has_overscan_; |
166 | 168 |
167 DCHECK(!native_info.bounds_in_native_.IsEmpty()); | 169 DCHECK(!native_info.bounds_in_native_.IsEmpty()); |
168 bounds_in_native_ = native_info.bounds_in_native_; | 170 bounds_in_native_ = native_info.bounds_in_native_; |
169 size_in_pixel_ = native_info.size_in_pixel_; | 171 size_in_pixel_ = native_info.size_in_pixel_; |
170 device_scale_factor_ = native_info.device_scale_factor_; | 172 device_scale_factor_ = native_info.device_scale_factor_; |
171 resolutions_ = native_info.resolutions_; | 173 resolutions_ = native_info.resolutions_; |
| 174 touch_support_ = native_info.touch_support_; |
172 | 175 |
173 // Copy overscan_insets_in_dip_ if it's not empty. This is for test | 176 // Copy overscan_insets_in_dip_ if it's not empty. This is for test |
174 // cases which use "/o" annotation which sets the overscan inset | 177 // cases which use "/o" annotation which sets the overscan inset |
175 // to native, and that overscan has to be propagated. This does not | 178 // to native, and that overscan has to be propagated. This does not |
176 // happen on the real environment. | 179 // happen on the real environment. |
177 if (!native_info.overscan_insets_in_dip_.empty()) | 180 if (!native_info.overscan_insets_in_dip_.empty()) |
178 overscan_insets_in_dip_ = native_info.overscan_insets_in_dip_; | 181 overscan_insets_in_dip_ = native_info.overscan_insets_in_dip_; |
179 | 182 |
180 // Rotation_ and ui_scale_ are given by preference, or unit | 183 // Rotation_ and ui_scale_ are given by preference, or unit |
181 // tests. Don't copy if this native_info came from | 184 // tests. Don't copy if this native_info came from |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 } | 221 } |
219 | 222 |
220 gfx::Insets DisplayInfo::GetOverscanInsetsInPixel() const { | 223 gfx::Insets DisplayInfo::GetOverscanInsetsInPixel() const { |
221 return overscan_insets_in_dip_.Scale(device_scale_factor_); | 224 return overscan_insets_in_dip_.Scale(device_scale_factor_); |
222 } | 225 } |
223 | 226 |
224 std::string DisplayInfo::ToString() const { | 227 std::string DisplayInfo::ToString() const { |
225 int rotation_degree = static_cast<int>(rotation_) * 90; | 228 int rotation_degree = static_cast<int>(rotation_) * 90; |
226 return base::StringPrintf( | 229 return base::StringPrintf( |
227 "DisplayInfo[%lld] native bounds=%s, size=%s, scale=%f, " | 230 "DisplayInfo[%lld] native bounds=%s, size=%s, scale=%f, " |
228 "overscan=%s, rotation=%d, ui-scale=%f", | 231 "overscan=%s, rotation=%d, ui-scale=%f, touchscreen=%s", |
229 static_cast<long long int>(id_), | 232 static_cast<long long int>(id_), |
230 bounds_in_native_.ToString().c_str(), | 233 bounds_in_native_.ToString().c_str(), |
231 size_in_pixel_.ToString().c_str(), | 234 size_in_pixel_.ToString().c_str(), |
232 device_scale_factor_, | 235 device_scale_factor_, |
233 overscan_insets_in_dip_.ToString().c_str(), | 236 overscan_insets_in_dip_.ToString().c_str(), |
234 rotation_degree, | 237 rotation_degree, |
235 ui_scale_); | 238 ui_scale_, |
| 239 touch_support_ == gfx::Display::TOUCH_SUPPORT_AVAILABLE ? "yes" : |
| 240 touch_support_ == gfx::Display::TOUCH_SUPPORT_UNAVAILABLE ? "no" : |
| 241 "unknown"); |
236 } | 242 } |
237 | 243 |
238 std::string DisplayInfo::ToFullString() const { | 244 std::string DisplayInfo::ToFullString() const { |
239 std::string resolutions_str; | 245 std::string resolutions_str; |
240 std::vector<Resolution>::const_iterator iter = resolutions_.begin(); | 246 std::vector<Resolution>::const_iterator iter = resolutions_.begin(); |
241 for (; iter != resolutions_.end(); ++iter) { | 247 for (; iter != resolutions_.end(); ++iter) { |
242 if (!resolutions_str.empty()) | 248 if (!resolutions_str.empty()) |
243 resolutions_str += ","; | 249 resolutions_str += ","; |
244 resolutions_str += iter->size.ToString(); | 250 resolutions_str += iter->size.ToString(); |
245 if (iter->interlaced) | 251 if (iter->interlaced) |
246 resolutions_str += "(i)"; | 252 resolutions_str += "(i)"; |
247 } | 253 } |
248 return ToString() + ", resolutions=" + resolutions_str; | 254 return ToString() + ", resolutions=" + resolutions_str; |
249 } | 255 } |
250 | 256 |
251 } // namespace internal | 257 } // namespace internal |
252 } // namespace ash | 258 } // namespace ash |
OLD | NEW |