| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/display/display_preferences.h" | 5 #include "chrome/browser/chromeos/display/display_preferences.h" |
| 6 | 6 |
| 7 #include "ash/display/display_layout_store.h" | 7 #include "ash/display/display_layout_store.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/display/display_pref_util.h" | 9 #include "ash/display/display_pref_util.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } | 159 } |
| 160 int ui_scale_value = 0; | 160 int ui_scale_value = 0; |
| 161 if (dict_value->GetInteger("ui-scale", &ui_scale_value)) | 161 if (dict_value->GetInteger("ui-scale", &ui_scale_value)) |
| 162 ui_scale = static_cast<float>(ui_scale_value) / 1000.0f; | 162 ui_scale = static_cast<float>(ui_scale_value) / 1000.0f; |
| 163 | 163 |
| 164 int width = 0, height = 0; | 164 int width = 0, height = 0; |
| 165 dict_value->GetInteger("width", &width); | 165 dict_value->GetInteger("width", &width); |
| 166 dict_value->GetInteger("height", &height); | 166 dict_value->GetInteger("height", &height); |
| 167 gfx::Size resolution_in_pixels(width, height); | 167 gfx::Size resolution_in_pixels(width, height); |
| 168 | 168 |
| 169 float device_scale_factor = 1.0; |
| 170 int dsf_value = 0; |
| 171 if (dict_value->GetInteger("device-scale-factor", &dsf_value)) |
| 172 device_scale_factor = static_cast<float>(dsf_value) / 1000.0f; |
| 173 |
| 169 gfx::Insets insets; | 174 gfx::Insets insets; |
| 170 if (ValueToInsets(*dict_value, &insets)) | 175 if (ValueToInsets(*dict_value, &insets)) |
| 171 insets_to_set = &insets; | 176 insets_to_set = &insets; |
| 172 | 177 |
| 173 ui::ColorCalibrationProfile color_profile = ui::COLOR_PROFILE_STANDARD; | 178 ui::ColorCalibrationProfile color_profile = ui::COLOR_PROFILE_STANDARD; |
| 174 std::string color_profile_name; | 179 std::string color_profile_name; |
| 175 if (dict_value->GetString("color_profile_name", &color_profile_name)) | 180 if (dict_value->GetString("color_profile_name", &color_profile_name)) |
| 176 color_profile = StringToColorProfile(color_profile_name); | 181 color_profile = StringToColorProfile(color_profile_name); |
| 177 GetDisplayManager()->RegisterDisplayProperty(id, | 182 GetDisplayManager()->RegisterDisplayProperty(id, |
| 178 rotation, | 183 rotation, |
| 179 ui_scale, | 184 ui_scale, |
| 180 insets_to_set, | 185 insets_to_set, |
| 181 resolution_in_pixels, | 186 resolution_in_pixels, |
| 187 device_scale_factor, |
| 182 color_profile); | 188 color_profile); |
| 183 } | 189 } |
| 184 } | 190 } |
| 185 | 191 |
| 186 void StoreDisplayLayoutPref(const ash::DisplayIdPair& pair, | 192 void StoreDisplayLayoutPref(const ash::DisplayIdPair& pair, |
| 187 const ash::DisplayLayout& display_layout) { | 193 const ash::DisplayLayout& display_layout) { |
| 188 std::string name = | 194 std::string name = |
| 189 base::Int64ToString(pair.first) + "," + base::Int64ToString(pair.second); | 195 base::Int64ToString(pair.first) + "," + base::Int64ToString(pair.second); |
| 190 | 196 |
| 191 PrefService* local_state = g_browser_process->local_state(); | 197 PrefService* local_state = g_browser_process->local_state(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 property_value->SetInteger("rotation", static_cast<int>(info.rotation())); | 237 property_value->SetInteger("rotation", static_cast<int>(info.rotation())); |
| 232 property_value->SetInteger( | 238 property_value->SetInteger( |
| 233 "ui-scale", | 239 "ui-scale", |
| 234 static_cast<int>(info.configured_ui_scale() * 1000)); | 240 static_cast<int>(info.configured_ui_scale() * 1000)); |
| 235 ash::DisplayMode mode; | 241 ash::DisplayMode mode; |
| 236 if (!display.IsInternal() && | 242 if (!display.IsInternal() && |
| 237 display_manager->GetSelectedModeForDisplayId(id, &mode) && | 243 display_manager->GetSelectedModeForDisplayId(id, &mode) && |
| 238 !mode.native) { | 244 !mode.native) { |
| 239 property_value->SetInteger("width", mode.size.width()); | 245 property_value->SetInteger("width", mode.size.width()); |
| 240 property_value->SetInteger("height", mode.size.height()); | 246 property_value->SetInteger("height", mode.size.height()); |
| 247 property_value->SetInteger( |
| 248 "device-scale-factor", |
| 249 static_cast<int>(mode.device_scale_factor * 1000)); |
| 241 } | 250 } |
| 242 if (!info.overscan_insets_in_dip().empty()) | 251 if (!info.overscan_insets_in_dip().empty()) |
| 243 InsetsToValue(info.overscan_insets_in_dip(), property_value.get()); | 252 InsetsToValue(info.overscan_insets_in_dip(), property_value.get()); |
| 244 if (info.color_profile() != ui::COLOR_PROFILE_STANDARD) { | 253 if (info.color_profile() != ui::COLOR_PROFILE_STANDARD) { |
| 245 property_value->SetString( | 254 property_value->SetString( |
| 246 "color_profile_name", ColorProfileToString(info.color_profile())); | 255 "color_profile_name", ColorProfileToString(info.color_profile())); |
| 247 } | 256 } |
| 248 pref_data->Set(base::Int64ToString(id), property_value.release()); | 257 pref_data->Set(base::Int64ToString(id), property_value.release()); |
| 249 } | 258 } |
| 250 } | 259 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 const ash::DisplayLayout& layout) { | 346 const ash::DisplayLayout& layout) { |
| 338 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); | 347 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); |
| 339 } | 348 } |
| 340 | 349 |
| 341 // Stores the given |power_state|. | 350 // Stores the given |power_state|. |
| 342 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { | 351 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { |
| 343 StoreDisplayPowerState(power_state); | 352 StoreDisplayPowerState(power_state); |
| 344 } | 353 } |
| 345 | 354 |
| 346 } // namespace chromeos | 355 } // namespace chromeos |
| OLD | NEW |