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

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

Issue 1417023002: Remove some implicit Point to PointF conversions, add helpers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-views: extrachange Created 5 years, 2 months 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_ = 162 bounds_ = gfx::Rect(gfx::ScaleToFlooredPoint(bounds_in_pixel.origin(),
163 gfx::Rect(gfx::ToFlooredPoint(gfx::ScalePoint( 163 1.0f / device_scale_factor_),
164 bounds_in_pixel.origin(), 1.0f / device_scale_factor_)), 164 gfx::ScaleToFlooredSize(bounds_in_pixel.size(),
165 gfx::ScaleToFlooredSize(bounds_in_pixel.size(), 165 1.0f / device_scale_factor_));
166 1.0f / device_scale_factor_));
167 UpdateWorkAreaFromInsets(insets); 166 UpdateWorkAreaFromInsets(insets);
168 } 167 }
169 168
170 void Display::SetSize(const gfx::Size& size_in_pixel) { 169 void Display::SetSize(const gfx::Size& size_in_pixel) {
171 gfx::Point origin = bounds_.origin(); 170 gfx::Point origin = bounds_.origin();
172 #if defined(USE_AURA) 171 #if defined(USE_AURA)
173 gfx::PointF origin_f = origin; 172 origin = gfx::ScaleToFlooredPoint(origin, device_scale_factor_);
174 origin_f.Scale(device_scale_factor_);
175 origin = gfx::ToFlooredPoint(origin_f);
176 #endif 173 #endif
177 SetScaleAndBounds(device_scale_factor_, gfx::Rect(origin, size_in_pixel)); 174 SetScaleAndBounds(device_scale_factor_, gfx::Rect(origin, size_in_pixel));
178 } 175 }
179 176
180 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { 177 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) {
181 work_area_ = bounds_; 178 work_area_ = bounds_;
182 work_area_.Inset(insets); 179 work_area_.Inset(insets);
183 } 180 }
184 181
185 gfx::Size Display::GetSizeInPixel() const { 182 gfx::Size Display::GetSizeInPixel() const {
(...skipping 30 matching lines...) Expand all
216 DCHECK_NE(kInvalidDisplayID, display_id); 213 DCHECK_NE(kInvalidDisplayID, display_id);
217 return HasInternalDisplay() && internal_display_id_ == display_id; 214 return HasInternalDisplay() && internal_display_id_ == display_id;
218 } 215 }
219 216
220 // static 217 // static
221 bool Display::HasInternalDisplay() { 218 bool Display::HasInternalDisplay() {
222 return internal_display_id_ != kInvalidDisplayID; 219 return internal_display_id_ != kInvalidDisplayID;
223 } 220 }
224 221
225 } // namespace gfx 222 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/base/x/x11_util.cc ('k') | ui/gfx/geometry/dip_util.cc » ('j') | ui/gfx/geometry/point.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698