OLD | NEW |
---|---|
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/gfx/monitor.h" | 5 #include "ui/gfx/monitor.h" |
6 | 6 |
7 #include "base/command_line.h" | |
8 #include "base/string_number_conversions.h" | |
9 #include "base/stringprintf.h" | |
10 #include "ui/gfx/gfx_switches.h" | |
7 #include "ui/gfx/insets.h" | 11 #include "ui/gfx/insets.h" |
8 #include "base/stringprintf.h" | |
9 | 12 |
10 namespace gfx { | 13 namespace gfx { |
14 namespace { | |
11 | 15 |
12 Monitor::Monitor() : id_(-1), device_scale_factor_(1.0) { | 16 float GetDefaultDeviceScaleFactorImpl() { |
17 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
18 if (command_line.HasSwitch(switches::kDefaultDeviceScaleFactor)) { | |
19 double scale_in_double; | |
20 base::StringToDouble( | |
sadrul
2012/04/30 18:57:00
Check the return value of StringToDouble?
oshima
2012/04/30 19:41:14
Done.
| |
21 command_line.GetSwitchValueASCII(switches::kDefaultDeviceScaleFactor), | |
22 &scale_in_double); | |
23 return static_cast<float>(scale_in_double); | |
24 } | |
25 return 1.0f; | |
13 } | 26 } |
14 | 27 |
15 Monitor::Monitor(int id) : id_(id), device_scale_factor_(1.0) { | 28 } // namespace |
29 | |
30 // static | |
31 float Monitor::GetDefaultDeviceScaleFactor() { | |
32 static float default_device_scale_factor = | |
33 GetDefaultDeviceScaleFactorImpl(); | |
34 return default_device_scale_factor; | |
35 } | |
36 | |
37 Monitor::Monitor() | |
38 : id_(-1), | |
39 device_scale_factor_(GetDefaultDeviceScaleFactor()) { | |
40 } | |
41 | |
42 Monitor::Monitor(int id) | |
43 : id_(id), | |
44 device_scale_factor_(GetDefaultDeviceScaleFactor()) { | |
16 } | 45 } |
17 | 46 |
18 Monitor::Monitor(int id, const gfx::Rect& bounds) | 47 Monitor::Monitor(int id, const gfx::Rect& bounds) |
19 : id_(id), | 48 : id_(id), |
20 bounds_(bounds), | 49 bounds_(bounds), |
21 work_area_(bounds), | 50 work_area_(bounds), |
22 device_scale_factor_(1.0) { | 51 device_scale_factor_(GetDefaultDeviceScaleFactor()) { |
23 #if defined(USE_ASH) | 52 #if defined(USE_ASH) |
24 SetScaleAndBounds(device_scale_factor_, bounds); | 53 SetScaleAndBounds(device_scale_factor_, bounds); |
25 #endif | 54 #endif |
26 } | 55 } |
27 | 56 |
28 Monitor::~Monitor() { | 57 Monitor::~Monitor() { |
29 } | 58 } |
30 | 59 |
31 void Monitor::SetScaleAndBounds( | 60 void Monitor::SetScaleAndBounds( |
32 float device_scale_factor, | 61 float device_scale_factor, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 | 94 |
66 std::string Monitor::ToString() const { | 95 std::string Monitor::ToString() const { |
67 return base::StringPrintf("Monitor[%d] bounds=%s, workarea=%s, scale=%f", | 96 return base::StringPrintf("Monitor[%d] bounds=%s, workarea=%s, scale=%f", |
68 id_, | 97 id_, |
69 bounds_.ToString().c_str(), | 98 bounds_.ToString().c_str(), |
70 work_area_.ToString().c_str(), | 99 work_area_.ToString().c_str(), |
71 device_scale_factor_); | 100 device_scale_factor_); |
72 } | 101 } |
73 | 102 |
74 } // namespace gfx | 103 } // namespace gfx |
OLD | NEW |