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

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

Issue 2855143004: Implements a display scale tray setting behind a chrome switch (Closed)
Patch Set: Sync with ToT Created 3 years, 7 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) 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 "ui/display/display.h" 5 #include "ui/display/display.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 g_has_forced_device_scale_factor = HasForceDeviceScaleFactorImpl(); 83 g_has_forced_device_scale_factor = HasForceDeviceScaleFactorImpl();
84 return !!g_has_forced_device_scale_factor; 84 return !!g_has_forced_device_scale_factor;
85 } 85 }
86 86
87 // static 87 // static
88 void Display::ResetForceDeviceScaleFactorForTesting() { 88 void Display::ResetForceDeviceScaleFactorForTesting() {
89 g_has_forced_device_scale_factor = -1; 89 g_has_forced_device_scale_factor = -1;
90 g_forced_device_scale_factor = -1.0; 90 g_forced_device_scale_factor = -1.0;
91 } 91 }
92 92
93 // static
94 void Display::SetForceDeviceScaleFactor(double dsf) {
95 std::string str_value = base::DoubleToString(dsf);
96
97 // We need a precision of upto 2 decimal point.
98 if (str_value.length() > 4)
99 str_value.erase(str_value.begin() + 4, str_value.end());
100
101 // Reset any previously set values and unset the flag.
102 g_has_forced_device_scale_factor = -1;
103 g_forced_device_scale_factor = -1.0;
104
105 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
106 switches::kForceDeviceScaleFactor, str_value);
107 }
108
93 Display::Display() : Display(kInvalidDisplayId) {} 109 Display::Display() : Display(kInvalidDisplayId) {}
94 110
95 Display::Display(int64_t id) : Display(id, gfx::Rect()) {} 111 Display::Display(int64_t id) : Display(id, gfx::Rect()) {}
96 112
97 Display::Display(int64_t id, const gfx::Rect& bounds) 113 Display::Display(int64_t id, const gfx::Rect& bounds)
98 : id_(id), 114 : id_(id),
99 bounds_(bounds), 115 bounds_(bounds),
100 work_area_(bounds), 116 work_area_(bounds),
101 device_scale_factor_(GetForcedDeviceScaleFactor()), 117 device_scale_factor_(GetForcedDeviceScaleFactor()),
102 color_depth_(DEFAULT_BITS_PER_PIXEL), 118 color_depth_(DEFAULT_BITS_PER_PIXEL),
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 DCHECK_NE(kInvalidDisplayId, display_id); 241 DCHECK_NE(kInvalidDisplayId, display_id);
226 return HasInternalDisplay() && internal_display_id_ == display_id; 242 return HasInternalDisplay() && internal_display_id_ == display_id;
227 } 243 }
228 244
229 // static 245 // static
230 bool Display::HasInternalDisplay() { 246 bool Display::HasInternalDisplay() {
231 return internal_display_id_ != kInvalidDisplayId; 247 return internal_display_id_ != kInvalidDisplayId;
232 } 248 }
233 249
234 } // namespace display 250 } // namespace display
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698