| 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/window_tree_host.h" | 19 #include "ui/aura/window_tree_host.h" |
| 20 #include "ui/gfx/win/dpi.h" | 20 #include "ui/gfx/win/dpi.h" |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 namespace ash { | 23 namespace ash { |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 // TODO(oshima): This feature is obsolete. Remove this after m38. |
| 26 bool allow_upgrade_to_high_dpi = false; | 27 bool allow_upgrade_to_high_dpi = false; |
| 27 | 28 |
| 28 } | 29 } |
| 29 | 30 |
| 30 DisplayMode::DisplayMode() | 31 DisplayMode::DisplayMode() |
| 31 : refresh_rate(0.0f), interlaced(false), native(false) {} | 32 : refresh_rate(0.0f), interlaced(false), native(false) {} |
| 32 | 33 |
| 33 DisplayMode::DisplayMode(const gfx::Size& size, | 34 DisplayMode::DisplayMode(const gfx::Size& size, |
| 34 float refresh_rate, | 35 float refresh_rate, |
| 35 bool interlaced, | 36 bool interlaced, |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 void DisplayInfo::SetBounds(const gfx::Rect& new_bounds_in_native) { | 247 void DisplayInfo::SetBounds(const gfx::Rect& new_bounds_in_native) { |
| 247 bounds_in_native_ = new_bounds_in_native; | 248 bounds_in_native_ = new_bounds_in_native; |
| 248 size_in_pixel_ = new_bounds_in_native.size(); | 249 size_in_pixel_ = new_bounds_in_native.size(); |
| 249 UpdateDisplaySize(); | 250 UpdateDisplaySize(); |
| 250 } | 251 } |
| 251 | 252 |
| 252 float DisplayInfo::GetEffectiveDeviceScaleFactor() const { | 253 float DisplayInfo::GetEffectiveDeviceScaleFactor() const { |
| 253 if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f && | 254 if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f && |
| 254 device_scale_factor_ == 1.0f) { | 255 device_scale_factor_ == 1.0f) { |
| 255 return 2.0f; | 256 return 2.0f; |
| 256 } else if (device_scale_factor_ == 2.0f && configured_ui_scale_ == 2.0f) { | 257 } else if (device_scale_factor_ == configured_ui_scale_) { |
| 257 return 1.0f; | 258 return 1.0f; |
| 258 } | 259 } |
| 259 return device_scale_factor_; | 260 return device_scale_factor_; |
| 260 } | 261 } |
| 261 | 262 |
| 262 float DisplayInfo::GetEffectiveUIScale() const { | 263 float DisplayInfo::GetEffectiveUIScale() const { |
| 263 if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f && | 264 if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f && |
| 264 device_scale_factor_ == 1.0f) { | 265 device_scale_factor_ == 1.0f) { |
| 265 return configured_ui_scale_ * 2.0f; | 266 return configured_ui_scale_ * 2.0f; |
| 266 } else if (device_scale_factor_ == 2.0f && configured_ui_scale_ == 2.0f) { | 267 } else if (device_scale_factor_ == configured_ui_scale_) { |
| 267 return 1.0f; | 268 return 1.0f; |
| 268 } | 269 } |
| 269 return configured_ui_scale_; | 270 return configured_ui_scale_; |
| 270 } | 271 } |
| 271 | 272 |
| 272 void DisplayInfo::UpdateDisplaySize() { | 273 void DisplayInfo::UpdateDisplaySize() { |
| 273 size_in_pixel_ = bounds_in_native_.size(); | 274 size_in_pixel_ = bounds_in_native_.size(); |
| 274 if (!overscan_insets_in_dip_.empty()) { | 275 if (!overscan_insets_in_dip_.empty()) { |
| 275 gfx::Insets insets_in_pixel = | 276 gfx::Insets insets_in_pixel = |
| 276 overscan_insets_in_dip_.Scale(device_scale_factor_); | 277 overscan_insets_in_dip_.Scale(device_scale_factor_); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 } | 340 } |
| 340 | 341 |
| 341 bool DisplayInfo::IsColorProfileAvailable( | 342 bool DisplayInfo::IsColorProfileAvailable( |
| 342 ui::ColorCalibrationProfile profile) const { | 343 ui::ColorCalibrationProfile profile) const { |
| 343 return std::find(available_color_profiles_.begin(), | 344 return std::find(available_color_profiles_.begin(), |
| 344 available_color_profiles_.end(), | 345 available_color_profiles_.end(), |
| 345 profile) != available_color_profiles_.end(); | 346 profile) != available_color_profiles_.end(); |
| 346 } | 347 } |
| 347 | 348 |
| 348 } // namespace ash | 349 } // namespace ash |
| OLD | NEW |