diff options
author | oshima <oshima@chromium.org> | 2015-05-15 15:16:07 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-15 22:17:10 +0000 |
commit | 5cb0c01e4233ff3eb1e7f6f677b4cf9dae9ffaf2 (patch) | |
tree | 77294dd8097a51267560992d69fba0382fca1341 | |
parent | 25f30bbb3c9f6230d86ec37f0eb4e75490208f29 (diff) | |
download | chromium_src-5cb0c01e4233ff3eb1e7f6f677b4cf9dae9ffaf2.zip chromium_src-5cb0c01e4233ff3eb1e7f6f677b4cf9dae9ffaf2.tar.gz chromium_src-5cb0c01e4233ff3eb1e7f6f677b4cf9dae9ffaf2.tar.bz2 |
Compute the base dpi from X
X uses 96 as default, and alters the screen size
but it can be overwritten. Compute the dpi from X
to match what gtk sues as base.
Round the dsf to 1 decimals as finer grained value can cause rendering problem than benefit.
Gpu test expectation on nvidia needs to be updated, so mark these tests as failing now.
BUG=485183
Review URL: https://codereview.chromium.org/1136913005
Cr-Commit-Position: refs/heads/master@{#330212}
-rw-r--r-- | chrome/browser/ui/libgtk2ui/gtk2_ui.cc | 22 | ||||
-rw-r--r-- | content/test/gpu/gpu_tests/pixel_expectations.py | 4 | ||||
-rw-r--r-- | content/test/gpu/page_sets/pixel_tests.py | 6 |
3 files changed, 21 insertions, 11 deletions
diff --git a/chrome/browser/ui/libgtk2ui/gtk2_ui.cc b/chrome/browser/ui/libgtk2ui/gtk2_ui.cc index 1925e13..29d8e1c 100644 --- a/chrome/browser/ui/libgtk2ui/gtk2_ui.cc +++ b/chrome/browser/ui/libgtk2ui/gtk2_ui.cc @@ -8,6 +8,7 @@ #include <set> #include <pango/pango.h> +#include <X11/Xlib.h> #include "base/command_line.h" #include "base/debug/leak_annotations.h" @@ -49,6 +50,7 @@ #include "ui/gfx/image/image.h" #include "ui/gfx/skbitmap_operations.h" #include "ui/gfx/skia_util.h" +#include "ui/gfx/x/x11_types.h" #include "ui/resources/grit/ui_resources.h" #include "ui/views/controls/button/label_button.h" #include "ui/views/controls/button/label_button_border.h" @@ -378,20 +380,27 @@ gfx::FontRenderParams GetGtkFontRenderParams() { return params; } -double GetDPI() { +double GetBaseDPI() { + XDisplay* xdisplay = gfx::GetXDisplay(); + int xscreen = DefaultScreen(xdisplay); + return (DisplayHeight(xdisplay, xscreen) * 25.4) / + DisplayHeightMM(xdisplay, xscreen); +} + +double GetFontDPI() { GtkSettings* gtk_settings = gtk_settings_get_default(); CHECK(gtk_settings); gint gtk_dpi = -1; g_object_get(gtk_settings, "gtk-xft-dpi", >k_dpi, NULL); // GTK multiplies the DPI by 1024 before storing it. - return (gtk_dpi > 0) ? gtk_dpi / 1024.0 : 96.0; + return (gtk_dpi > 0) ? gtk_dpi / 1024.0 : GetBaseDPI(); } // Queries GTK for its font DPI setting and returns the number of pixels in a // point. double GetPixelsInPoint(float device_scale_factor) { - double dpi = GetDPI(); + double dpi = GetFontDPI(); // Take device_scale_factor into account — if Chrome already scales the // entire UI up by 2x, we should not also scale up. @@ -1424,10 +1433,9 @@ void Gtk2UI::UpdateDeviceScaleFactor(float device_scale_factor) { } float Gtk2UI::GetDeviceScaleFactor() const { - const int kCSSDefaultDPI = 96; - float scale = GetDPI() / kCSSDefaultDPI; - // Round to 2 decimals, e.g. to 1.33. - return roundf(scale * 100) / 100; + float scale = GetFontDPI() / GetBaseDPI(); + // Round to 1 decimal, e.g. to 1.4. + return roundf(scale * 10) / 10; } } // namespace libgtk2ui diff --git a/content/test/gpu/gpu_tests/pixel_expectations.py b/content/test/gpu/gpu_tests/pixel_expectations.py index a8b1dda..0ef5d92 100644 --- a/content/test/gpu/gpu_tests/pixel_expectations.py +++ b/content/test/gpu/gpu_tests/pixel_expectations.py @@ -11,4 +11,6 @@ class PixelExpectations(GpuTestExpectations): # Sample Usage: # self.Fail('Pixel.Canvas2DRedBox', # ['mac', 'amd', ('nvidia', 0x1234)], bug=123) - pass + self.Fail('Pixel.Canvas2DRedBox', bug=485183) + self.Fail('Pixel.CSS3DBlueBox', bug=485183) + self.Fail('Pixel.WebGLGreenTriangle', bug=485183) diff --git a/content/test/gpu/page_sets/pixel_tests.py b/content/test/gpu/page_sets/pixel_tests.py index e747d3c..877311d 100644 --- a/content/test/gpu/page_sets/pixel_tests.py +++ b/content/test/gpu/page_sets/pixel_tests.py @@ -30,19 +30,19 @@ class PixelTestsPageSet(page_set_module.PageSet): url='file://../../data/gpu/pixel_canvas2d.html', name=base_name + '.Canvas2DRedBox', test_rect=[0, 0, 300, 300], - revision=4, + revision=5, page_set=self)) self.AddUserStory(PixelTestsPage( url='file://../../data/gpu/pixel_css3d.html', name=base_name + '.CSS3DBlueBox', test_rect=[0, 0, 300, 300], - revision=12, + revision=13, page_set=self)) self.AddUserStory(PixelTestsPage( url='file://../../data/gpu/pixel_webgl.html', name=base_name + '.WebGLGreenTriangle', test_rect=[0, 0, 300, 300], - revision=9, + revision=10, page_set=self)) |