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

Side by Side Diff: ui/display/manager/display_manager_utilities.cc

Issue 2945913003: Add 1.6x mode. (Closed)
Patch Set: Add 1.6x support Created 3 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ui/display/manager/display_manager_utilities.h" 5 #include "ui/display/manager/display_manager_utilities.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/sys_info.h" 10 #include "base/sys_info.h"
11 #include "ui/display/manager/managed_display_info.h" 11 #include "ui/display/manager/managed_display_info.h"
12 #include "ui/gfx/geometry/size_conversions.h" 12 #include "ui/gfx/geometry/size_conversions.h"
13 #include "ui/gfx/geometry/size_f.h" 13 #include "ui/gfx/geometry/size_f.h"
14 14
15 namespace display { 15 namespace display {
16 16
17 namespace { 17 namespace {
18 18
19 // List of value UI Scale values. Scales for 2x are equivalent to 640, 19 // List of value UI Scale values. Scales for 2x are equivalent to 640,
20 // 800, 1024, 1280, 1440, 1600 and 1920 pixel width respectively on 20 // 800, 1024, 1280, 1440, 1600 and 1920 pixel width respectively on
21 // 2560 pixel width 2x density display. Please see crbug.com/233375 21 // 2560 pixel width 2x density display. Please see crbug.com/233375
22 // for the full list of resolutions. 22 // for the full list of resolutions.
23 constexpr float kUIScalesFor2x[] = {0.5f, 0.625f, 0.8f, 1.0f, 23 constexpr float kUIScalesFor2x[] = {0.5f, 0.625f, 0.8f, 1.0f,
24 1.125f, 1.25f, 1.5f, 2.0f}; 24 1.125f, 1.25f, 1.5f, 2.0f};
25 constexpr float kUIScalesFor1_25x[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.25f}; 25 constexpr float kUIScalesFor1_25x[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.25f};
26 constexpr float kUIScalesFor1_6x[] = {0.5f, 0.8f, 1.0f, 1.2f, 1.6f};
27
26 constexpr float kUIScalesFor1280[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.125f}; 28 constexpr float kUIScalesFor1280[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.125f};
27 constexpr float kUIScalesFor1366[] = {0.5f, 0.6f, 0.75f, 1.0f, 1.125f}; 29 constexpr float kUIScalesFor1366[] = {0.5f, 0.6f, 0.75f, 1.0f, 1.125f};
30 constexpr float kUIScalesForFHD[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.25f};
28 31
29 // The default UI scales for the above display densities. 32 // The default UI scales for the above display densities.
30 constexpr float kDefaultUIScaleFor2x = 1.0f; 33 constexpr float kDefaultUIScaleFor2x = 1.0f;
31 constexpr float kDefaultUIScaleFor1_25x = 0.8f; 34 constexpr float kDefaultUIScaleFor1_25x = 0.8f;
35 constexpr float kDefaultUIScaleFor1_6x = 1.0f;
32 constexpr float kDefaultUIScaleFor1280 = 1.0f; 36 constexpr float kDefaultUIScaleFor1280 = 1.0f;
33 constexpr float kDefaultUIScaleFor1366 = 1.0f; 37 constexpr float kDefaultUIScaleFor1366 = 1.0f;
38 constexpr float kDefaultUIScaleForFHD = 1.0f;
34 39
35 // Encapsulates the list of UI scales and the default one. 40 // Encapsulates the list of UI scales and the default one.
36 struct DisplayUIScales { 41 struct DisplayUIScales {
37 std::vector<float> scales; 42 std::vector<float> scales;
38 float default_scale; 43 float default_scale;
39 }; 44 };
40 45
41 DisplayUIScales GetScalesForDisplay( 46 DisplayUIScales GetScalesForDisplay(
42 const scoped_refptr<ManagedDisplayMode>& native_mode) { 47 const scoped_refptr<ManagedDisplayMode>& native_mode) {
43 #define ASSIGN_ARRAY(v, a) v.assign(a, a + arraysize(a)) 48 #define ASSIGN_ARRAY(v, a) v.assign(a, a + arraysize(a))
44 49
45 DisplayUIScales ret; 50 DisplayUIScales ret;
46 if (native_mode->device_scale_factor() == 2.0f) { 51 if (native_mode->device_scale_factor() == 2.0f) {
47 ASSIGN_ARRAY(ret.scales, kUIScalesFor2x); 52 ASSIGN_ARRAY(ret.scales, kUIScalesFor2x);
48 ret.default_scale = kDefaultUIScaleFor2x; 53 ret.default_scale = kDefaultUIScaleFor2x;
49 return ret; 54 return ret;
50 } else if (native_mode->device_scale_factor() == 1.25f) { 55 } else if (native_mode->device_scale_factor() == 1.25f) {
51 ASSIGN_ARRAY(ret.scales, kUIScalesFor1_25x); 56 ASSIGN_ARRAY(ret.scales, kUIScalesFor1_25x);
52 ret.default_scale = kDefaultUIScaleFor1_25x; 57 ret.default_scale = kDefaultUIScaleFor1_25x;
53 return ret; 58 return ret;
59 } else if (native_mode->device_scale_factor() == 1.6f) {
60 ASSIGN_ARRAY(ret.scales, kUIScalesFor1_6x);
61 ret.default_scale = kDefaultUIScaleFor1_6x;
62 return ret;
54 } 63 }
55 switch (native_mode->size().width()) { 64 switch (native_mode->size().width()) {
56 case 1280: 65 case 1280:
57 ASSIGN_ARRAY(ret.scales, kUIScalesFor1280); 66 ASSIGN_ARRAY(ret.scales, kUIScalesFor1280);
58 ret.default_scale = kDefaultUIScaleFor1280; 67 ret.default_scale = kDefaultUIScaleFor1280;
59 break; 68 break;
60 case 1366: 69 case 1366:
61 ASSIGN_ARRAY(ret.scales, kUIScalesFor1366); 70 ASSIGN_ARRAY(ret.scales, kUIScalesFor1366);
62 ret.default_scale = kDefaultUIScaleFor1366; 71 ret.default_scale = kDefaultUIScaleFor1366;
63 break; 72 break;
73 case 1980:
74 ASSIGN_ARRAY(ret.scales, kUIScalesForFHD);
75 ret.default_scale = kDefaultUIScaleForFHD;
76 break;
64 default: 77 default:
65 ASSIGN_ARRAY(ret.scales, kUIScalesFor1280); 78 ASSIGN_ARRAY(ret.scales, kUIScalesFor1280);
66 ret.default_scale = kDefaultUIScaleFor1280; 79 ret.default_scale = kDefaultUIScaleFor1280;
67 #if defined(OS_CHROMEOS) 80 #if defined(OS_CHROMEOS)
68 if (base::SysInfo::IsRunningOnChromeOS()) 81 if (base::SysInfo::IsRunningOnChromeOS())
69 NOTREACHED() << "Unknown resolution:" << native_mode->size().ToString(); 82 NOTREACHED() << "Unknown resolution:" << native_mode->size().ToString();
70 #endif 83 #endif
71 } 84 }
72 return ret; 85 return ret;
73 } 86 }
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 std::stringstream s; 294 std::stringstream s;
282 const char* sep = ""; 295 const char* sep = "";
283 for (int64_t id : list) { 296 for (int64_t id : list) {
284 s << sep << id; 297 s << sep << id;
285 sep = ","; 298 sep = ",";
286 } 299 }
287 return s.str(); 300 return s.str();
288 } 301 }
289 302
290 } // namespace display 303 } // namespace display
OLDNEW
« no previous file with comments | « ui/display/manager/chromeos/display_change_observer_unittest.cc ('k') | ui/display/manager/managed_display_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698