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

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

Issue 578553002: Use DSF instead of UI scale if the native DSF is 1.25 and UI Scale is 0.8x (dsf=1.25 equivalent) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@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
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. 26 // TODO(oshima): This feature is obsolete. Remove this after m38.
27 bool allow_upgrade_to_high_dpi = false; 27 bool allow_upgrade_to_high_dpi = false;
28 28
29 bool use_125_dsf_for_ui_scaling = false;
30
29 // Check the content of |spec| and fill |bounds| and |device_scale_factor|. 31 // Check the content of |spec| and fill |bounds| and |device_scale_factor|.
30 // Returns true when |bounds| is found. 32 // Returns true when |bounds| is found.
31 bool GetDisplayBounds( 33 bool GetDisplayBounds(
32 const std::string& spec, gfx::Rect* bounds, float* device_scale_factor) { 34 const std::string& spec, gfx::Rect* bounds, float* device_scale_factor) {
33 int width = 0; 35 int width = 0;
34 int height = 0; 36 int height = 0;
35 int x = 0; 37 int x = 0;
36 int y = 0; 38 int y = 0;
37 if (sscanf(spec.c_str(), "%dx%d*%f", 39 if (sscanf(spec.c_str(), "%dx%d*%f",
38 &width, &height, device_scale_factor) >= 2 || 40 &width, &height, device_scale_factor) >= 2 ||
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 DisplayInfo DisplayInfo::CreateFromSpec(const std::string& spec) { 84 DisplayInfo DisplayInfo::CreateFromSpec(const std::string& spec) {
83 return CreateFromSpecWithID(spec, gfx::Display::kInvalidDisplayID); 85 return CreateFromSpecWithID(spec, gfx::Display::kInvalidDisplayID);
84 } 86 }
85 87
86 // static 88 // static
87 void DisplayInfo::SetAllowUpgradeToHighDPI(bool enable) { 89 void DisplayInfo::SetAllowUpgradeToHighDPI(bool enable) {
88 allow_upgrade_to_high_dpi = enable; 90 allow_upgrade_to_high_dpi = enable;
89 } 91 }
90 92
91 // static 93 // static
94 void DisplayInfo::SetUse125DSFForUIScaling(bool enable) {
95 use_125_dsf_for_ui_scaling = enable;
96 }
97
98 // static
92 DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec, 99 DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec,
93 int64 id) { 100 int64 id) {
94 // Default bounds for a display. 101 // Default bounds for a display.
95 const int kDefaultHostWindowX = 200; 102 const int kDefaultHostWindowX = 200;
96 const int kDefaultHostWindowY = 200; 103 const int kDefaultHostWindowY = 200;
97 const int kDefaultHostWindowWidth = 1366; 104 const int kDefaultHostWindowWidth = 1366;
98 const int kDefaultHostWindowHeight = 768; 105 const int kDefaultHostWindowHeight = 768;
99 106
100 // Use larger than max int to catch overflow early. 107 // Use larger than max int to catch overflow early.
101 static int64 synthesized_display_id = 2200000000LL; 108 static int64 synthesized_display_id = 2200000000LL;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 // |CreateFromSpec|. 283 // |CreateFromSpec|.
277 } 284 }
278 285
279 void DisplayInfo::SetBounds(const gfx::Rect& new_bounds_in_native) { 286 void DisplayInfo::SetBounds(const gfx::Rect& new_bounds_in_native) {
280 bounds_in_native_ = new_bounds_in_native; 287 bounds_in_native_ = new_bounds_in_native;
281 size_in_pixel_ = new_bounds_in_native.size(); 288 size_in_pixel_ = new_bounds_in_native.size();
282 UpdateDisplaySize(); 289 UpdateDisplaySize();
283 } 290 }
284 291
285 float DisplayInfo::GetEffectiveDeviceScaleFactor() const { 292 float DisplayInfo::GetEffectiveDeviceScaleFactor() const {
293 if (use_125_dsf_for_ui_scaling && device_scale_factor_ == 1.25f)
294 return configured_ui_scale_ == 0.8f ? 1.25f : 1.0f;
Jun Mukai 2014/09/16 16:33:56 I personally prefer parens for this type of condit
oshima 2014/09/16 17:05:38 Done.
295
286 if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f && 296 if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f &&
287 device_scale_factor_ == 1.0f) { 297 device_scale_factor_ == 1.0f) {
288 return 2.0f; 298 return 2.0f;
289 } else if (device_scale_factor_ == configured_ui_scale_) { 299 } else if (device_scale_factor_ == configured_ui_scale_) {
290 return 1.0f; 300 return 1.0f;
291 } 301 }
292 return device_scale_factor_; 302 return device_scale_factor_;
293 } 303 }
294 304
295 float DisplayInfo::GetEffectiveUIScale() const { 305 float DisplayInfo::GetEffectiveUIScale() const {
306 if (use_125_dsf_for_ui_scaling && device_scale_factor_ == 1.25f)
307 return configured_ui_scale_ == 0.8f ? 1.0f : configured_ui_scale_;
Jun Mukai 2014/09/16 16:33:56 ditto
oshima 2014/09/16 17:05:38 Done.
308
296 if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f && 309 if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f &&
297 device_scale_factor_ == 1.0f) { 310 device_scale_factor_ == 1.0f) {
298 return configured_ui_scale_ * 2.0f; 311 return configured_ui_scale_ * 2.0f;
299 } else if (device_scale_factor_ == configured_ui_scale_) { 312 } else if (device_scale_factor_ == configured_ui_scale_) {
300 return 1.0f; 313 return 1.0f;
301 } 314 }
302 return configured_ui_scale_; 315 return configured_ui_scale_;
303 } 316 }
304 317
305 void DisplayInfo::UpdateDisplaySize() { 318 void DisplayInfo::UpdateDisplaySize() {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 394 }
382 395
383 bool DisplayInfo::IsColorProfileAvailable( 396 bool DisplayInfo::IsColorProfileAvailable(
384 ui::ColorCalibrationProfile profile) const { 397 ui::ColorCalibrationProfile profile) const {
385 return std::find(available_color_profiles_.begin(), 398 return std::find(available_color_profiles_.begin(),
386 available_color_profiles_.end(), 399 available_color_profiles_.end(),
387 profile) != available_color_profiles_.end(); 400 profile) != available_color_profiles_.end();
388 } 401 }
389 402
390 } // namespace ash 403 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698