Chromium Code Reviews| 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/display/resolution_notification_controller.h" | 10 #include "ash/display/resolution_notification_controller.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 | 128 |
| 129 int rotation_value = 0; | 129 int rotation_value = 0; |
| 130 if (dict_value->GetInteger("rotation", &rotation_value)) { | 130 if (dict_value->GetInteger("rotation", &rotation_value)) { |
| 131 rotation = static_cast<gfx::Display::Rotation>(rotation_value); | 131 rotation = static_cast<gfx::Display::Rotation>(rotation_value); |
| 132 } | 132 } |
| 133 int ui_scale_value = 0; | 133 int ui_scale_value = 0; |
| 134 if (dict_value->GetInteger("ui-scale", &ui_scale_value)) | 134 if (dict_value->GetInteger("ui-scale", &ui_scale_value)) |
| 135 ui_scale = static_cast<float>(ui_scale_value) / 1000.0f; | 135 ui_scale = static_cast<float>(ui_scale_value) / 1000.0f; |
| 136 | 136 |
| 137 int width = 0, height = 0; | 137 int width = 0, height = 0; |
| 138 double refresh_rate; | |
| 138 dict_value->GetInteger("width", &width); | 139 dict_value->GetInteger("width", &width); |
| 139 dict_value->GetInteger("height", &height); | 140 dict_value->GetInteger("height", &height); |
| 141 dict_value->GetDouble("refresh-rate", &refresh_rate); | |
|
oshima
2014/01/27 18:53:22
Unless you want to use this to select output mode,
sheu
2014/01/28 21:30:42
My problem here is that RegisterDisplayProperty cr
oshima
2014/01/28 22:17:08
I believe your problem was that you didn't add the
sheu
2014/01/29 00:14:10
I've added a default, but I'm not sure what you me
oshima
2014/01/29 01:15:26
Maybe I misread the code, but if you indeed added
| |
| 140 gfx::Size resolution_in_pixels(width, height); | 142 gfx::Size resolution_in_pixels(width, height); |
| 141 | 143 |
| 142 gfx::Insets insets; | 144 gfx::Insets insets; |
| 143 if (ValueToInsets(*dict_value, &insets)) | 145 if (ValueToInsets(*dict_value, &insets)) |
| 144 insets_to_set = &insets; | 146 insets_to_set = &insets; |
| 145 GetDisplayManager()->RegisterDisplayProperty(id, | 147 GetDisplayManager()->RegisterDisplayProperty(id, |
| 146 rotation, | 148 rotation, |
| 147 ui_scale, | 149 ui_scale, |
| 148 insets_to_set, | 150 insets_to_set, |
| 149 resolution_in_pixels); | 151 resolution_in_pixels, |
| 152 refresh_rate); | |
| 150 } | 153 } |
| 151 } | 154 } |
| 152 | 155 |
| 153 void StoreDisplayLayoutPref(const ash::DisplayIdPair& pair, | 156 void StoreDisplayLayoutPref(const ash::DisplayIdPair& pair, |
| 154 const ash::DisplayLayout& display_layout) { | 157 const ash::DisplayLayout& display_layout) { |
| 155 std::string name = | 158 std::string name = |
| 156 base::Int64ToString(pair.first) + "," + base::Int64ToString(pair.second); | 159 base::Int64ToString(pair.first) + "," + base::Int64ToString(pair.second); |
| 157 | 160 |
| 158 PrefService* local_state = g_browser_process->local_state(); | 161 PrefService* local_state = g_browser_process->local_state(); |
| 159 DictionaryPrefUpdate update(local_state, prefs::kSecondaryDisplays); | 162 DictionaryPrefUpdate update(local_state, prefs::kSecondaryDisplays); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 int64 id = display.id(); | 196 int64 id = display.id(); |
| 194 ash::internal::DisplayInfo info = display_manager->GetDisplayInfo(id); | 197 ash::internal::DisplayInfo info = display_manager->GetDisplayInfo(id); |
| 195 | 198 |
| 196 scoped_ptr<base::DictionaryValue> property_value( | 199 scoped_ptr<base::DictionaryValue> property_value( |
| 197 new base::DictionaryValue()); | 200 new base::DictionaryValue()); |
| 198 property_value->SetInteger("rotation", static_cast<int>(info.rotation())); | 201 property_value->SetInteger("rotation", static_cast<int>(info.rotation())); |
| 199 property_value->SetInteger( | 202 property_value->SetInteger( |
| 200 "ui-scale", | 203 "ui-scale", |
| 201 static_cast<int>(info.configured_ui_scale() * 1000)); | 204 static_cast<int>(info.configured_ui_scale() * 1000)); |
| 202 gfx::Size resolution; | 205 gfx::Size resolution; |
| 206 float refresh_rate; | |
| 203 if (!display.IsInternal() && | 207 if (!display.IsInternal() && |
| 204 display_manager->GetSelectedResolutionForDisplayId(id, &resolution)) { | 208 display_manager->GetSelectedResolutionForDisplayId( |
| 209 id, &resolution, &refresh_rate)) { | |
| 205 property_value->SetInteger("width", resolution.width()); | 210 property_value->SetInteger("width", resolution.width()); |
| 206 property_value->SetInteger("height", resolution.height()); | 211 property_value->SetInteger("height", resolution.height()); |
| 212 property_value->SetDouble("refresh-rate", refresh_rate); | |
| 207 } | 213 } |
| 208 | 214 |
| 209 if (!info.overscan_insets_in_dip().empty()) | 215 if (!info.overscan_insets_in_dip().empty()) |
| 210 InsetsToValue(info.overscan_insets_in_dip(), property_value.get()); | 216 InsetsToValue(info.overscan_insets_in_dip(), property_value.get()); |
| 211 pref_data->Set(base::Int64ToString(id), property_value.release()); | 217 pref_data->Set(base::Int64ToString(id), property_value.release()); |
| 212 } | 218 } |
| 213 } | 219 } |
| 214 | 220 |
| 215 typedef std::map<chromeos::DisplayPowerState, std::string> | 221 typedef std::map<chromeos::DisplayPowerState, std::string> |
| 216 DisplayPowerStateToStringMap; | 222 DisplayPowerStateToStringMap; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 const ash::DisplayLayout& layout) { | 306 const ash::DisplayLayout& layout) { |
| 301 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); | 307 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); |
| 302 } | 308 } |
| 303 | 309 |
| 304 // Stores the given |power_state|. | 310 // Stores the given |power_state|. |
| 305 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { | 311 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { |
| 306 StoreDisplayPowerState(power_state); | 312 StoreDisplayPowerState(power_state); |
| 307 } | 313 } |
| 308 | 314 |
| 309 } // namespace chromeos | 315 } // namespace chromeos |
| OLD | NEW |