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 "chrome/browser/ui/libgtk2ui/gtk2_ui.h" | 5 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <pango/pango.h> | 8 #include <pango/pango.h> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1345 void Gtk2UI::UpdateDeviceScaleFactor(float device_scale_factor) { | 1345 void Gtk2UI::UpdateDeviceScaleFactor(float device_scale_factor) { |
1346 device_scale_factor_ = device_scale_factor; | 1346 device_scale_factor_ = device_scale_factor; |
1347 UpdateDefaultFont(); | 1347 UpdateDefaultFont(); |
1348 } | 1348 } |
1349 | 1349 |
1350 float Gtk2UI::GetDeviceScaleFactor() const { | 1350 float Gtk2UI::GetDeviceScaleFactor() const { |
1351 if (gfx::Display::HasForceDeviceScaleFactor()) | 1351 if (gfx::Display::HasForceDeviceScaleFactor()) |
1352 return gfx::Display::GetForcedDeviceScaleFactor(); | 1352 return gfx::Display::GetForcedDeviceScaleFactor(); |
1353 const int kCSSDefaultDPI = 96; | 1353 const int kCSSDefaultDPI = 96; |
1354 const float scale = GetDPI() / kCSSDefaultDPI; | 1354 const float scale = GetDPI() / kCSSDefaultDPI; |
1355 // Round to 1 decimal, e.g. to 1.4. | 1355 |
1356 const float rounded = roundf(scale * 10) / 10; | 1356 // Blacklist scaling factors <130% (crbug.com/484400) and round |
1357 // See crbug.com/484400 | 1357 // to 1 decimal to prevent rendering problems (crbug.com/485183). |
1358 return rounded < 1.3 ? 1.0 : rounded; | 1358 return scale < 1.3f ? 1.0f : roundf(scale * 10) / 10; |
1359 } | 1359 } |
1360 | 1360 |
1361 } // namespace libgtk2ui | 1361 } // namespace libgtk2ui |
1362 | 1362 |
1363 views::LinuxUI* BuildGtk2UI() { | 1363 views::LinuxUI* BuildGtk2UI() { |
1364 return new libgtk2ui::Gtk2UI; | 1364 return new libgtk2ui::Gtk2UI; |
1365 } | 1365 } |
OLD | NEW |