diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-10 19:50:24 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-10 19:50:24 +0000 |
commit | 4aeeedd6e49eb33bb709ad1eba6470ff56a539ed (patch) | |
tree | d94752f5c2115b736c241017b78ba17d21074b36 /ui | |
parent | 676c15a624d2301e7cde0c85dba3139b39975d08 (diff) | |
download | chromium_src-4aeeedd6e49eb33bb709ad1eba6470ff56a539ed.zip chromium_src-4aeeedd6e49eb33bb709ad1eba6470ff56a539ed.tar.gz chromium_src-4aeeedd6e49eb33bb709ad1eba6470ff56a539ed.tar.bz2 |
Add device scale factor to Monitor
BUG=111990
TEST=none
Review URL: https://chromiumcodereview.appspot.com/9967029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131609 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/monitor.cc | 2 | ||||
-rw-r--r-- | ui/aura/monitor.h | 11 | ||||
-rw-r--r-- | ui/aura/monitor_manager.cc | 9 |
3 files changed, 18 insertions, 4 deletions
diff --git a/ui/aura/monitor.cc b/ui/aura/monitor.cc index d410a1a..52d64f0 100644 --- a/ui/aura/monitor.cc +++ b/ui/aura/monitor.cc @@ -6,7 +6,7 @@ namespace aura { -Monitor::Monitor() { +Monitor::Monitor() : device_scale_factor_(1.0f) { } Monitor::~Monitor() { diff --git a/ui/aura/monitor.h b/ui/aura/monitor.h index 5f04188..496263e 100644 --- a/ui/aura/monitor.h +++ b/ui/aura/monitor.h @@ -33,6 +33,15 @@ class AURA_EXPORT Monitor { } const gfx::Insets& work_area_insets() const { return work_area_insets_; } + // Output device's pixel scale factor. This specifies how much the + // UI should be scaled when the actual output has more pixels than + // standard monitors (which is around 100~120dpi.) For aura, this + // value is either 1.0 or 2.0, but may return different values on + // other platforms. + float GetDeviceScaleFactor() const { + return device_scale_factor_; + } + // Returns the monitor's work area. gfx::Rect GetWorkAreaBounds() const; @@ -42,6 +51,8 @@ class AURA_EXPORT Monitor { gfx::Rect bounds_; + float device_scale_factor_; + DISALLOW_COPY_AND_ASSIGN(Monitor); }; diff --git a/ui/aura/monitor_manager.cc b/ui/aura/monitor_manager.cc index ee0bf52..de23f58 100644 --- a/ui/aura/monitor_manager.cc +++ b/ui/aura/monitor_manager.cc @@ -6,6 +6,7 @@ #include <stdio.h> +#include "base/logging.h" #include "ui/aura/env.h" #include "ui/aura/monitor.h" #include "ui/aura/root_window.h" @@ -29,16 +30,18 @@ Monitor* MonitorManager::CreateMonitorFromSpec(const std::string& spec) { gfx::Rect bounds(kDefaultHostWindowX, kDefaultHostWindowY, kDefaultHostWindowWidth, kDefaultHostWindowHeight); int x = 0, y = 0, width, height; - if (sscanf(spec.c_str(), "%dx%d", &width, &height) == 2) { + float scale = 1.0f; + if (sscanf(spec.c_str(), "%dx%d*%f", &width, &height, &scale) >= 2) { bounds.set_size(gfx::Size(width, height)); - } else if (sscanf(spec.c_str(), "%d+%d-%dx%d", &x, &y, &width, &height) - == 4) { + } else if (sscanf(spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height, + &scale) >= 4 ) { bounds = gfx::Rect(x, y, width, height); } else if (use_fullscreen_host_window_) { bounds = gfx::Rect(aura::RootWindowHost::GetNativeScreenSize()); } Monitor* monitor = new Monitor(); monitor->set_bounds(bounds); + VLOG(1) << "Monitor bounds=" << bounds.ToString() << ", scale=" << scale; return monitor; } |