Chromium Code Reviews| Index: ash/display/display_change_observer_chromeos.cc |
| diff --git a/ash/display/display_change_observer_chromeos.cc b/ash/display/display_change_observer_chromeos.cc |
| index 54b39dce7c9e4d1237eaca3b4250dae863df0371..355743a9599c03b4d8a08c327d8d500674e751c3 100644 |
| --- a/ash/display/display_change_observer_chromeos.cc |
| +++ b/ash/display/display_change_observer_chromeos.cc |
| @@ -30,9 +30,18 @@ using ui::DisplayConfigurator; |
| namespace { |
| -// The DPI threshold to detect high density screen. |
| -// Higher DPI than this will use device_scale_factor=2. |
| -const unsigned int kHighDensityDPIThreshold = 170; |
| +// The DPI threshold to determine the device scale factor. |
| +// DPI higher than |dpi| will use |device_scale_factor|. |
| +struct DeviceScaleFactorDPIThreshold { |
| + int dpi; |
|
Jun Mukai
2014/07/22 23:19:49
why not float for dpi?
oshima
2014/07/23 01:38:05
Done.
|
| + float device_scale_factor; |
| +}; |
| + |
| +const DeviceScaleFactorDPIThreshold kThresholdTable[] = { |
| + {180, 2.0f}, |
| + {150, 1.25f}, |
| + {0, 1.0f}, |
| +}; |
| // 1 inch in mm. |
| const float kInchInMm = 25.4f; |
| @@ -134,10 +143,10 @@ void DisplayChangeObserver::OnDisplayModeChanged( |
| continue; |
| float device_scale_factor = 1.0f; |
| - if (!ui::IsDisplaySizeBlackListed(state.display->physical_size()) && |
| - (kInchInMm * mode_info->size().width() / |
| - state.display->physical_size().width()) > kHighDensityDPIThreshold) { |
| - device_scale_factor = 2.0f; |
| + if (!ui::IsDisplaySizeBlackListed(state.display->physical_size())) { |
| + device_scale_factor = |
| + FindDeviceScaleFactor((kInchInMm * mode_info->size().width() / |
| + state.display->physical_size().width())); |
| } |
| gfx::Rect display_bounds(state.display->origin(), mode_info->size()); |
| @@ -184,4 +193,13 @@ void DisplayChangeObserver::OnAppTerminating() { |
| #endif |
| } |
| +// static |
| +float DisplayChangeObserver::FindDeviceScaleFactor(float dpi) { |
| + for (size_t i = 0; i < arraysize(kThresholdTable); ++i) { |
| + if (dpi > kThresholdTable[i].dpi) |
| + return kThresholdTable[i].device_scale_factor; |
| + } |
| + return 1.0f; |
| +} |
| + |
| } // namespace ash |