Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "ash/display/display_change_observer_chromeos.h" | 5 #include "ash/display/display_change_observer_chromeos.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 UpdateInternalDisplayId(display_states); | 180 UpdateInternalDisplayId(display_states); |
| 181 | 181 |
| 182 std::vector<DisplayInfo> displays; | 182 std::vector<DisplayInfo> displays; |
| 183 std::set<int64> ids; | 183 std::set<int64> ids; |
| 184 for (const ui::DisplaySnapshot* state : display_states) { | 184 for (const ui::DisplaySnapshot* state : display_states) { |
| 185 const ui::DisplayMode* mode_info = state->current_mode(); | 185 const ui::DisplayMode* mode_info = state->current_mode(); |
| 186 if (!mode_info) | 186 if (!mode_info) |
| 187 continue; | 187 continue; |
| 188 | 188 |
| 189 float device_scale_factor = 1.0f; | 189 float device_scale_factor = 1.0f; |
| 190 float dpi = | |
| 191 kInchInMm * mode_info->size().width() / state->physical_size().width(); | |
|
oshima
2015/09/15 17:34:24
can you check against black listed size and fallba
| |
| 190 if (state->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL) { | 192 if (state->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL) { |
| 191 if (!ui::IsDisplaySizeBlackListed(state->physical_size())) { | 193 if (!ui::IsDisplaySizeBlackListed(state->physical_size())) |
| 192 device_scale_factor = | 194 device_scale_factor = FindDeviceScaleFactor(dpi); |
| 193 FindDeviceScaleFactor((kInchInMm * mode_info->size().width() / | |
| 194 state->physical_size().width())); | |
| 195 } | |
| 196 } else { | 195 } else { |
| 197 DisplayMode mode; | 196 DisplayMode mode; |
| 198 if (Shell::GetInstance()->display_manager()->GetSelectedModeForDisplayId( | 197 if (Shell::GetInstance()->display_manager()->GetSelectedModeForDisplayId( |
| 199 state->display_id(), &mode)) { | 198 state->display_id(), &mode)) { |
| 200 device_scale_factor = mode.device_scale_factor; | 199 device_scale_factor = mode.device_scale_factor; |
| 201 } else { | 200 } else { |
| 202 // For monitors that are 40 inches and 4K or above, set | 201 // For monitors that are 40 inches and 4K or above, set |
| 203 // |device_scale_factor| to 2x. For margin purposes, 100 is subtracted | 202 // |device_scale_factor| to 2x. For margin purposes, 100 is subtracted |
| 204 // from the value of |k2xThreshouldSizeSquaredFor4KInMm| | 203 // from the value of |k2xThreshouldSizeSquaredFor4KInMm| |
| 205 const int k2xThreshouldSizeSquaredFor4KInMm = | 204 const int k2xThreshouldSizeSquaredFor4KInMm = |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 227 int64 id = state->display_id(); | 226 int64 id = state->display_id(); |
| 228 ids.insert(id); | 227 ids.insert(id); |
| 229 | 228 |
| 230 displays.push_back(DisplayInfo(id, name, has_overscan)); | 229 displays.push_back(DisplayInfo(id, name, has_overscan)); |
| 231 DisplayInfo& new_info = displays.back(); | 230 DisplayInfo& new_info = displays.back(); |
| 232 new_info.set_device_scale_factor(device_scale_factor); | 231 new_info.set_device_scale_factor(device_scale_factor); |
| 233 new_info.SetBounds(display_bounds); | 232 new_info.SetBounds(display_bounds); |
| 234 new_info.set_native(true); | 233 new_info.set_native(true); |
| 235 new_info.set_is_aspect_preserving_scaling( | 234 new_info.set_is_aspect_preserving_scaling( |
| 236 state->is_aspect_preserving_scaling()); | 235 state->is_aspect_preserving_scaling()); |
| 236 new_info.set_device_dpi(dpi); | |
| 237 | 237 |
| 238 std::vector<DisplayMode> display_modes = | 238 std::vector<DisplayMode> display_modes = |
| 239 (state->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL) | 239 (state->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL) |
| 240 ? GetInternalDisplayModeList(new_info, *state) | 240 ? GetInternalDisplayModeList(new_info, *state) |
| 241 : GetExternalDisplayModeList(*state); | 241 : GetExternalDisplayModeList(*state); |
| 242 new_info.SetDisplayModes(display_modes); | 242 new_info.SetDisplayModes(display_modes); |
| 243 | 243 |
| 244 new_info.set_available_color_profiles( | 244 new_info.set_available_color_profiles( |
| 245 Shell::GetInstance() | 245 Shell::GetInstance() |
| 246 ->display_configurator() | 246 ->display_configurator() |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 } | 286 } |
| 287 return 1.0f; | 287 return 1.0f; |
| 288 } | 288 } |
| 289 | 289 |
| 290 void DisplayChangeObserver::OnTouchscreenDeviceConfigurationChanged() { | 290 void DisplayChangeObserver::OnTouchscreenDeviceConfigurationChanged() { |
| 291 OnDisplayModeChanged( | 291 OnDisplayModeChanged( |
| 292 Shell::GetInstance()->display_configurator()->cached_displays()); | 292 Shell::GetInstance()->display_configurator()->cached_displays()); |
| 293 } | 293 } |
| 294 | 294 |
| 295 } // namespace ash | 295 } // namespace ash |
| OLD | NEW |