| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/display/win/display_info.h" | 5 #include "ui/display/win/display_info.h" |
| 6 | 6 |
| 7 #include "base/hash.h" | 7 #include "base/hash.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 | 9 |
| 10 namespace display { |
| 10 namespace { | 11 namespace { |
| 11 | 12 |
| 12 gfx::Display::Rotation GetRotationForDevice(const wchar_t* device_name) { | 13 Display::Rotation GetRotationForDevice(const wchar_t* device_name) { |
| 13 DEVMODE mode; | 14 DEVMODE mode; |
| 14 ::ZeroMemory(&mode, sizeof(mode)); | 15 ::ZeroMemory(&mode, sizeof(mode)); |
| 15 mode.dmSize = sizeof(mode); | 16 mode.dmSize = sizeof(mode); |
| 16 mode.dmDriverExtra = 0; | 17 mode.dmDriverExtra = 0; |
| 17 if (::EnumDisplaySettings(device_name, ENUM_CURRENT_SETTINGS, &mode)) { | 18 if (::EnumDisplaySettings(device_name, ENUM_CURRENT_SETTINGS, &mode)) { |
| 18 switch (mode.dmDisplayOrientation) { | 19 switch (mode.dmDisplayOrientation) { |
| 19 case DMDO_DEFAULT: | 20 case DMDO_DEFAULT: |
| 20 return gfx::Display::ROTATE_0; | 21 return Display::ROTATE_0; |
| 21 case DMDO_90: | 22 case DMDO_90: |
| 22 return gfx::Display::ROTATE_90; | 23 return Display::ROTATE_90; |
| 23 case DMDO_180: | 24 case DMDO_180: |
| 24 return gfx::Display::ROTATE_180; | 25 return Display::ROTATE_180; |
| 25 case DMDO_270: | 26 case DMDO_270: |
| 26 return gfx::Display::ROTATE_270; | 27 return Display::ROTATE_270; |
| 27 default: | 28 default: |
| 28 NOTREACHED(); | 29 NOTREACHED(); |
| 29 } | 30 } |
| 30 } | 31 } |
| 31 return gfx::Display::ROTATE_0; | 32 return Display::ROTATE_0; |
| 32 } | 33 } |
| 33 | 34 |
| 34 } // namespace | 35 } // namespace |
| 35 | 36 |
| 36 namespace display { | |
| 37 namespace win { | 37 namespace win { |
| 38 | 38 |
| 39 DisplayInfo::DisplayInfo(const MONITORINFOEX& monitor_info, | 39 DisplayInfo::DisplayInfo(const MONITORINFOEX& monitor_info, |
| 40 float device_scale_factor) | 40 float device_scale_factor) |
| 41 : DisplayInfo(monitor_info, | 41 : DisplayInfo(monitor_info, |
| 42 device_scale_factor, | 42 device_scale_factor, |
| 43 GetRotationForDevice(monitor_info.szDevice)) {} | 43 GetRotationForDevice(monitor_info.szDevice)) {} |
| 44 | 44 |
| 45 DisplayInfo::DisplayInfo(const MONITORINFOEX& monitor_info, | 45 DisplayInfo::DisplayInfo(const MONITORINFOEX& monitor_info, |
| 46 float device_scale_factor, | 46 float device_scale_factor, |
| 47 gfx::Display::Rotation rotation) | 47 Display::Rotation rotation) |
| 48 : id_(DeviceIdFromDeviceName(monitor_info.szDevice)), | 48 : id_(DeviceIdFromDeviceName(monitor_info.szDevice)), |
| 49 rotation_(rotation), | 49 rotation_(rotation), |
| 50 screen_rect_(monitor_info.rcMonitor), | 50 screen_rect_(monitor_info.rcMonitor), |
| 51 screen_work_rect_(monitor_info.rcWork), | 51 screen_work_rect_(monitor_info.rcWork), |
| 52 device_scale_factor_(device_scale_factor) {} | 52 device_scale_factor_(device_scale_factor) {} |
| 53 | 53 |
| 54 // static | 54 // static |
| 55 int64_t DisplayInfo::DeviceIdFromDeviceName(const wchar_t* device_name) { | 55 int64_t DisplayInfo::DeviceIdFromDeviceName(const wchar_t* device_name) { |
| 56 return static_cast<int64_t>(base::Hash(base::WideToUTF8(device_name))); | 56 return static_cast<int64_t>(base::Hash(base::WideToUTF8(device_name))); |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace win | 59 } // namespace win |
| 60 } // namespace display | 60 } // namespace display |
| OLD | NEW |