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

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

Issue 230683003: Allow upgrading to 2x DSF for lower UI scale when 2x resoruces are available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « ash/display/display_info.cc ('k') | ash/display/display_manager_unittest.cc » ('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 (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 "ash/display/display_manager.h" 5 #include "ash/display/display_manager.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "ash/ash_switches.h" 12 #include "ash/ash_switches.h"
13 #include "ash/display/display_layout_store.h" 13 #include "ash/display/display_layout_store.h"
14 #include "ash/display/screen_ash.h" 14 #include "ash/display/screen_ash.h"
15 #include "ash/screen_util.h" 15 #include "ash/screen_util.h"
16 #include "ash/shell.h" 16 #include "ash/shell.h"
17 #include "base/auto_reset.h" 17 #include "base/auto_reset.h"
18 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/metrics/histogram.h" 20 #include "base/metrics/histogram.h"
21 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/string_split.h" 22 #include "base/strings/string_split.h"
23 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
24 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
25 #include "grit/ash_strings.h" 25 #include "grit/ash_strings.h"
26 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/base/layout.h"
28 #include "ui/base/resource/resource_bundle.h"
27 #include "ui/gfx/display.h" 29 #include "ui/gfx/display.h"
28 #include "ui/gfx/rect.h" 30 #include "ui/gfx/rect.h"
29 #include "ui/gfx/screen.h" 31 #include "ui/gfx/screen.h"
30 #include "ui/gfx/size_conversions.h" 32 #include "ui/gfx/size_conversions.h"
31 33
32 #if defined(USE_X11) 34 #if defined(USE_X11)
33 #include "ui/base/x/x11_util.h" 35 #include "ui/base/x/x11_util.h"
34 #endif 36 #endif
35 37
36 #if defined(OS_CHROMEOS) 38 #if defined(OS_CHROMEOS)
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 layout_store_(new DisplayLayoutStore), 152 layout_store_(new DisplayLayoutStore),
151 first_display_id_(gfx::Display::kInvalidDisplayID), 153 first_display_id_(gfx::Display::kInvalidDisplayID),
152 num_connected_displays_(0), 154 num_connected_displays_(0),
153 force_bounds_changed_(false), 155 force_bounds_changed_(false),
154 change_display_upon_host_resize_(false), 156 change_display_upon_host_resize_(false),
155 second_display_mode_(EXTENDED), 157 second_display_mode_(EXTENDED),
156 mirrored_display_id_(gfx::Display::kInvalidDisplayID) { 158 mirrored_display_id_(gfx::Display::kInvalidDisplayID) {
157 #if defined(OS_CHROMEOS) 159 #if defined(OS_CHROMEOS)
158 change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS(); 160 change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS();
159 #endif 161 #endif
162 DisplayInfo::SetAllowUpgradeToHighDPI(
163 ui::ResourceBundle::GetSharedInstance().GetMaxScaleFactor() ==
164 ui::SCALE_FACTOR_200P);
165
160 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, 166 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE,
161 screen_ash_.get()); 167 screen_ash_.get());
162 gfx::Screen* current_native = 168 gfx::Screen* current_native =
163 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); 169 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE);
164 // If there is no native, or the native was for shutdown, 170 // If there is no native, or the native was for shutdown,
165 // use ash's screen. 171 // use ash's screen.
166 if (!current_native || 172 if (!current_native ||
167 current_native == screen_for_shutdown) { 173 current_native == screen_for_shutdown) {
168 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, 174 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE,
169 screen_ash_.get()); 175 screen_ash_.get());
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 } 1016 }
1011 #endif 1017 #endif
1012 } 1018 }
1013 1019
1014 gfx::Display DisplayManager::CreateDisplayFromDisplayInfoById(int64 id) { 1020 gfx::Display DisplayManager::CreateDisplayFromDisplayInfoById(int64 id) {
1015 DCHECK(display_info_.find(id) != display_info_.end()); 1021 DCHECK(display_info_.find(id) != display_info_.end());
1016 const DisplayInfo& display_info = display_info_[id]; 1022 const DisplayInfo& display_info = display_info_[id];
1017 1023
1018 gfx::Display new_display(display_info.id()); 1024 gfx::Display new_display(display_info.id());
1019 gfx::Rect bounds_in_native(display_info.size_in_pixel()); 1025 gfx::Rect bounds_in_native(display_info.size_in_pixel());
1020 float device_scale_factor = display_info.device_scale_factor(); 1026 float device_scale_factor = display_info.GetEffectiveDeviceScaleFactor();
1021 if (device_scale_factor == 2.0f && display_info.configured_ui_scale() == 2.0f)
1022 device_scale_factor = 1.0f;
1023 1027
1024 // Simply set the origin to (0,0). The primary display's origin is 1028 // Simply set the origin to (0,0). The primary display's origin is
1025 // always (0,0) and the secondary display's bounds will be updated 1029 // always (0,0) and the secondary display's bounds will be updated
1026 // in |UpdateSecondaryDisplayBoundsForLayout| called in |UpdateDisplay|. 1030 // in |UpdateSecondaryDisplayBoundsForLayout| called in |UpdateDisplay|.
1027 new_display.SetScaleAndBounds( 1031 new_display.SetScaleAndBounds(
1028 device_scale_factor, gfx::Rect(bounds_in_native.size())); 1032 device_scale_factor, gfx::Rect(bounds_in_native.size()));
1029 new_display.set_rotation(display_info.rotation()); 1033 new_display.set_rotation(display_info.rotation());
1030 new_display.set_touch_support(display_info.touch_support()); 1034 new_display.set_touch_support(display_info.touch_support());
1031 return new_display; 1035 return new_display;
1032 } 1036 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 new_secondary_origin.Offset(-secondary_bounds.width(), offset); 1115 new_secondary_origin.Offset(-secondary_bounds.width(), offset);
1112 break; 1116 break;
1113 } 1117 }
1114 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); 1118 gfx::Insets insets = secondary_display->GetWorkAreaInsets();
1115 secondary_display->set_bounds( 1119 secondary_display->set_bounds(
1116 gfx::Rect(new_secondary_origin, secondary_bounds.size())); 1120 gfx::Rect(new_secondary_origin, secondary_bounds.size()));
1117 secondary_display->UpdateWorkAreaFromInsets(insets); 1121 secondary_display->UpdateWorkAreaFromInsets(insets);
1118 } 1122 }
1119 1123
1120 } // namespace ash 1124 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_info.cc ('k') | ash/display/display_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698