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

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

Issue 2617623002: Switch RenderWidgetHostViewAndroid to use Screen (Closed)
Patch Set: remove comment change Created 3 years, 11 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
« no previous file with comments | « ui/display/display.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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 #if defined(OS_ANDROID)
157 size_in_pixels_ = bounds_in_pixel.size();
158 #endif // defined(OS_ANDROID)
156 UpdateWorkAreaFromInsets(insets); 159 UpdateWorkAreaFromInsets(insets);
157 } 160 }
158 161
159 void Display::SetSize(const gfx::Size& size_in_pixel) { 162 void Display::SetSize(const gfx::Size& size_in_pixel) {
160 gfx::Point origin = bounds_.origin(); 163 gfx::Point origin = bounds_.origin();
161 #if defined(USE_AURA) 164 #if defined(USE_AURA)
162 origin = gfx::ScaleToFlooredPoint(origin, device_scale_factor_); 165 origin = gfx::ScaleToFlooredPoint(origin, device_scale_factor_);
163 #endif 166 #endif
164 SetScaleAndBounds(device_scale_factor_, gfx::Rect(origin, size_in_pixel)); 167 SetScaleAndBounds(device_scale_factor_, gfx::Rect(origin, size_in_pixel));
165 } 168 }
166 169
167 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { 170 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) {
168 work_area_ = bounds_; 171 work_area_ = bounds_;
169 work_area_.Inset(insets); 172 work_area_.Inset(insets);
170 } 173 }
171 174
172 gfx::Size Display::GetSizeInPixel() const { 175 gfx::Size Display::GetSizeInPixel() const {
176 // TODO(oshima): This should always use size_in_pixels_.
177 if (!size_in_pixels_.IsEmpty())
178 return size_in_pixels_;
173 return gfx::ScaleToFlooredSize(size(), device_scale_factor_); 179 return gfx::ScaleToFlooredSize(size(), device_scale_factor_);
174 } 180 }
175 181
176 std::string Display::ToString() const { 182 std::string Display::ToString() const {
177 return base::StringPrintf( 183 return base::StringPrintf(
178 "Display[%lld] bounds=%s, workarea=%s, scale=%g, %s", 184 "Display[%lld] bounds=%s, workarea=%s, scale=%g, %s",
179 static_cast<long long int>(id_), bounds_.ToString().c_str(), 185 static_cast<long long int>(id_), bounds_.ToString().c_str(),
180 work_area_.ToString().c_str(), device_scale_factor_, 186 work_area_.ToString().c_str(), device_scale_factor_,
181 IsInternal() ? "internal" : "external"); 187 IsInternal() ? "internal" : "external");
182 } 188 }
(...skipping 18 matching lines...) Expand all
201 DCHECK_NE(kInvalidDisplayId, display_id); 207 DCHECK_NE(kInvalidDisplayId, display_id);
202 return HasInternalDisplay() && internal_display_id_ == display_id; 208 return HasInternalDisplay() && internal_display_id_ == display_id;
203 } 209 }
204 210
205 // static 211 // static
206 bool Display::HasInternalDisplay() { 212 bool Display::HasInternalDisplay() {
207 return internal_display_id_ != kInvalidDisplayId; 213 return internal_display_id_ != kInvalidDisplayId;
208 } 214 }
209 215
210 } // namespace display 216 } // namespace display
OLDNEW
« no previous file with comments | « ui/display/display.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698