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/display.h" | 5 #include "ui/gfx/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" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "ui/gfx/insets.h" | 13 #include "ui/gfx/insets.h" |
14 #include "ui/gfx/point_conversions.h" | 14 #include "ui/gfx/point_conversions.h" |
15 #include "ui/gfx/point_f.h" | 15 #include "ui/gfx/point_f.h" |
16 #include "ui/gfx/size_conversions.h" | 16 #include "ui/gfx/size_conversions.h" |
17 #include "ui/gfx/switches.h" | 17 #include "ui/gfx/switches.h" |
18 | 18 |
19 namespace gfx { | 19 namespace gfx { |
20 namespace { | 20 namespace { |
21 | 21 |
22 bool HasForceDeviceScaleFactorImpl() { | |
23 return base::CommandLine::ForCurrentProcess()->HasSwitch( | |
24 switches::kForceDeviceScaleFactor); | |
25 } | |
26 | |
27 float GetForcedDeviceScaleFactorImpl() { | |
28 double scale_in_double = 1.0; | |
29 if (HasForceDeviceScaleFactorImpl()) { | |
30 std::string value = base::CommandLine::ForCurrentProcess()-> | |
31 GetSwitchValueASCII(switches::kForceDeviceScaleFactor); | |
32 if (!base::StringToDouble(value, &scale_in_double)) | |
33 LOG(ERROR) << "Failed to parse the default device scale factor:" << value; | |
34 } | |
35 return static_cast<float>(scale_in_double); | |
36 } | |
37 | |
38 int64 internal_display_id_ = -1; | 22 int64 internal_display_id_ = -1; |
39 | 23 |
40 } // namespace | 24 } // namespace |
41 | 25 |
42 const int64 Display::kInvalidDisplayID = -1; | 26 const int64 Display::kInvalidDisplayID = -1; |
43 | 27 |
44 // static | 28 // static |
45 float Display::GetForcedDeviceScaleFactor() { | 29 float Display::GetForcedDeviceScaleFactor() { |
46 static const float kForcedDeviceScaleFactor = | 30 return 1.0f; |
47 GetForcedDeviceScaleFactorImpl(); | |
48 return kForcedDeviceScaleFactor; | |
49 } | 31 } |
50 | 32 |
51 //static | 33 //static |
52 bool Display::HasForceDeviceScaleFactor() { | 34 bool Display::HasForceDeviceScaleFactor() { |
53 static const bool kHasForceDeviceScaleFactor = | 35 return false; |
54 HasForceDeviceScaleFactorImpl(); | |
55 return kHasForceDeviceScaleFactor; | |
56 } | 36 } |
57 | 37 |
58 Display::Display() | 38 Display::Display() |
59 : id_(kInvalidDisplayID), | 39 : id_(kInvalidDisplayID), |
60 device_scale_factor_(GetForcedDeviceScaleFactor()), | 40 device_scale_factor_(GetForcedDeviceScaleFactor()), |
61 rotation_(ROTATE_0), | 41 rotation_(ROTATE_0), |
62 touch_support_(TOUCH_SUPPORT_UNKNOWN) { | 42 touch_support_(TOUCH_SUPPORT_UNKNOWN) { |
63 } | 43 } |
64 | 44 |
65 Display::Display(int64 id) | 45 Display::Display(int64 id) |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 163 |
184 int64 Display::InternalDisplayId() { | 164 int64 Display::InternalDisplayId() { |
185 return internal_display_id_; | 165 return internal_display_id_; |
186 } | 166 } |
187 | 167 |
188 void Display::SetInternalDisplayId(int64 internal_display_id) { | 168 void Display::SetInternalDisplayId(int64 internal_display_id) { |
189 internal_display_id_ = internal_display_id; | 169 internal_display_id_ = internal_display_id; |
190 } | 170 } |
191 | 171 |
192 } // namespace gfx | 172 } // namespace gfx |
OLD | NEW |