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

Side by Side Diff: ash/display/display_info.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.h ('k') | ash/display/display_manager.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <stdio.h> 5 #include <stdio.h>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/display/display_info.h" 9 #include "ash/display/display_info.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "ui/gfx/display.h" 14 #include "ui/gfx/display.h"
15 #include "ui/gfx/size_conversions.h" 15 #include "ui/gfx/size_conversions.h"
16 #include "ui/gfx/size_f.h" 16 #include "ui/gfx/size_f.h"
17 17
18 #if defined(OS_WIN) 18 #if defined(OS_WIN)
19 #include "ui/aura/window_tree_host.h" 19 #include "ui/aura/window_tree_host.h"
20 #include "ui/gfx/win/dpi.h" 20 #include "ui/gfx/win/dpi.h"
21 #endif 21 #endif
22 22
23 namespace ash { 23 namespace ash {
24 namespace {
25
26 bool allow_upgrade_to_high_dpi = false;
27
28 }
24 29
25 DisplayMode::DisplayMode() 30 DisplayMode::DisplayMode()
26 : refresh_rate(0.0f), interlaced(false), native(false) {} 31 : refresh_rate(0.0f), interlaced(false), native(false) {}
27 32
28 DisplayMode::DisplayMode(const gfx::Size& size, 33 DisplayMode::DisplayMode(const gfx::Size& size,
29 float refresh_rate, 34 float refresh_rate,
30 bool interlaced, 35 bool interlaced,
31 bool native) 36 bool native)
32 : size(size), 37 : size(size),
33 refresh_rate(refresh_rate), 38 refresh_rate(refresh_rate),
34 interlaced(interlaced), 39 interlaced(interlaced),
35 native(native) {} 40 native(native) {}
36 41
37 // satic 42 // satic
38 DisplayInfo DisplayInfo::CreateFromSpec(const std::string& spec) { 43 DisplayInfo DisplayInfo::CreateFromSpec(const std::string& spec) {
39 return CreateFromSpecWithID(spec, gfx::Display::kInvalidDisplayID); 44 return CreateFromSpecWithID(spec, gfx::Display::kInvalidDisplayID);
40 } 45 }
41 46
42 // static 47 // static
48 void DisplayInfo::SetAllowUpgradeToHighDPI(bool enable) {
49 allow_upgrade_to_high_dpi = enable;
50 }
51
52 // static
43 DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec, 53 DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec,
44 int64 id) { 54 int64 id) {
45 // Default bounds for a display. 55 // Default bounds for a display.
46 const int kDefaultHostWindowX = 200; 56 const int kDefaultHostWindowX = 200;
47 const int kDefaultHostWindowY = 200; 57 const int kDefaultHostWindowY = 200;
48 const int kDefaultHostWindowWidth = 1366; 58 const int kDefaultHostWindowWidth = 1366;
49 const int kDefaultHostWindowHeight = 768; 59 const int kDefaultHostWindowHeight = 768;
50 60
51 // Use larger than max int to catch overflow early. 61 // Use larger than max int to catch overflow early.
52 static int64 synthesized_display_id = 2200000000LL; 62 static int64 synthesized_display_id = 2200000000LL;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // is treated as a native so that it can be specified in 238 // is treated as a native so that it can be specified in
229 // |CreateFromSpec|. 239 // |CreateFromSpec|.
230 } 240 }
231 241
232 void DisplayInfo::SetBounds(const gfx::Rect& new_bounds_in_native) { 242 void DisplayInfo::SetBounds(const gfx::Rect& new_bounds_in_native) {
233 bounds_in_native_ = new_bounds_in_native; 243 bounds_in_native_ = new_bounds_in_native;
234 size_in_pixel_ = new_bounds_in_native.size(); 244 size_in_pixel_ = new_bounds_in_native.size();
235 UpdateDisplaySize(); 245 UpdateDisplaySize();
236 } 246 }
237 247
248 float DisplayInfo::GetEffectiveDeviceScaleFactor() const {
249 if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f &&
250 device_scale_factor_ == 1.0f) {
251 return 2.0f;
252 } else if (device_scale_factor_ == 2.0f && configured_ui_scale_ == 2.0f) {
253 return 1.0f;
254 }
255 return device_scale_factor_;
256 }
257
238 float DisplayInfo::GetEffectiveUIScale() const { 258 float DisplayInfo::GetEffectiveUIScale() const {
239 if (device_scale_factor_ == 2.0f && configured_ui_scale_ == 2.0f) 259 if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f &&
260 device_scale_factor_ == 1.0f) {
261 return configured_ui_scale_ * 2.0f;
262 } else if (device_scale_factor_ == 2.0f && configured_ui_scale_ == 2.0f) {
240 return 1.0f; 263 return 1.0f;
264 }
241 return configured_ui_scale_; 265 return configured_ui_scale_;
242 } 266 }
243 267
244 void DisplayInfo::UpdateDisplaySize() { 268 void DisplayInfo::UpdateDisplaySize() {
245 size_in_pixel_ = bounds_in_native_.size(); 269 size_in_pixel_ = bounds_in_native_.size();
246 if (!overscan_insets_in_dip_.empty()) { 270 if (!overscan_insets_in_dip_.empty()) {
247 gfx::Insets insets_in_pixel = 271 gfx::Insets insets_in_pixel =
248 overscan_insets_in_dip_.Scale(device_scale_factor_); 272 overscan_insets_in_dip_.Scale(device_scale_factor_);
249 size_in_pixel_.Enlarge(-insets_in_pixel.width(), -insets_in_pixel.height()); 273 size_in_pixel_.Enlarge(-insets_in_pixel.width(), -insets_in_pixel.height());
250 } else { 274 } else {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 } 333 }
310 334
311 bool DisplayInfo::IsColorProfileAvailable( 335 bool DisplayInfo::IsColorProfileAvailable(
312 ui::ColorCalibrationProfile profile) const { 336 ui::ColorCalibrationProfile profile) const {
313 return std::find(available_color_profiles_.begin(), 337 return std::find(available_color_profiles_.begin(),
314 available_color_profiles_.end(), 338 available_color_profiles_.end(),
315 profile) != available_color_profiles_.end(); 339 profile) != available_color_profiles_.end();
316 } 340 }
317 341
318 } // namespace ash 342 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_info.h ('k') | ash/display/display_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698