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

Side by Side Diff: chrome/browser/ui/libgtk2ui/gtk2_ui.cc

Issue 1078423002: Allow arbitrary scale factors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow arbitrary scale factors. Created 5 years, 8 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 | « no previous file | testing/xvfb.py » ('j') | 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 "chrome/browser/ui/libgtk2ui/gtk2_ui.h" 5 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h"
6 6
7 #include <math.h>
7 #include <set> 8 #include <set>
8 9
9 #include <pango/pango.h> 10 #include <pango/pango.h>
10 11
11 #include "base/command_line.h" 12 #include "base/command_line.h"
12 #include "base/debug/leak_annotations.h" 13 #include "base/debug/leak_annotations.h"
13 #include "base/environment.h" 14 #include "base/environment.h"
14 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/nix/mime_util_xdg.h" 17 #include "base/nix/mime_util_xdg.h"
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 } 1420 }
1420 1421
1421 void Gtk2UI::UpdateDeviceScaleFactor(float device_scale_factor) { 1422 void Gtk2UI::UpdateDeviceScaleFactor(float device_scale_factor) {
1422 device_scale_factor_ = device_scale_factor; 1423 device_scale_factor_ = device_scale_factor;
1423 GtkStyle* label_style = gtk_rc_get_style(fake_label_.get()); 1424 GtkStyle* label_style = gtk_rc_get_style(fake_label_.get());
1424 UpdateDefaultFont(label_style->font_desc); 1425 UpdateDefaultFont(label_style->font_desc);
1425 } 1426 }
1426 1427
1427 float Gtk2UI::GetDeviceScaleFactor() const { 1428 float Gtk2UI::GetDeviceScaleFactor() const {
1428 const int kCSSDefaultDPI = 96; 1429 const int kCSSDefaultDPI = 96;
1429 const float scale = GetDPI() / kCSSDefaultDPI; 1430 float scale = GetDPI() / kCSSDefaultDPI;
1430 return ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(scale)); 1431 // Round to 2 decimals, e.g. to 1.33.
1432 return roundf(scale * 100) / 100;
1431 } 1433 }
1432 1434
1433 } // namespace libgtk2ui 1435 } // namespace libgtk2ui
1434 1436
1435 views::LinuxUI* BuildGtk2UI() { 1437 views::LinuxUI* BuildGtk2UI() {
1436 return new libgtk2ui::Gtk2UI; 1438 return new libgtk2ui::Gtk2UI;
1437 } 1439 }
OLDNEW
« no previous file with comments | « no previous file | testing/xvfb.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698