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

Unified Diff: ui/views/widget/desktop_aura/desktop_screen_x11.cc

Issue 659883002: Enable hidpi on Linux, refactor a bit on Windows to share Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: constants Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/widget/desktop_aura/desktop_screen_x11.cc
diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11.cc b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
index bb253cff17ce48e6295bbee89574a874f5733462..d5b1f52da25e4b850ea9dfe1c76420325fe15eec 100644
--- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
@@ -20,6 +20,7 @@
#include "ui/display/util/x11/edid_parser_x11.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/display.h"
+#include "ui/gfx/dpi.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/screen.h"
#include "ui/gfx/x/x11_types.h"
@@ -33,18 +34,6 @@ namespace {
// in |Dispatch()|.
const int64 kConfigureDelayMs = 500;
-// TODO(oshima): Consider using gtk-xft-dpi instead.
-float GetDeviceScaleFactor(int screen_pixels, int screen_mm) {
- const int kCSSDefaultDPI = 96;
- const float kInchInMm = 25.4f;
-
- float screen_inches = screen_mm / kInchInMm;
- float screen_dpi = screen_pixels / screen_inches;
- float scale = screen_dpi / kCSSDefaultDPI;
-
- return ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(scale));
-}
-
std::vector<gfx::Display> GetFallbackDisplayList() {
::XDisplay* display = gfx::GetXDisplay();
::Screen* screen = DefaultScreenOfDisplay(display);
@@ -56,8 +45,7 @@ std::vector<gfx::Display> GetFallbackDisplayList() {
gfx::Display gfx_display(0, bounds_in_pixels);
if (!gfx::Display::HasForceDeviceScaleFactor() &&
!ui::IsDisplaySizeBlackListed(physical_size)) {
- float device_scale_factor = GetDeviceScaleFactor(
- width, physical_size.width());
+ float device_scale_factor = gfx::GetDeviceScaleFactor();
DCHECK_LE(1.0f, device_scale_factor);
gfx_display.SetScaleAndBounds(device_scale_factor, bounds_in_pixels);
}
@@ -279,7 +267,7 @@ std::vector<gfx::Display> DesktopScreenX11::BuildDisplaysFromXRandRInfo() {
has_work_area = true;
}
- float device_scale_factor = 1.0f;
+ float device_scale_factor = gfx::GetDeviceScaleFactor();
for (int i = 0; i < resources->noutput; ++i) {
RROutput output_id = resources->outputs[i];
XRROutputInfo* output_info =
@@ -306,17 +294,8 @@ std::vector<gfx::Display> DesktopScreenX11::BuildDisplaysFromXRandRInfo() {
gfx::Rect crtc_bounds(crtc->x, crtc->y, crtc->width, crtc->height);
gfx::Display display(display_id, crtc_bounds);
- if (!gfx::Display::HasForceDeviceScaleFactor()) {
- if (i == 0 && !ui::IsDisplaySizeBlackListed(
- gfx::Size(output_info->mm_width, output_info->mm_height))) {
- // As per display scale factor is not supported right now,
- // the primary display's scale factor is always used.
- device_scale_factor = GetDeviceScaleFactor(crtc->width,
- output_info->mm_width);
- DCHECK_LE(1.0f, device_scale_factor);
- }
+ if (!gfx::Display::HasForceDeviceScaleFactor())
display.SetScaleAndBounds(device_scale_factor, crtc_bounds);
- }
if (has_work_area) {
gfx::Rect intersection = crtc_bounds;

Powered by Google App Engine
This is Rietveld 408576698