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

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

Issue 579053002: Remove "upgrading to 2x DSF for lower UI scale when 2x resoruces are available" option (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 6 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 | « 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 { 24 namespace {
25 25
26 // TODO(oshima): This feature is obsolete. Remove this after m38.
27 bool allow_upgrade_to_high_dpi = false;
28
29 bool use_125_dsf_for_ui_scaling = false; 26 bool use_125_dsf_for_ui_scaling = false;
30 27
31 // Check the content of |spec| and fill |bounds| and |device_scale_factor|. 28 // Check the content of |spec| and fill |bounds| and |device_scale_factor|.
32 // Returns true when |bounds| is found. 29 // Returns true when |bounds| is found.
33 bool GetDisplayBounds( 30 bool GetDisplayBounds(
34 const std::string& spec, gfx::Rect* bounds, float* device_scale_factor) { 31 const std::string& spec, gfx::Rect* bounds, float* device_scale_factor) {
35 int width = 0; 32 int width = 0;
36 int height = 0; 33 int height = 0;
37 int x = 0; 34 int x = 0;
38 int y = 0; 35 int y = 0;
39 if (sscanf(spec.c_str(), "%dx%d*%f", 36 if (sscanf(spec.c_str(), "%dx%d*%f",
40 &width, &height, device_scale_factor) >= 2 || 37 &width, &height, device_scale_factor) >= 2 ||
41 sscanf(spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height, 38 sscanf(spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height,
42 device_scale_factor) >= 4) { 39 device_scale_factor) >= 4) {
43 bounds->SetRect(x, y, width, height); 40 bounds->SetRect(x, y, width, height);
44 return true; 41 return true;
45 } 42 }
46 return false; 43 return false;
47 } 44 }
48 45
49 } 46 } // namespace
50 47
51 DisplayMode::DisplayMode() 48 DisplayMode::DisplayMode()
52 : refresh_rate(0.0f), 49 : refresh_rate(0.0f),
53 interlaced(false), 50 interlaced(false),
54 native(false), 51 native(false),
55 ui_scale(1.0f), 52 ui_scale(1.0f),
56 device_scale_factor(1.0f) {} 53 device_scale_factor(1.0f) {}
57 54
58 DisplayMode::DisplayMode(const gfx::Size& size, 55 DisplayMode::DisplayMode(const gfx::Size& size,
59 float refresh_rate, 56 float refresh_rate,
(...skipping 19 matching lines...) Expand all
79 std::abs(ui_scale - other.ui_scale) < kEpsilon && 76 std::abs(ui_scale - other.ui_scale) < kEpsilon &&
80 std::abs(device_scale_factor - other.device_scale_factor) < kEpsilon; 77 std::abs(device_scale_factor - other.device_scale_factor) < kEpsilon;
81 } 78 }
82 79
83 // satic 80 // satic
84 DisplayInfo DisplayInfo::CreateFromSpec(const std::string& spec) { 81 DisplayInfo DisplayInfo::CreateFromSpec(const std::string& spec) {
85 return CreateFromSpecWithID(spec, gfx::Display::kInvalidDisplayID); 82 return CreateFromSpecWithID(spec, gfx::Display::kInvalidDisplayID);
86 } 83 }
87 84
88 // static 85 // static
89 void DisplayInfo::SetAllowUpgradeToHighDPI(bool enable) {
90 allow_upgrade_to_high_dpi = enable;
91 }
92 86
93 // static 87 // static
94 void DisplayInfo::SetUse125DSFForUIScaling(bool enable) { 88 void DisplayInfo::SetUse125DSFForUIScaling(bool enable) {
95 use_125_dsf_for_ui_scaling = enable; 89 use_125_dsf_for_ui_scaling = enable;
96 } 90 }
97 91
98 // static 92 // static
99 DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec, 93 DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec,
100 int64 id) { 94 int64 id) {
101 // Default bounds for a display. 95 // Default bounds for a display.
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 279
286 void DisplayInfo::SetBounds(const gfx::Rect& new_bounds_in_native) { 280 void DisplayInfo::SetBounds(const gfx::Rect& new_bounds_in_native) {
287 bounds_in_native_ = new_bounds_in_native; 281 bounds_in_native_ = new_bounds_in_native;
288 size_in_pixel_ = new_bounds_in_native.size(); 282 size_in_pixel_ = new_bounds_in_native.size();
289 UpdateDisplaySize(); 283 UpdateDisplaySize();
290 } 284 }
291 285
292 float DisplayInfo::GetEffectiveDeviceScaleFactor() const { 286 float DisplayInfo::GetEffectiveDeviceScaleFactor() const {
293 if (use_125_dsf_for_ui_scaling && device_scale_factor_ == 1.25f) 287 if (use_125_dsf_for_ui_scaling && device_scale_factor_ == 1.25f)
294 return (configured_ui_scale_ == 0.8f) ? 1.25f : 1.0f; 288 return (configured_ui_scale_ == 0.8f) ? 1.25f : 1.0f;
295 289 if (device_scale_factor_ == configured_ui_scale_)
296 if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f &&
297 device_scale_factor_ == 1.0f) {
298 return 2.0f;
299 } else if (device_scale_factor_ == configured_ui_scale_) {
300 return 1.0f; 290 return 1.0f;
301 }
302 return device_scale_factor_; 291 return device_scale_factor_;
303 } 292 }
304 293
305 float DisplayInfo::GetEffectiveUIScale() const { 294 float DisplayInfo::GetEffectiveUIScale() const {
306 if (use_125_dsf_for_ui_scaling && device_scale_factor_ == 1.25f) 295 if (use_125_dsf_for_ui_scaling && device_scale_factor_ == 1.25f)
307 return (configured_ui_scale_ == 0.8f) ? 1.0f : configured_ui_scale_; 296 return (configured_ui_scale_ == 0.8f) ? 1.0f : configured_ui_scale_;
308 297 if (device_scale_factor_ == configured_ui_scale_)
309 if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f &&
310 device_scale_factor_ == 1.0f) {
311 return configured_ui_scale_ * 2.0f;
312 } else if (device_scale_factor_ == configured_ui_scale_) {
313 return 1.0f; 298 return 1.0f;
314 }
315 return configured_ui_scale_; 299 return configured_ui_scale_;
316 } 300 }
317 301
318 void DisplayInfo::UpdateDisplaySize() { 302 void DisplayInfo::UpdateDisplaySize() {
319 size_in_pixel_ = bounds_in_native_.size(); 303 size_in_pixel_ = bounds_in_native_.size();
320 if (!overscan_insets_in_dip_.empty()) { 304 if (!overscan_insets_in_dip_.empty()) {
321 gfx::Insets insets_in_pixel = 305 gfx::Insets insets_in_pixel =
322 overscan_insets_in_dip_.Scale(device_scale_factor_); 306 overscan_insets_in_dip_.Scale(device_scale_factor_);
323 size_in_pixel_.Enlarge(-insets_in_pixel.width(), -insets_in_pixel.height()); 307 size_in_pixel_.Enlarge(-insets_in_pixel.width(), -insets_in_pixel.height());
324 } else { 308 } else {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 } 378 }
395 379
396 bool DisplayInfo::IsColorProfileAvailable( 380 bool DisplayInfo::IsColorProfileAvailable(
397 ui::ColorCalibrationProfile profile) const { 381 ui::ColorCalibrationProfile profile) const {
398 return std::find(available_color_profiles_.begin(), 382 return std::find(available_color_profiles_.begin(),
399 available_color_profiles_.end(), 383 available_color_profiles_.end(),
400 profile) != available_color_profiles_.end(); 384 profile) != available_color_profiles_.end();
401 } 385 }
402 386
403 } // namespace ash 387 } // 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