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

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

Issue 11348033: Initialize device scale factor correctly on Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Hook up WebScreenInfo.deviceScaleFactor Created 8 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 | Annotate | Revision Log
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 "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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 return gfx::Insets(work_area_.y() - bounds_.y(), 76 return gfx::Insets(work_area_.y() - bounds_.y(),
77 work_area_.x() - bounds_.x(), 77 work_area_.x() - bounds_.x(),
78 bounds_.bottom() - work_area_.bottom(), 78 bounds_.bottom() - work_area_.bottom(),
79 bounds_.right() - work_area_.right()); 79 bounds_.right() - work_area_.right());
80 } 80 }
81 81
82 void Display::SetScaleAndBounds( 82 void Display::SetScaleAndBounds(
83 float device_scale_factor, 83 float device_scale_factor,
84 const gfx::Rect& bounds_in_pixel) { 84 const gfx::Rect& bounds_in_pixel) {
85 Insets insets = bounds_.InsetsFrom(work_area_); 85 Insets insets = bounds_.InsetsFrom(work_area_);
86 if (!HasForceDeviceScaleFactor()) 86 if (!HasForceDeviceScaleFactor()) {
87 #if defined(OS_CHROMEOS) || defined(OS_MACOSX)
88 // Unless an explicit scale factor was provided for testing, ensure the
89 // scale is integral.
90 device_scale_factor = static_cast<int>(device_scale_factor);
91 #endif
87 device_scale_factor_ = device_scale_factor; 92 device_scale_factor_ = device_scale_factor;
93 }
94 device_scale_factor_ = std::max(1.0f, device_scale_factor_);
oshima 2012/11/14 16:52:35 Is this necessary for android? I most likely elimi
johnme 2012/11/14 16:56:45 There should never be any harm in using this safeg
88 #if defined(USE_AURA) 95 #if defined(USE_AURA)
89 bounds_in_pixel_ = bounds_in_pixel; 96 bounds_in_pixel_ = bounds_in_pixel;
90 #endif 97 #endif
91 bounds_ = gfx::Rect(gfx::ToFlooredSize( 98 bounds_ = gfx::Rect(gfx::ToFlooredSize(
92 bounds_in_pixel.size().Scale(1.0f / device_scale_factor_))); 99 bounds_in_pixel.size().Scale(1.0f / device_scale_factor_)));
93 UpdateWorkAreaFromInsets(insets); 100 UpdateWorkAreaFromInsets(insets);
94 } 101 }
95 102
96 void Display::SetSize(const gfx::Size& size_in_pixel) { 103 void Display::SetSize(const gfx::Size& size_in_pixel) {
97 SetScaleAndBounds( 104 SetScaleAndBounds(
(...skipping 16 matching lines...) Expand all
114 121
115 std::string Display::ToString() const { 122 std::string Display::ToString() const {
116 return base::StringPrintf("Display[%lld] bounds=%s, workarea=%s, scale=%f", 123 return base::StringPrintf("Display[%lld] bounds=%s, workarea=%s, scale=%f",
117 static_cast<long long int>(id_), 124 static_cast<long long int>(id_),
118 bounds_.ToString().c_str(), 125 bounds_.ToString().c_str(),
119 work_area_.ToString().c_str(), 126 work_area_.ToString().c_str(),
120 device_scale_factor_); 127 device_scale_factor_);
121 } 128 }
122 129
123 } // namespace gfx 130 } // namespace gfx
OLDNEW
« content/renderer/render_widget.cc ('K') | « content/renderer/render_widget.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698