| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 device_scale_factor_ = device_scale_factor; | 87 device_scale_factor_ = device_scale_factor; |
| 88 #if defined(USE_AURA) | 88 #if defined(USE_AURA) |
| 89 bounds_in_pixel_ = bounds_in_pixel; | 89 bounds_in_pixel_ = bounds_in_pixel; |
| 90 #endif | 90 #endif |
| 91 bounds_ = gfx::Rect(gfx::ToFlooredSize( | 91 bounds_ = gfx::Rect(gfx::ToFlooredSize( |
| 92 bounds_in_pixel.size().Scale(1.0f / device_scale_factor_))); | 92 gfx::ScaleSize(bounds_in_pixel.size(), 1.0f / device_scale_factor_))); |
| 93 UpdateWorkAreaFromInsets(insets); | 93 UpdateWorkAreaFromInsets(insets); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void Display::SetSize(const gfx::Size& size_in_pixel) { | 96 void Display::SetSize(const gfx::Size& size_in_pixel) { |
| 97 SetScaleAndBounds( | 97 SetScaleAndBounds( |
| 98 device_scale_factor_, | 98 device_scale_factor_, |
| 99 #if defined(USE_AURA) | 99 #if defined(USE_AURA) |
| 100 gfx::Rect(bounds_in_pixel_.origin(), size_in_pixel)); | 100 gfx::Rect(bounds_in_pixel_.origin(), size_in_pixel)); |
| 101 #else | 101 #else |
| 102 gfx::Rect(bounds_.origin(), size_in_pixel)); | 102 gfx::Rect(bounds_.origin(), size_in_pixel)); |
| 103 #endif | 103 #endif |
| 104 } | 104 } |
| 105 | 105 |
| 106 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { | 106 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { |
| 107 work_area_ = bounds_; | 107 work_area_ = bounds_; |
| 108 work_area_.Inset(insets); | 108 work_area_.Inset(insets); |
| 109 } | 109 } |
| 110 | 110 |
| 111 gfx::Size Display::GetSizeInPixel() const { | 111 gfx::Size Display::GetSizeInPixel() const { |
| 112 return gfx::ToFlooredSize(size().Scale(device_scale_factor_)); | 112 return gfx::ToFlooredSize(gfx::ScaleSize(size(), device_scale_factor_)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 std::string Display::ToString() const { | 115 std::string Display::ToString() const { |
| 116 return base::StringPrintf("Display[%lld] bounds=%s, workarea=%s, scale=%f", | 116 return base::StringPrintf("Display[%lld] bounds=%s, workarea=%s, scale=%f", |
| 117 static_cast<long long int>(id_), | 117 static_cast<long long int>(id_), |
| 118 bounds_.ToString().c_str(), | 118 bounds_.ToString().c_str(), |
| 119 work_area_.ToString().c_str(), | 119 work_area_.ToString().c_str(), |
| 120 device_scale_factor_); | 120 device_scale_factor_); |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace gfx | 123 } // namespace gfx |
| OLD | NEW |