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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 device_scale_factor_(GetForcedDeviceScaleFactor()), | 73 device_scale_factor_(GetForcedDeviceScaleFactor()), |
74 rotation_(ROTATE_0) { | 74 rotation_(ROTATE_0) { |
75 } | 75 } |
76 | 76 |
77 Display::Display(int64 id, const gfx::Rect& bounds) | 77 Display::Display(int64 id, const gfx::Rect& bounds) |
78 : id_(id), | 78 : id_(id), |
79 bounds_(bounds), | 79 bounds_(bounds), |
80 work_area_(bounds), | 80 work_area_(bounds), |
81 device_scale_factor_(GetForcedDeviceScaleFactor()), | 81 device_scale_factor_(GetForcedDeviceScaleFactor()), |
82 rotation_(ROTATE_0) { | 82 rotation_(ROTATE_0) { |
83 #if defined(USE_AURA) | 83 #if defined(USE_AURA) || defined(ENABLE_HIDPI) |
84 SetScaleAndBounds(device_scale_factor_, bounds); | 84 SetScaleAndBounds(device_scale_factor_, bounds); |
85 #endif | 85 #endif |
86 } | 86 } |
87 | 87 |
88 Display::~Display() { | 88 Display::~Display() { |
89 } | 89 } |
90 | 90 |
91 Insets Display::GetWorkAreaInsets() const { | 91 Insets Display::GetWorkAreaInsets() const { |
92 return gfx::Insets(work_area_.y() - bounds_.y(), | 92 return gfx::Insets(work_area_.y() - bounds_.y(), |
93 work_area_.x() - bounds_.x(), | 93 work_area_.x() - bounds_.x(), |
(...skipping 17 matching lines...) Expand all Loading... |
111 bounds_ = gfx::Rect( | 111 bounds_ = gfx::Rect( |
112 gfx::ToFlooredPoint(gfx::ScalePoint(bounds_in_pixel.origin(), | 112 gfx::ToFlooredPoint(gfx::ScalePoint(bounds_in_pixel.origin(), |
113 1.0f / device_scale_factor_)), | 113 1.0f / device_scale_factor_)), |
114 gfx::ToFlooredSize(gfx::ScaleSize(bounds_in_pixel.size(), | 114 gfx::ToFlooredSize(gfx::ScaleSize(bounds_in_pixel.size(), |
115 1.0f / device_scale_factor_))); | 115 1.0f / device_scale_factor_))); |
116 UpdateWorkAreaFromInsets(insets); | 116 UpdateWorkAreaFromInsets(insets); |
117 } | 117 } |
118 | 118 |
119 void Display::SetSize(const gfx::Size& size_in_pixel) { | 119 void Display::SetSize(const gfx::Size& size_in_pixel) { |
120 gfx::Point origin = bounds_.origin(); | 120 gfx::Point origin = bounds_.origin(); |
121 #if defined(USE_AURA) | 121 #if defined(USE_AURA) || defined(ENABLE_HIDPI) |
122 gfx::PointF origin_f = origin; | 122 gfx::PointF origin_f = origin; |
123 origin_f.Scale(device_scale_factor_); | 123 origin_f.Scale(device_scale_factor_); |
124 origin.SetPoint(origin_f.x(), origin_f.y()); | 124 origin.SetPoint(origin_f.x(), origin_f.y()); |
125 #endif | 125 #endif |
126 SetScaleAndBounds(device_scale_factor_, gfx::Rect(origin, size_in_pixel)); | 126 SetScaleAndBounds(device_scale_factor_, gfx::Rect(origin, size_in_pixel)); |
127 } | 127 } |
128 | 128 |
129 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { | 129 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { |
130 work_area_ = bounds_; | 130 work_area_ = bounds_; |
131 work_area_.Inset(insets); | 131 work_area_.Inset(insets); |
(...skipping 19 matching lines...) Expand all Loading... |
151 | 151 |
152 int64 Display::InternalDisplayId() { | 152 int64 Display::InternalDisplayId() { |
153 return internal_display_id_; | 153 return internal_display_id_; |
154 } | 154 } |
155 | 155 |
156 void Display::SetInternalDisplayId(int64 internal_display_id) { | 156 void Display::SetInternalDisplayId(int64 internal_display_id) { |
157 internal_display_id_ = internal_display_id; | 157 internal_display_id_ = internal_display_id; |
158 } | 158 } |
159 | 159 |
160 } // namespace gfx | 160 } // namespace gfx |
OLD | NEW |