Skip to content

Commit

Permalink
Allow arbitrary scale factors.
Browse files Browse the repository at this point in the history
As discussed in https://codereview.chromium.org/1070433002/, this CL
allows arbitrary scale factors, which works because chromium uses the
resource most closely matching the scale factor (e.g. 1x for 1.25x,
but 2x for 1.9x) and scales it.

BUG=143619

Review URL: https://codereview.chromium.org/1078423002

Cr-Commit-Position: refs/heads/master@{#326851}
  • Loading branch information
stapelberg authored and Commit bot committed Apr 24, 2015
1 parent ccbe99a commit b3ca230
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions chrome/browser/ui/libgtk2ui/gtk2_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "chrome/browser/ui/libgtk2ui/gtk2_ui.h"

#include <math.h>
#include <set>

#include <pango/pango.h>
Expand Down Expand Up @@ -1427,8 +1428,9 @@ void Gtk2UI::UpdateDeviceScaleFactor(float device_scale_factor) {

float Gtk2UI::GetDeviceScaleFactor() const {
const int kCSSDefaultDPI = 96;
const float scale = GetDPI() / kCSSDefaultDPI;
return ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(scale));
float scale = GetDPI() / kCSSDefaultDPI;
// Round to 2 decimals, e.g. to 1.33.
return roundf(scale * 100) / 100;
}

} // namespace libgtk2ui
Expand Down
2 changes: 1 addition & 1 deletion testing/xvfb.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def start_xvfb(xvfb_path, display):
xvfb_path: Path to Xvfb.
"""
cmd = [xvfb_path, display, '-screen', '0', '1024x768x24', '-ac',
'-nolisten', 'tcp']
'-nolisten', 'tcp', '-dpi', '96']
try:
proc = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
Expand Down

0 comments on commit b3ca230

Please sign in to comment.