| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 DVLOG(1) << "DisplayInfoFromSpec info=" << display_info.ToString() | 172 DVLOG(1) << "DisplayInfoFromSpec info=" << display_info.ToString() |
| 173 << ", spec=" << spec; | 173 << ", spec=" << spec; |
| 174 return display_info; | 174 return display_info; |
| 175 } | 175 } |
| 176 | 176 |
| 177 DisplayInfo::DisplayInfo() | 177 DisplayInfo::DisplayInfo() |
| 178 : id_(gfx::Display::kInvalidDisplayID), | 178 : id_(gfx::Display::kInvalidDisplayID), |
| 179 has_overscan_(false), | 179 has_overscan_(false), |
| 180 rotation_(gfx::Display::ROTATE_0), | 180 rotation_(gfx::Display::ROTATE_0), |
| 181 touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), | 181 touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), |
| 182 touch_device_id_(0), |
| 182 device_scale_factor_(1.0f), | 183 device_scale_factor_(1.0f), |
| 183 overscan_insets_in_dip_(0, 0, 0, 0), | 184 overscan_insets_in_dip_(0, 0, 0, 0), |
| 184 configured_ui_scale_(1.0f), | 185 configured_ui_scale_(1.0f), |
| 185 native_(false), | 186 native_(false), |
| 186 color_profile_(ui::COLOR_PROFILE_STANDARD) { | 187 color_profile_(ui::COLOR_PROFILE_STANDARD) { |
| 187 } | 188 } |
| 188 | 189 |
| 189 DisplayInfo::DisplayInfo(int64 id, | 190 DisplayInfo::DisplayInfo(int64 id, |
| 190 const std::string& name, | 191 const std::string& name, |
| 191 bool has_overscan) | 192 bool has_overscan) |
| 192 : id_(id), | 193 : id_(id), |
| 193 name_(name), | 194 name_(name), |
| 194 has_overscan_(has_overscan), | 195 has_overscan_(has_overscan), |
| 195 rotation_(gfx::Display::ROTATE_0), | 196 rotation_(gfx::Display::ROTATE_0), |
| 196 touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), | 197 touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), |
| 198 touch_device_id_(0), |
| 197 device_scale_factor_(1.0f), | 199 device_scale_factor_(1.0f), |
| 198 overscan_insets_in_dip_(0, 0, 0, 0), | 200 overscan_insets_in_dip_(0, 0, 0, 0), |
| 199 configured_ui_scale_(1.0f), | 201 configured_ui_scale_(1.0f), |
| 200 native_(false), | 202 native_(false), |
| 201 color_profile_(ui::COLOR_PROFILE_STANDARD) { | 203 color_profile_(ui::COLOR_PROFILE_STANDARD) { |
| 202 } | 204 } |
| 203 | 205 |
| 204 DisplayInfo::~DisplayInfo() { | 206 DisplayInfo::~DisplayInfo() { |
| 205 } | 207 } |
| 206 | 208 |
| 207 void DisplayInfo::Copy(const DisplayInfo& native_info) { | 209 void DisplayInfo::Copy(const DisplayInfo& native_info) { |
| 208 DCHECK(id_ == native_info.id_); | 210 DCHECK(id_ == native_info.id_); |
| 209 name_ = native_info.name_; | 211 name_ = native_info.name_; |
| 210 has_overscan_ = native_info.has_overscan_; | 212 has_overscan_ = native_info.has_overscan_; |
| 211 | 213 |
| 212 DCHECK(!native_info.bounds_in_native_.IsEmpty()); | 214 DCHECK(!native_info.bounds_in_native_.IsEmpty()); |
| 213 bounds_in_native_ = native_info.bounds_in_native_; | 215 bounds_in_native_ = native_info.bounds_in_native_; |
| 214 size_in_pixel_ = native_info.size_in_pixel_; | 216 size_in_pixel_ = native_info.size_in_pixel_; |
| 215 device_scale_factor_ = native_info.device_scale_factor_; | 217 device_scale_factor_ = native_info.device_scale_factor_; |
| 216 display_modes_ = native_info.display_modes_; | 218 display_modes_ = native_info.display_modes_; |
| 217 touch_support_ = native_info.touch_support_; | 219 touch_support_ = native_info.touch_support_; |
| 220 touch_device_id_ = native_info.touch_device_id_; |
| 218 | 221 |
| 219 // Copy overscan_insets_in_dip_ if it's not empty. This is for test | 222 // Copy overscan_insets_in_dip_ if it's not empty. This is for test |
| 220 // cases which use "/o" annotation which sets the overscan inset | 223 // cases which use "/o" annotation which sets the overscan inset |
| 221 // to native, and that overscan has to be propagated. This does not | 224 // to native, and that overscan has to be propagated. This does not |
| 222 // happen on the real environment. | 225 // happen on the real environment. |
| 223 if (!native_info.overscan_insets_in_dip_.empty()) | 226 if (!native_info.overscan_insets_in_dip_.empty()) |
| 224 overscan_insets_in_dip_ = native_info.overscan_insets_in_dip_; | 227 overscan_insets_in_dip_ = native_info.overscan_insets_in_dip_; |
| 225 | 228 |
| 226 // Rotation_ and ui_scale_ color_profile_ are given by preference, | 229 // Rotation_ and ui_scale_ color_profile_ are given by preference, |
| 227 // or unit tests. Don't copy if this native_info came from | 230 // or unit tests. Don't copy if this native_info came from |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 } | 291 } |
| 289 | 292 |
| 290 gfx::Insets DisplayInfo::GetOverscanInsetsInPixel() const { | 293 gfx::Insets DisplayInfo::GetOverscanInsetsInPixel() const { |
| 291 return overscan_insets_in_dip_.Scale(device_scale_factor_); | 294 return overscan_insets_in_dip_.Scale(device_scale_factor_); |
| 292 } | 295 } |
| 293 | 296 |
| 294 std::string DisplayInfo::ToString() const { | 297 std::string DisplayInfo::ToString() const { |
| 295 int rotation_degree = static_cast<int>(rotation_) * 90; | 298 int rotation_degree = static_cast<int>(rotation_) * 90; |
| 296 return base::StringPrintf( | 299 return base::StringPrintf( |
| 297 "DisplayInfo[%lld] native bounds=%s, size=%s, scale=%f, " | 300 "DisplayInfo[%lld] native bounds=%s, size=%s, scale=%f, " |
| 298 "overscan=%s, rotation=%d, ui-scale=%f, touchscreen=%s", | 301 "overscan=%s, rotation=%d, ui-scale=%f, touchscreen=%s, " |
| 302 "touch-device-id=%d", |
| 299 static_cast<long long int>(id_), | 303 static_cast<long long int>(id_), |
| 300 bounds_in_native_.ToString().c_str(), | 304 bounds_in_native_.ToString().c_str(), |
| 301 size_in_pixel_.ToString().c_str(), | 305 size_in_pixel_.ToString().c_str(), |
| 302 device_scale_factor_, | 306 device_scale_factor_, |
| 303 overscan_insets_in_dip_.ToString().c_str(), | 307 overscan_insets_in_dip_.ToString().c_str(), |
| 304 rotation_degree, | 308 rotation_degree, |
| 305 configured_ui_scale_, | 309 configured_ui_scale_, |
| 306 touch_support_ == gfx::Display::TOUCH_SUPPORT_AVAILABLE | 310 touch_support_ == gfx::Display::TOUCH_SUPPORT_AVAILABLE |
| 307 ? "yes" | 311 ? "yes" |
| 308 : touch_support_ == gfx::Display::TOUCH_SUPPORT_UNAVAILABLE | 312 : touch_support_ == gfx::Display::TOUCH_SUPPORT_UNAVAILABLE |
| 309 ? "no" | 313 ? "no" |
| 310 : "unknown"); | 314 : "unknown", |
| 315 touch_device_id_); |
| 311 } | 316 } |
| 312 | 317 |
| 313 std::string DisplayInfo::ToFullString() const { | 318 std::string DisplayInfo::ToFullString() const { |
| 314 std::string display_modes_str; | 319 std::string display_modes_str; |
| 315 std::vector<DisplayMode>::const_iterator iter = display_modes_.begin(); | 320 std::vector<DisplayMode>::const_iterator iter = display_modes_.begin(); |
| 316 for (; iter != display_modes_.end(); ++iter) { | 321 for (; iter != display_modes_.end(); ++iter) { |
| 317 if (!display_modes_str.empty()) | 322 if (!display_modes_str.empty()) |
| 318 display_modes_str += ","; | 323 display_modes_str += ","; |
| 319 base::StringAppendF(&display_modes_str, | 324 base::StringAppendF(&display_modes_str, |
| 320 "(%dx%d@%f%c%s)", | 325 "(%dx%d@%f%c%s)", |
| (...skipping 12 matching lines...) Expand all Loading... |
| 333 } | 338 } |
| 334 | 339 |
| 335 bool DisplayInfo::IsColorProfileAvailable( | 340 bool DisplayInfo::IsColorProfileAvailable( |
| 336 ui::ColorCalibrationProfile profile) const { | 341 ui::ColorCalibrationProfile profile) const { |
| 337 return std::find(available_color_profiles_.begin(), | 342 return std::find(available_color_profiles_.begin(), |
| 338 available_color_profiles_.end(), | 343 available_color_profiles_.end(), |
| 339 profile) != available_color_profiles_.end(); | 344 profile) != available_color_profiles_.end(); |
| 340 } | 345 } |
| 341 | 346 |
| 342 } // namespace ash | 347 } // namespace ash |
| OLD | NEW |