Chromium Code Reviews| 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/display/display.h" | 5 #include "ui/display/display.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 // scale is integral. | 146 // scale is integral. |
| 147 device_scale_factor = static_cast<int>(device_scale_factor); | 147 device_scale_factor = static_cast<int>(device_scale_factor); |
| 148 #endif | 148 #endif |
| 149 device_scale_factor_ = device_scale_factor; | 149 device_scale_factor_ = device_scale_factor; |
| 150 } | 150 } |
| 151 device_scale_factor_ = std::max(1.0f, device_scale_factor_); | 151 device_scale_factor_ = std::max(1.0f, device_scale_factor_); |
| 152 bounds_ = gfx::Rect(gfx::ScaleToFlooredPoint(bounds_in_pixel.origin(), | 152 bounds_ = gfx::Rect(gfx::ScaleToFlooredPoint(bounds_in_pixel.origin(), |
| 153 1.0f / device_scale_factor_), | 153 1.0f / device_scale_factor_), |
| 154 gfx::ScaleToFlooredSize(bounds_in_pixel.size(), | 154 gfx::ScaleToFlooredSize(bounds_in_pixel.size(), |
| 155 1.0f / device_scale_factor_)); | 155 1.0f / device_scale_factor_)); |
| 156 size_in_pixels_ = bounds_in_pixel.size(); | |
|
oshima
2017/01/06 19:31:23
Would you mind adding ifdef android for now?
I do
boliu
2017/01/06 20:26:21
Done. Also marked the setter android-only to avoid
| |
| 156 UpdateWorkAreaFromInsets(insets); | 157 UpdateWorkAreaFromInsets(insets); |
| 157 } | 158 } |
| 158 | 159 |
| 159 void Display::SetSize(const gfx::Size& size_in_pixel) { | 160 void Display::SetSize(const gfx::Size& size_in_pixel) { |
| 160 gfx::Point origin = bounds_.origin(); | 161 gfx::Point origin = bounds_.origin(); |
| 161 #if defined(USE_AURA) | 162 #if defined(USE_AURA) |
| 162 origin = gfx::ScaleToFlooredPoint(origin, device_scale_factor_); | 163 origin = gfx::ScaleToFlooredPoint(origin, device_scale_factor_); |
| 163 #endif | 164 #endif |
| 164 SetScaleAndBounds(device_scale_factor_, gfx::Rect(origin, size_in_pixel)); | 165 SetScaleAndBounds(device_scale_factor_, gfx::Rect(origin, size_in_pixel)); |
| 165 } | 166 } |
| 166 | 167 |
| 167 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { | 168 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { |
| 168 work_area_ = bounds_; | 169 work_area_ = bounds_; |
| 169 work_area_.Inset(insets); | 170 work_area_.Inset(insets); |
| 170 } | 171 } |
| 171 | 172 |
| 172 gfx::Size Display::GetSizeInPixel() const { | 173 gfx::Size Display::GetSizeInPixel() const { |
| 174 if (!size_in_pixels_.IsEmpty()) | |
| 175 return size_in_pixels_; | |
|
oshima
2017/01/06 19:31:23
can you add this
// TODO(oshima): this should alw
boliu
2017/01/06 20:26:21
Done.
| |
| 173 return gfx::ScaleToFlooredSize(size(), device_scale_factor_); | 176 return gfx::ScaleToFlooredSize(size(), device_scale_factor_); |
| 174 } | 177 } |
| 175 | 178 |
| 176 std::string Display::ToString() const { | 179 std::string Display::ToString() const { |
| 177 return base::StringPrintf( | 180 return base::StringPrintf( |
| 178 "Display[%lld] bounds=%s, workarea=%s, scale=%g, %s", | 181 "Display[%lld] bounds=%s, workarea=%s, scale=%g, %s", |
| 179 static_cast<long long int>(id_), bounds_.ToString().c_str(), | 182 static_cast<long long int>(id_), bounds_.ToString().c_str(), |
| 180 work_area_.ToString().c_str(), device_scale_factor_, | 183 work_area_.ToString().c_str(), device_scale_factor_, |
| 181 IsInternal() ? "internal" : "external"); | 184 IsInternal() ? "internal" : "external"); |
| 182 } | 185 } |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 201 DCHECK_NE(kInvalidDisplayId, display_id); | 204 DCHECK_NE(kInvalidDisplayId, display_id); |
| 202 return HasInternalDisplay() && internal_display_id_ == display_id; | 205 return HasInternalDisplay() && internal_display_id_ == display_id; |
| 203 } | 206 } |
| 204 | 207 |
| 205 // static | 208 // static |
| 206 bool Display::HasInternalDisplay() { | 209 bool Display::HasInternalDisplay() { |
| 207 return internal_display_id_ != kInvalidDisplayId; | 210 return internal_display_id_ != kInvalidDisplayId; |
| 208 } | 211 } |
| 209 | 212 |
| 210 } // namespace display | 213 } // namespace display |
| OLD | NEW |