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

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

Issue 11953054: Fix high-DPI on Windows to make use of DIP scaling in WebKit. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove experimental changes to resource handling. Created 7 years, 11 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
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"
12 #include "ui/gfx/insets.h" 13 #include "ui/gfx/insets.h"
13 #include "ui/gfx/size_conversions.h" 14 #include "ui/gfx/size_conversions.h"
14 15
15 namespace gfx { 16 namespace gfx {
16 namespace { 17 namespace {
17 18
18 bool HasForceDeviceScaleFactor() { 19 bool HasForceDeviceScaleFactorImpl() {
19 return CommandLine::ForCurrentProcess()->HasSwitch( 20 return CommandLine::ForCurrentProcess()->HasSwitch(
20 switches::kForceDeviceScaleFactor); 21 switches::kForceDeviceScaleFactor);
21 } 22 }
22 23
23 float GetForcedDeviceScaleFactorImpl() { 24 float GetForcedDeviceScaleFactorImpl() {
24 double scale_in_double = 1.0; 25 double scale_in_double = 1.0;
25 if (HasForceDeviceScaleFactor()) { 26 if (HasForceDeviceScaleFactorImpl()) {
26 std::string value = CommandLine::ForCurrentProcess()-> 27 std::string value = CommandLine::ForCurrentProcess()->
27 GetSwitchValueASCII(switches::kForceDeviceScaleFactor); 28 GetSwitchValueASCII(switches::kForceDeviceScaleFactor);
28 if (!base::StringToDouble(value, &scale_in_double)) 29 if (!base::StringToDouble(value, &scale_in_double))
29 LOG(ERROR) << "Failed to parse the deafult device scale factor:" << value; 30 LOG(ERROR) << "Failed to parse the deafult device scale factor:" << value;
30 } 31 }
32 #if defined(OS_WIN)
pkotwicz 2013/01/23 19:39:23 I think that this block of code should be in GetDe
kevers 2013/01/23 21:37:00 Done.
33 else {
34 static double os_scale = ui::GetDPIScale();
35 scale_in_double = os_scale;
36 }
37 #endif
38
31 return static_cast<float>(scale_in_double); 39 return static_cast<float>(scale_in_double);
32 } 40 }
33 41
34 } // namespace 42 } // namespace
35 43
36 const int64 Display::kInvalidDisplayID = -1; 44 const int64 Display::kInvalidDisplayID = -1;
37 45
38 // static 46 // static
39 float Display::GetForcedDeviceScaleFactor() { 47 float Display::GetForcedDeviceScaleFactor() {
40 static const float kForcedDeviceScaleFactor = 48 static const float kForcedDeviceScaleFactor =
41 GetForcedDeviceScaleFactorImpl(); 49 GetForcedDeviceScaleFactorImpl();
42 return kForcedDeviceScaleFactor; 50 return kForcedDeviceScaleFactor;
43 } 51 }
52 //static
pkotwicz 2013/01/23 19:39:23 Nit: newline before static
kevers 2013/01/23 21:37:00 Done.
53 bool Display::HasForceDeviceScaleFactor() {
54 return HasForceDeviceScaleFactorImpl();
55 }
44 56
45 // static 57 // static
46 int64 Display::GetID(uint16 manufacturer_id, uint32 serial_number) { 58 int64 Display::GetID(uint16 manufacturer_id, uint32 serial_number) {
47 int64 new_id = ((static_cast<int64>(manufacturer_id) << 32) | serial_number); 59 int64 new_id = ((static_cast<int64>(manufacturer_id) << 32) | serial_number);
48 DCHECK_NE(kInvalidDisplayID, new_id); 60 DCHECK_NE(kInvalidDisplayID, new_id);
49 return new_id; 61 return new_id;
50 } 62 }
51 63
52 Display::Display() 64 Display::Display()
53 : id_(kInvalidDisplayID), 65 : id_(kInvalidDisplayID),
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 133
122 std::string Display::ToString() const { 134 std::string Display::ToString() const {
123 return base::StringPrintf("Display[%lld] bounds=%s, workarea=%s, scale=%f", 135 return base::StringPrintf("Display[%lld] bounds=%s, workarea=%s, scale=%f",
124 static_cast<long long int>(id_), 136 static_cast<long long int>(id_),
125 bounds_.ToString().c_str(), 137 bounds_.ToString().c_str(),
126 work_area_.ToString().c_str(), 138 work_area_.ToString().c_str(),
127 device_scale_factor_); 139 device_scale_factor_);
128 } 140 }
129 141
130 } // namespace gfx 142 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698