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" | 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 Monitor::Monitor(int id) | 43 Monitor::Monitor(int id) |
44 : id_(id), | 44 : id_(id), |
45 device_scale_factor_(GetDefaultDeviceScaleFactor()) { | 45 device_scale_factor_(GetDefaultDeviceScaleFactor()) { |
46 } | 46 } |
47 | 47 |
48 Monitor::Monitor(int id, const gfx::Rect& bounds) | 48 Monitor::Monitor(int id, const gfx::Rect& bounds) |
49 : id_(id), | 49 : id_(id), |
50 bounds_(bounds), | 50 bounds_(bounds), |
51 work_area_(bounds), | 51 work_area_(bounds), |
52 device_scale_factor_(GetDefaultDeviceScaleFactor()) { | 52 device_scale_factor_(GetDefaultDeviceScaleFactor()) { |
53 #if defined(USE_ASH) | 53 #if defined(USE_AURA) |
54 SetScaleAndBounds(device_scale_factor_, bounds); | 54 SetScaleAndBounds(device_scale_factor_, bounds); |
55 #endif | 55 #endif |
56 } | 56 } |
57 | 57 |
58 Monitor::~Monitor() { | 58 Monitor::~Monitor() { |
59 } | 59 } |
60 | 60 |
61 void Monitor::SetScaleAndBounds( | 61 void Monitor::SetScaleAndBounds( |
62 float device_scale_factor, | 62 float device_scale_factor, |
63 const gfx::Rect& bounds_in_pixel) { | 63 const gfx::Rect& bounds_in_pixel) { |
64 Insets insets = bounds_.InsetsFrom(work_area_); | 64 Insets insets = bounds_.InsetsFrom(work_area_); |
65 device_scale_factor_ = device_scale_factor; | 65 device_scale_factor_ = device_scale_factor; |
66 #if defined(USE_ASH) | 66 #if defined(USE_AURA) |
67 bounds_in_pixel_ = bounds_in_pixel; | 67 bounds_in_pixel_ = bounds_in_pixel; |
68 #endif | 68 #endif |
69 // TODO(oshima): For m19, work area/monitor bounds that chrome/webapps sees | 69 // TODO(oshima): For m19, work area/monitor bounds that chrome/webapps sees |
70 // has (0, 0) origin because it's simpler and enough. Fix this when | 70 // has (0, 0) origin because it's simpler and enough. Fix this when |
71 // real multi monitor support is implemented. | 71 // real multi monitor support is implemented. |
72 #if defined(ENABLE_DIP) | 72 #if defined(ENABLE_DIP) |
73 bounds_ = gfx::Rect( | 73 bounds_ = gfx::Rect( |
74 bounds_in_pixel.size().Scale(1.0f / device_scale_factor_)); | 74 bounds_in_pixel.size().Scale(1.0f / device_scale_factor_)); |
75 #else | 75 #else |
76 bounds_ = gfx::Rect(bounds_in_pixel.size()); | 76 bounds_ = gfx::Rect(bounds_in_pixel.size()); |
77 #endif | 77 #endif |
78 UpdateWorkAreaFromInsets(insets); | 78 UpdateWorkAreaFromInsets(insets); |
79 } | 79 } |
80 | 80 |
81 void Monitor::SetSize(const gfx::Size& size_in_pixel) { | 81 void Monitor::SetSize(const gfx::Size& size_in_pixel) { |
82 SetScaleAndBounds( | 82 SetScaleAndBounds( |
83 device_scale_factor_, | 83 device_scale_factor_, |
84 #if defined(USE_ASH) | 84 #if defined(USE_AURA) |
85 gfx::Rect(bounds_in_pixel_.origin(), size_in_pixel)); | 85 gfx::Rect(bounds_in_pixel_.origin(), size_in_pixel)); |
86 #else | 86 #else |
87 gfx::Rect(bounds_.origin(), size_in_pixel)); | 87 gfx::Rect(bounds_.origin(), size_in_pixel)); |
88 #endif | 88 #endif |
89 } | 89 } |
90 | 90 |
91 void Monitor::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { | 91 void Monitor::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { |
92 work_area_ = bounds_; | 92 work_area_ = bounds_; |
93 work_area_.Inset(insets); | 93 work_area_.Inset(insets); |
94 } | 94 } |
95 | 95 |
96 std::string Monitor::ToString() const { | 96 std::string Monitor::ToString() const { |
97 return base::StringPrintf("Monitor[%d] bounds=%s, workarea=%s, scale=%f", | 97 return base::StringPrintf("Monitor[%d] bounds=%s, workarea=%s, scale=%f", |
98 id_, | 98 id_, |
99 bounds_.ToString().c_str(), | 99 bounds_.ToString().c_str(), |
100 work_area_.ToString().c_str(), | 100 work_area_.ToString().c_str(), |
101 device_scale_factor_); | 101 device_scale_factor_); |
102 } | 102 } |
103 | 103 |
104 } // namespace gfx | 104 } // namespace gfx |
OLD | NEW |