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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 std::string value = CommandLine::ForCurrentProcess()-> | 25 std::string value = CommandLine::ForCurrentProcess()-> |
26 GetSwitchValueASCII(switches::kForceDeviceScaleFactor); | 26 GetSwitchValueASCII(switches::kForceDeviceScaleFactor); |
27 if (!base::StringToDouble(value, &scale_in_double)) | 27 if (!base::StringToDouble(value, &scale_in_double)) |
28 LOG(ERROR) << "Failed to parse the deafult device scale factor:" << value; | 28 LOG(ERROR) << "Failed to parse the deafult device scale factor:" << value; |
29 } | 29 } |
30 return static_cast<float>(scale_in_double); | 30 return static_cast<float>(scale_in_double); |
31 } | 31 } |
32 | 32 |
33 } // namespace | 33 } // namespace |
34 | 34 |
| 35 const int64 Display::kInvalidDisplayID = -1; |
| 36 |
35 // static | 37 // static |
36 float Display::GetForcedDeviceScaleFactor() { | 38 float Display::GetForcedDeviceScaleFactor() { |
37 static const float kForcedDeviceScaleFactor = | 39 static const float kForcedDeviceScaleFactor = |
38 GetForcedDeviceScaleFactorImpl(); | 40 GetForcedDeviceScaleFactorImpl(); |
39 return kForcedDeviceScaleFactor; | 41 return kForcedDeviceScaleFactor; |
40 } | 42 } |
41 | 43 |
| 44 // static |
| 45 int64 Display::GetID(uint16 manufacturer_id, uint32 serial_number) { |
| 46 int64 new_id = ((static_cast<int64>(manufacturer_id) << 32) | serial_number); |
| 47 DCHECK_NE(kInvalidDisplayID, new_id); |
| 48 return new_id; |
| 49 } |
| 50 |
42 Display::Display() | 51 Display::Display() |
43 : id_(-1), | 52 : id_(kInvalidDisplayID), |
44 device_scale_factor_(GetForcedDeviceScaleFactor()) { | 53 device_scale_factor_(GetForcedDeviceScaleFactor()) { |
45 } | 54 } |
46 | 55 |
47 Display::Display(int id) | 56 Display::Display(int64 id) |
48 : id_(id), | 57 : id_(id), |
49 device_scale_factor_(GetForcedDeviceScaleFactor()) { | 58 device_scale_factor_(GetForcedDeviceScaleFactor()) { |
50 } | 59 } |
51 | 60 |
52 Display::Display(int id, const gfx::Rect& bounds) | 61 Display::Display(int64 id, const gfx::Rect& bounds) |
53 : id_(id), | 62 : id_(id), |
54 bounds_(bounds), | 63 bounds_(bounds), |
55 work_area_(bounds), | 64 work_area_(bounds), |
56 device_scale_factor_(GetForcedDeviceScaleFactor()) { | 65 device_scale_factor_(GetForcedDeviceScaleFactor()) { |
57 #if defined(USE_AURA) | 66 #if defined(USE_AURA) |
58 SetScaleAndBounds(device_scale_factor_, bounds); | 67 SetScaleAndBounds(device_scale_factor_, bounds); |
59 #endif | 68 #endif |
60 } | 69 } |
61 | 70 |
62 Display::~Display() { | 71 Display::~Display() { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { | 105 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { |
97 work_area_ = bounds_; | 106 work_area_ = bounds_; |
98 work_area_.Inset(insets); | 107 work_area_.Inset(insets); |
99 } | 108 } |
100 | 109 |
101 gfx::Size Display::GetSizeInPixel() const { | 110 gfx::Size Display::GetSizeInPixel() const { |
102 return size().Scale(device_scale_factor_); | 111 return size().Scale(device_scale_factor_); |
103 } | 112 } |
104 | 113 |
105 std::string Display::ToString() const { | 114 std::string Display::ToString() const { |
106 return base::StringPrintf("Display[%d] bounds=%s, workarea=%s, scale=%f", | 115 return base::StringPrintf("Display[%lld] bounds=%s, workarea=%s, scale=%f", |
107 id_, | 116 static_cast<long long int>(id_), |
108 bounds_.ToString().c_str(), | 117 bounds_.ToString().c_str(), |
109 work_area_.ToString().c_str(), | 118 work_area_.ToString().c_str(), |
110 device_scale_factor_); | 119 device_scale_factor_); |
111 } | 120 } |
112 | 121 |
113 } // namespace gfx | 122 } // namespace gfx |
OLD | NEW |