Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: ash/display/display_change_observer_chromeos.cc

Issue 1289043002: Hookup device dpi for ChromeOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use 96 for black listed displays Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ash/display/display_info.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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/21 23:11:51 can you check the blacklist and simply set it to z
bshe 2015/09/22 00:20:24 Done.
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
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 if (!ui::IsDisplaySizeBlackListed(state->physical_size())) {
237 // Only sets dpi if the size is not black listed. Otherwise, use the
238 // default dpi 96.0.
239 new_info.set_device_dpi(dpi);
240 }
237 241
238 std::vector<DisplayMode> display_modes = 242 std::vector<DisplayMode> display_modes =
239 (state->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL) 243 (state->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL)
240 ? GetInternalDisplayModeList(new_info, *state) 244 ? GetInternalDisplayModeList(new_info, *state)
241 : GetExternalDisplayModeList(*state); 245 : GetExternalDisplayModeList(*state);
242 new_info.SetDisplayModes(display_modes); 246 new_info.SetDisplayModes(display_modes);
243 247
244 new_info.set_available_color_profiles( 248 new_info.set_available_color_profiles(
245 Shell::GetInstance() 249 Shell::GetInstance()
246 ->display_configurator() 250 ->display_configurator()
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 } 290 }
287 return 1.0f; 291 return 1.0f;
288 } 292 }
289 293
290 void DisplayChangeObserver::OnTouchscreenDeviceConfigurationChanged() { 294 void DisplayChangeObserver::OnTouchscreenDeviceConfigurationChanged() {
291 OnDisplayModeChanged( 295 OnDisplayModeChanged(
292 Shell::GetInstance()->display_configurator()->cached_displays()); 296 Shell::GetInstance()->display_configurator()->cached_displays());
293 } 297 }
294 298
295 } // namespace ash 299 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/display/display_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698