Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: ui/gfx/display.cc

Issue 1426933002: Refactor Windows DPI Point, Rect, and Size for Multiple Monitor DPI Awareness (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 Insets insets = bounds_.InsetsFrom(work_area_); 152 Insets insets = bounds_.InsetsFrom(work_area_);
153 if (!HasForceDeviceScaleFactor()) { 153 if (!HasForceDeviceScaleFactor()) {
154 #if defined(OS_MACOSX) 154 #if defined(OS_MACOSX)
155 // Unless an explicit scale factor was provided for testing, ensure the 155 // Unless an explicit scale factor was provided for testing, ensure the
156 // scale is integral. 156 // scale is integral.
157 device_scale_factor = static_cast<int>(device_scale_factor); 157 device_scale_factor = static_cast<int>(device_scale_factor);
158 #endif 158 #endif
159 device_scale_factor_ = device_scale_factor; 159 device_scale_factor_ = device_scale_factor;
160 } 160 }
161 device_scale_factor_ = std::max(1.0f, device_scale_factor_); 161 device_scale_factor_ = std::max(1.0f, device_scale_factor_);
162 bounds_ = gfx::Rect(gfx::ScaleToFlooredPoint(bounds_in_pixel.origin(), 162 bounds_ =
163 1.0f / device_scale_factor_), 163 #if defined(OS_WIN)
164 gfx::ScaleToFlooredSize(bounds_in_pixel.size(), 164 // Origins are fixed in Windows in both Screen and DIP.
165 1.0f / device_scale_factor_)); 165 gfx::Rect(bounds_in_pixel.origin(),
166 gfx::ScaleToFlooredSize(bounds_in_pixel.size(),
167 1.0f / device_scale_factor_));
168 #else
169 gfx::Rect(gfx::ScaleToFlooredPoint(bounds_in_pixel.origin(),
170 1.0f / device_scale_factor_),
171 gfx::ScaleToFlooredSize(bounds_in_pixel.size(),
172 1.0f / device_scale_factor_));
173 #endif // defined(OS_WIN)
166 UpdateWorkAreaFromInsets(insets); 174 UpdateWorkAreaFromInsets(insets);
167 } 175 }
168 176
169 void Display::SetSize(const gfx::Size& size_in_pixel) { 177 void Display::SetSize(const gfx::Size& size_in_pixel) {
170 gfx::Point origin = bounds_.origin(); 178 gfx::Point origin = bounds_.origin();
171 #if defined(USE_AURA) 179 #if defined(USE_AURA)
172 origin = gfx::ScaleToFlooredPoint(origin, device_scale_factor_); 180 origin = gfx::ScaleToFlooredPoint(origin, device_scale_factor_);
173 #endif 181 #endif
174 SetScaleAndBounds(device_scale_factor_, gfx::Rect(origin, size_in_pixel)); 182 SetScaleAndBounds(device_scale_factor_, gfx::Rect(origin, size_in_pixel));
175 } 183 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 DCHECK_NE(kInvalidDisplayID, display_id); 221 DCHECK_NE(kInvalidDisplayID, display_id);
214 return HasInternalDisplay() && internal_display_id_ == display_id; 222 return HasInternalDisplay() && internal_display_id_ == display_id;
215 } 223 }
216 224
217 // static 225 // static
218 bool Display::HasInternalDisplay() { 226 bool Display::HasInternalDisplay() {
219 return internal_display_id_ != kInvalidDisplayID; 227 return internal_display_id_ != kInvalidDisplayID;
220 } 228 }
221 229
222 } // namespace gfx 230 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698