| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 device_scale_factor_(GetForcedDeviceScaleFactor()), | 63 device_scale_factor_(GetForcedDeviceScaleFactor()), |
| 64 rotation_(ROTATE_0) { | 64 rotation_(ROTATE_0) { |
| 65 } | 65 } |
| 66 | 66 |
| 67 Display::Display(int64 id, const gfx::Rect& bounds) | 67 Display::Display(int64 id, const gfx::Rect& bounds) |
| 68 : id_(id), | 68 : id_(id), |
| 69 bounds_(bounds), | 69 bounds_(bounds), |
| 70 work_area_(bounds), | 70 work_area_(bounds), |
| 71 device_scale_factor_(GetForcedDeviceScaleFactor()), | 71 device_scale_factor_(GetForcedDeviceScaleFactor()), |
| 72 rotation_(ROTATE_0) { | 72 rotation_(ROTATE_0) { |
| 73 #if defined(USE_AURA) | 73 #if defined(USE_AURA) || defined(ENABLE_HIDPI) |
| 74 SetScaleAndBounds(device_scale_factor_, bounds); | 74 SetScaleAndBounds(device_scale_factor_, bounds); |
| 75 #endif | 75 #endif |
| 76 } | 76 } |
| 77 | 77 |
| 78 Display::~Display() { | 78 Display::~Display() { |
| 79 } | 79 } |
| 80 | 80 |
| 81 Insets Display::GetWorkAreaInsets() const { | 81 Insets Display::GetWorkAreaInsets() const { |
| 82 return gfx::Insets(work_area_.y() - bounds_.y(), | 82 return gfx::Insets(work_area_.y() - bounds_.y(), |
| 83 work_area_.x() - bounds_.x(), | 83 work_area_.x() - bounds_.x(), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 101 bounds_ = gfx::Rect( | 101 bounds_ = gfx::Rect( |
| 102 gfx::ToFlooredPoint(gfx::ScalePoint(bounds_in_pixel.origin(), | 102 gfx::ToFlooredPoint(gfx::ScalePoint(bounds_in_pixel.origin(), |
| 103 1.0f / device_scale_factor_)), | 103 1.0f / device_scale_factor_)), |
| 104 gfx::ToFlooredSize(gfx::ScaleSize(bounds_in_pixel.size(), | 104 gfx::ToFlooredSize(gfx::ScaleSize(bounds_in_pixel.size(), |
| 105 1.0f / device_scale_factor_))); | 105 1.0f / device_scale_factor_))); |
| 106 UpdateWorkAreaFromInsets(insets); | 106 UpdateWorkAreaFromInsets(insets); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void Display::SetSize(const gfx::Size& size_in_pixel) { | 109 void Display::SetSize(const gfx::Size& size_in_pixel) { |
| 110 gfx::Point origin = bounds_.origin(); | 110 gfx::Point origin = bounds_.origin(); |
| 111 #if defined(USE_AURA) | 111 #if defined(USE_AURA) || defined(ENABLE_HIDPI) |
| 112 gfx::PointF origin_f = origin; | 112 gfx::PointF origin_f = origin; |
| 113 origin_f.Scale(device_scale_factor_); | 113 origin_f.Scale(device_scale_factor_); |
| 114 origin.SetPoint(origin_f.x(), origin_f.y()); | 114 origin.SetPoint(origin_f.x(), origin_f.y()); |
| 115 #endif | 115 #endif |
| 116 SetScaleAndBounds(device_scale_factor_, gfx::Rect(origin, size_in_pixel)); | 116 SetScaleAndBounds(device_scale_factor_, gfx::Rect(origin, size_in_pixel)); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { | 119 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { |
| 120 work_area_ = bounds_; | 120 work_area_ = bounds_; |
| 121 work_area_.Inset(insets); | 121 work_area_.Inset(insets); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 141 | 141 |
| 142 int64 Display::InternalDisplayId() { | 142 int64 Display::InternalDisplayId() { |
| 143 return internal_display_id_; | 143 return internal_display_id_; |
| 144 } | 144 } |
| 145 | 145 |
| 146 void Display::SetInternalDisplayId(int64 internal_display_id) { | 146 void Display::SetInternalDisplayId(int64 internal_display_id) { |
| 147 internal_display_id_ = internal_display_id; | 147 internal_display_id_ = internal_display_id; |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace gfx | 150 } // namespace gfx |
| OLD | NEW |