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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 return gfx::Insets(work_area_.y() - bounds_.y(), | 76 return gfx::Insets(work_area_.y() - bounds_.y(), |
77 work_area_.x() - bounds_.x(), | 77 work_area_.x() - bounds_.x(), |
78 bounds_.bottom() - work_area_.bottom(), | 78 bounds_.bottom() - work_area_.bottom(), |
79 bounds_.right() - work_area_.right()); | 79 bounds_.right() - work_area_.right()); |
80 } | 80 } |
81 | 81 |
82 void Display::SetScaleAndBounds( | 82 void Display::SetScaleAndBounds( |
83 float device_scale_factor, | 83 float device_scale_factor, |
84 const gfx::Rect& bounds_in_pixel) { | 84 const gfx::Rect& bounds_in_pixel) { |
85 Insets insets = bounds_.InsetsFrom(work_area_); | 85 Insets insets = bounds_.InsetsFrom(work_area_); |
86 if (!HasForceDeviceScaleFactor()) | 86 if (!HasForceDeviceScaleFactor()) { |
87 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) | |
88 // Unless an explicit scale factor was provided for testing, ensure the | |
89 // scale is integral. | |
90 device_scale_factor = static_cast<int>(device_scale_factor); | |
91 #endif | |
87 device_scale_factor_ = device_scale_factor; | 92 device_scale_factor_ = device_scale_factor; |
93 } | |
94 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) | |
johnme
2012/11/06 15:45:34
We want this on Android (and all other platforms)
Sami
2012/11/06 17:08:47
Ok, I wasn't sure if this was the case so thanks f
| |
95 device_scale_factor_ = std::max(1.0f, device_scale_factor_); | |
96 #endif | |
88 #if defined(USE_AURA) | 97 #if defined(USE_AURA) |
89 bounds_in_pixel_ = bounds_in_pixel; | 98 bounds_in_pixel_ = bounds_in_pixel; |
90 #endif | 99 #endif |
91 bounds_ = gfx::Rect(gfx::ToFlooredSize( | 100 bounds_ = gfx::Rect(gfx::ToFlooredSize( |
92 bounds_in_pixel.size().Scale(1.0f / device_scale_factor_))); | 101 bounds_in_pixel.size().Scale(1.0f / device_scale_factor_))); |
93 UpdateWorkAreaFromInsets(insets); | 102 UpdateWorkAreaFromInsets(insets); |
94 } | 103 } |
95 | 104 |
96 void Display::SetSize(const gfx::Size& size_in_pixel) { | 105 void Display::SetSize(const gfx::Size& size_in_pixel) { |
97 SetScaleAndBounds( | 106 SetScaleAndBounds( |
(...skipping 16 matching lines...) Expand all Loading... | |
114 | 123 |
115 std::string Display::ToString() const { | 124 std::string Display::ToString() const { |
116 return base::StringPrintf("Display[%lld] bounds=%s, workarea=%s, scale=%f", | 125 return base::StringPrintf("Display[%lld] bounds=%s, workarea=%s, scale=%f", |
117 static_cast<long long int>(id_), | 126 static_cast<long long int>(id_), |
118 bounds_.ToString().c_str(), | 127 bounds_.ToString().c_str(), |
119 work_area_.ToString().c_str(), | 128 work_area_.ToString().c_str(), |
120 device_scale_factor_); | 129 device_scale_factor_); |
121 } | 130 } |
122 | 131 |
123 } // namespace gfx | 132 } // namespace gfx |
OLD | NEW |