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

Side by Side Diff: chrome/browser/extensions/display_info_provider_win.cc

Issue 1426933002: Refactor Windows DPI Point, Rect, and Size for Multiple Monitor DPI Awareness (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR Feedback Created 5 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/extensions/display_info_provider_win.h" 5 #include "chrome/browser/extensions/display_info_provider_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/hash.h" 9 #include "base/hash.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 20 matching lines...) Expand all
31 MONITORINFOEX monitor_info; 31 MONITORINFOEX monitor_info;
32 ZeroMemory(&monitor_info, sizeof(MONITORINFOEX)); 32 ZeroMemory(&monitor_info, sizeof(MONITORINFOEX));
33 monitor_info.cbSize = sizeof(monitor_info); 33 monitor_info.cbSize = sizeof(monitor_info);
34 GetMonitorInfo(monitor, &monitor_info); 34 GetMonitorInfo(monitor, &monitor_info);
35 35
36 DISPLAY_DEVICE device; 36 DISPLAY_DEVICE device;
37 device.cb = sizeof(device); 37 device.cb = sizeof(device);
38 if (!EnumDisplayDevices(monitor_info.szDevice, 0, &device, 0)) 38 if (!EnumDisplayDevices(monitor_info.szDevice, 0, &device, 0))
39 return FALSE; 39 return FALSE;
40 40
41 gfx::Size dpi(gfx::GetDPI());
42 unit->id = 41 unit->id =
43 base::Int64ToString(base::Hash(base::WideToUTF8(monitor_info.szDevice))); 42 base::Int64ToString(base::Hash(base::WideToUTF8(monitor_info.szDevice)));
44 unit->name = base::WideToUTF8(device.DeviceString); 43 unit->name = base::WideToUTF8(device.DeviceString);
45 unit->dpi_x = dpi.width();
46 unit->dpi_y = dpi.height();
47 all_displays->push_back(unit); 44 all_displays->push_back(unit);
48 45
49 return TRUE; 46 return TRUE;
50 } 47 }
51 48
52 } // namespace 49 } // namespace
53 50
54 DisplayInfoProviderWin::DisplayInfoProviderWin() { 51 DisplayInfoProviderWin::DisplayInfoProviderWin() {
55 } 52 }
56 53
(...skipping 10 matching lines...) Expand all
67 64
68 void DisplayInfoProviderWin::UpdateDisplayUnitInfoForPlatform( 65 void DisplayInfoProviderWin::UpdateDisplayUnitInfoForPlatform(
69 const gfx::Display& display, 66 const gfx::Display& display,
70 extensions::api::system_display::DisplayUnitInfo* unit) { 67 extensions::api::system_display::DisplayUnitInfo* unit) {
71 DisplayInfo all_displays; 68 DisplayInfo all_displays;
72 EnumDisplayMonitors( 69 EnumDisplayMonitors(
73 NULL, NULL, EnumMonitorCallback, reinterpret_cast<LPARAM>(&all_displays)); 70 NULL, NULL, EnumMonitorCallback, reinterpret_cast<LPARAM>(&all_displays));
74 for (size_t i = 0; i < all_displays.size(); ++i) { 71 for (size_t i = 0; i < all_displays.size(); ++i) {
75 if (unit->id == all_displays[i]->id) { 72 if (unit->id == all_displays[i]->id) {
76 unit->name = all_displays[i]->name; 73 unit->name = all_displays[i]->name;
77 unit->dpi_x = all_displays[i]->dpi_x; 74 int dpi = gfx::GetDPIFromScalingFactor(display.device_scale_factor());
78 unit->dpi_y = all_displays[i]->dpi_y; 75 unit->dpi_x = dpi;
76 unit->dpi_y = dpi;
79 break; 77 break;
80 } 78 }
81 } 79 }
82 } 80 }
83 81
84 gfx::Screen* DisplayInfoProviderWin::GetActiveScreen() { 82 gfx::Screen* DisplayInfoProviderWin::GetActiveScreen() {
85 // TODO(scottmg): native screen is wrong http://crbug.com/133312 83 // TODO(scottmg): native screen is wrong http://crbug.com/133312
86 return gfx::Screen::GetNativeScreen(); 84 return gfx::Screen::GetNativeScreen();
87 } 85 }
88 86
89 // static 87 // static
90 DisplayInfoProvider* DisplayInfoProvider::Create() { 88 DisplayInfoProvider* DisplayInfoProvider::Create() {
91 return new DisplayInfoProviderWin(); 89 return new DisplayInfoProviderWin();
92 } 90 }
93 91
94 } // namespace extensions 92 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698