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

Unified Diff: ui/gfx/monitor.cc

Issue 10255020: Get the default device scale factor from monitor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added missing file (gfx_switches) Created 8 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 side-by-side diff with in-line comments
Download patch
« ui/gfx/gfx_switches.h ('K') | « ui/gfx/monitor.h ('k') | ui/ui.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/monitor.cc
diff --git a/ui/gfx/monitor.cc b/ui/gfx/monitor.cc
index 242abced7e2eb00fae2f4854eb3e2ba2d8a30371..d87d9dc1defe534a67fe20b3d13ee3120e20cbd6 100644
--- a/ui/gfx/monitor.cc
+++ b/ui/gfx/monitor.cc
@@ -4,22 +4,51 @@
#include "ui/gfx/monitor.h"
-#include "ui/gfx/insets.h"
+#include "base/command_line.h"
+#include "base/string_number_conversions.h"
#include "base/stringprintf.h"
+#include "ui/gfx/gfx_switches.h"
+#include "ui/gfx/insets.h"
namespace gfx {
+namespace {
+
+float GetDefaultDeviceScaleFactorImpl() {
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(switches::kDefaultDeviceScaleFactor)) {
+ double scale_in_double;
+ base::StringToDouble(
sadrul 2012/04/30 18:57:00 Check the return value of StringToDouble?
oshima 2012/04/30 19:41:14 Done.
+ command_line.GetSwitchValueASCII(switches::kDefaultDeviceScaleFactor),
+ &scale_in_double);
+ return static_cast<float>(scale_in_double);
+ }
+ return 1.0f;
+}
-Monitor::Monitor() : id_(-1), device_scale_factor_(1.0) {
+} // namespace
+
+// static
+float Monitor::GetDefaultDeviceScaleFactor() {
+ static float default_device_scale_factor =
+ GetDefaultDeviceScaleFactorImpl();
+ return default_device_scale_factor;
+}
+
+Monitor::Monitor()
+ : id_(-1),
+ device_scale_factor_(GetDefaultDeviceScaleFactor()) {
}
-Monitor::Monitor(int id) : id_(id), device_scale_factor_(1.0) {
+Monitor::Monitor(int id)
+ : id_(id),
+ device_scale_factor_(GetDefaultDeviceScaleFactor()) {
}
Monitor::Monitor(int id, const gfx::Rect& bounds)
: id_(id),
bounds_(bounds),
work_area_(bounds),
- device_scale_factor_(1.0) {
+ device_scale_factor_(GetDefaultDeviceScaleFactor()) {
#if defined(USE_ASH)
SetScaleAndBounds(device_scale_factor_, bounds);
#endif
« ui/gfx/gfx_switches.h ('K') | « ui/gfx/monitor.h ('k') | ui/ui.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698