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

Side by Side Diff: ui/gfx/display.cc

Issue 12398019: Set the scale factor for the display on Windows when in high-DPI mode. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix bounds. Created 7 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/gfx/screen_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/display.h" 5 #include "ui/gfx/display.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
11 #include "ui/base/ui_base_switches.h" 11 #include "ui/base/ui_base_switches.h"
12 #include "ui/base/win/dpi.h"
13 #include "ui/gfx/insets.h" 12 #include "ui/gfx/insets.h"
14 #include "ui/gfx/point_f.h" 13 #include "ui/gfx/point_f.h"
15 #include "ui/gfx/size_conversions.h" 14 #include "ui/gfx/size_conversions.h"
16 15
17 namespace gfx { 16 namespace gfx {
18 namespace { 17 namespace {
19 18
20 bool HasForceDeviceScaleFactorImpl() { 19 bool HasForceDeviceScaleFactorImpl() {
21 return CommandLine::ForCurrentProcess()->HasSwitch( 20 return CommandLine::ForCurrentProcess()->HasSwitch(
22 switches::kForceDeviceScaleFactor); 21 switches::kForceDeviceScaleFactor);
23 } 22 }
24 23
25 float GetForcedDeviceScaleFactorImpl() { 24 float GetForcedDeviceScaleFactorImpl() {
26 double scale_in_double = 1.0; 25 double scale_in_double = 1.0;
27 if (HasForceDeviceScaleFactorImpl()) { 26 if (HasForceDeviceScaleFactorImpl()) {
28 std::string value = CommandLine::ForCurrentProcess()-> 27 std::string value = CommandLine::ForCurrentProcess()->
29 GetSwitchValueASCII(switches::kForceDeviceScaleFactor); 28 GetSwitchValueASCII(switches::kForceDeviceScaleFactor);
30 if (!base::StringToDouble(value, &scale_in_double)) 29 if (!base::StringToDouble(value, &scale_in_double))
31 LOG(ERROR) << "Failed to parse the default device scale factor:" << value; 30 LOG(ERROR) << "Failed to parse the default device scale factor:" << value;
32 } 31 }
33 return static_cast<float>(scale_in_double); 32 return static_cast<float>(scale_in_double);
34 } 33 }
35 34
36 const int64 kInvalidDisplayIDForCompileTimeInit = -1; 35 const int64 kInvalidDisplayIDForCompileTimeInit = -1;
37 int64 internal_display_id_ = kInvalidDisplayIDForCompileTimeInit; 36 int64 internal_display_id_ = kInvalidDisplayIDForCompileTimeInit;
37
38 } // namespace 38 } // namespace
39 39
40 const int64 Display::kInvalidDisplayID = kInvalidDisplayIDForCompileTimeInit; 40 const int64 Display::kInvalidDisplayID = kInvalidDisplayIDForCompileTimeInit;
41 41
42 // static 42 // static
43 float Display::GetForcedDeviceScaleFactor() { 43 float Display::GetForcedDeviceScaleFactor() {
44 static const float kForcedDeviceScaleFactor = 44 static const float kForcedDeviceScaleFactor =
45 GetForcedDeviceScaleFactorImpl(); 45 GetForcedDeviceScaleFactorImpl();
46 return kForcedDeviceScaleFactor; 46 return kForcedDeviceScaleFactor;
47 } 47 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 int64 Display::InternalDisplayId() { 145 int64 Display::InternalDisplayId() {
146 return internal_display_id_; 146 return internal_display_id_;
147 } 147 }
148 148
149 void Display::SetInternalDisplayId(int64 internal_display_id) { 149 void Display::SetInternalDisplayId(int64 internal_display_id) {
150 internal_display_id_ = internal_display_id; 150 internal_display_id_ = internal_display_id;
151 } 151 }
152 152
153 } // namespace gfx 153 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/screen_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698