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

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: updated comment 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
« no previous file with comments | « ui/gfx/monitor.h ('k') | ui/gfx/screen.h » ('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..ea342c564d7c53a8596d7f228dd79629ee36e942 100644
--- a/ui/gfx/monitor.cc
+++ b/ui/gfx/monitor.cc
@@ -4,22 +4,52 @@
#include "ui/gfx/monitor.h"
-#include "ui/gfx/insets.h"
+#include "base/command_line.h"
+#include "base/logging.h"
+#include "base/string_number_conversions.h"
#include "base/stringprintf.h"
+#include "ui/base/ui_base_switches.h"
+#include "ui/gfx/insets.h"
namespace gfx {
+namespace {
+
+float GetDefaultDeviceScaleFactorImpl() {
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ double scale_in_double = 1.0;
+ if (command_line.HasSwitch(switches::kDefaultDeviceScaleFactor)) {
+ std::string value =
+ command_line.GetSwitchValueASCII(switches::kDefaultDeviceScaleFactor);
+ if (!base::StringToDouble(value, &scale_in_double))
+ LOG(ERROR) << "Failed to parse the deafult device scale factor:" << value;
+ }
+ return static_cast<float>(scale_in_double);
+}
-Monitor::Monitor() : id_(-1), device_scale_factor_(1.0) {
+} // namespace
+
+// static
+float Monitor::GetDefaultDeviceScaleFactor() {
+ static const float kDefaultDeviceScaleFactor =
+ GetDefaultDeviceScaleFactorImpl();
+ return kDefaultDeviceScaleFactor;
+}
+
+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
« no previous file with comments | « ui/gfx/monitor.h ('k') | ui/gfx/screen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698