Avi Drissman | d6cdf9b | 2022-09-15 19:52:53 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | 05a6071 | 2012-09-26 02:02:18 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "remoting/host/desktop_resizer.h" |
| 6 | |
[email protected] | 8c83a71c | 2013-12-16 18:02:58 | [diff] [blame] | 7 | #include <windows.h> |
dcheng | 0765c49 | 2016-04-06 22:41:53 | [diff] [blame] | 8 | |
avi | c5960f3 | 2015-12-22 22:49:48 | [diff] [blame] | 9 | #include <map> |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 10 | |
Hans Wennborg | 22e28d6a | 2020-06-17 17:17:21 | [diff] [blame] | 11 | #include "base/check.h" |
[email protected] | 05a6071 | 2012-09-26 02:02:18 | [diff] [blame] | 12 | #include "base/logging.h" |
dcheng | 0765c49 | 2016-04-06 22:41:53 | [diff] [blame] | 13 | #include "base/memory/ptr_util.h" |
Yuwei Huang | 6b9099b | 2022-09-13 00:03:58 | [diff] [blame] | 14 | #include "base/notreached.h" |
[email protected] | 05a6071 | 2012-09-26 02:02:18 | [diff] [blame] | 15 | |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 16 | namespace { |
| 17 | // TODO(jamiewalch): Use the correct DPI for the mode: http://crbug.com/172405. |
| 18 | const int kDefaultDPI = 96; |
| 19 | } // namespace |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 20 | |
[email protected] | 05a6071 | 2012-09-26 02:02:18 | [diff] [blame] | 21 | namespace remoting { |
| 22 | |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 23 | // Provide comparison operation for ScreenResolution so we can use it in |
| 24 | // std::map. |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 25 | static inline bool operator<(const ScreenResolution& a, |
| 26 | const ScreenResolution& b) { |
| 27 | if (a.dimensions().width() != b.dimensions().width()) { |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 28 | return a.dimensions().width() < b.dimensions().width(); |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 29 | } |
| 30 | if (a.dimensions().height() != b.dimensions().height()) { |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 31 | return a.dimensions().height() < b.dimensions().height(); |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 32 | } |
| 33 | if (a.dpi().x() != b.dpi().x()) { |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 34 | return a.dpi().x() < b.dpi().x(); |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 35 | } |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 36 | return a.dpi().y() < b.dpi().y(); |
| 37 | } |
| 38 | |
[email protected] | 05a6071 | 2012-09-26 02:02:18 | [diff] [blame] | 39 | class DesktopResizerWin : public DesktopResizer { |
| 40 | public: |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 41 | DesktopResizerWin(); |
Lei Zhang | 8bb2aa54 | 2021-05-20 06:40:22 | [diff] [blame] | 42 | DesktopResizerWin(const DesktopResizerWin&) = delete; |
| 43 | DesktopResizerWin& operator=(const DesktopResizerWin&) = delete; |
nick | 697f429 | 2015-04-23 18:22:31 | [diff] [blame] | 44 | ~DesktopResizerWin() override; |
[email protected] | 05a6071 | 2012-09-26 02:02:18 | [diff] [blame] | 45 | |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 46 | // DesktopResizer interface. |
Lambros Lambrou | de710cd2 | 2022-07-06 18:57:57 | [diff] [blame] | 47 | ScreenResolution GetCurrentResolution(webrtc::ScreenId screen_id) override; |
nick | 697f429 | 2015-04-23 18:22:31 | [diff] [blame] | 48 | std::list<ScreenResolution> GetSupportedResolutions( |
Lambros Lambrou | bf61f84 | 2022-05-20 19:40:57 | [diff] [blame] | 49 | const ScreenResolution& preferred, |
Lambros Lambrou | de710cd2 | 2022-07-06 18:57:57 | [diff] [blame] | 50 | webrtc::ScreenId screen_id) override; |
Lambros Lambrou | bf61f84 | 2022-05-20 19:40:57 | [diff] [blame] | 51 | void SetResolution(const ScreenResolution& resolution, |
Lambros Lambrou | de710cd2 | 2022-07-06 18:57:57 | [diff] [blame] | 52 | webrtc::ScreenId screen_id) override; |
Lambros Lambrou | bf61f84 | 2022-05-20 19:40:57 | [diff] [blame] | 53 | void RestoreResolution(const ScreenResolution& original, |
Lambros Lambrou | de710cd2 | 2022-07-06 18:57:57 | [diff] [blame] | 54 | webrtc::ScreenId screen_id) override; |
Yuwei Huang | 6b9099b | 2022-09-13 00:03:58 | [diff] [blame] | 55 | void SetVideoLayout(const protocol::VideoLayout& layout) override; |
[email protected] | 05a6071 | 2012-09-26 02:02:18 | [diff] [blame] | 56 | |
| 57 | private: |
Jamie Walch | a981ffa | 2020-07-07 18:55:44 | [diff] [blame] | 58 | void UpdateBestModeForResolution(const DEVMODE& current_mode, |
| 59 | const DEVMODE& candidate_mode); |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 60 | static bool IsResizeSupported(); |
| 61 | |
| 62 | // Calls EnumDisplaySettingsEx() for the primary monitor. |
[email protected] | 5d2848a7 | 2013-02-14 05:10:13 | [diff] [blame] | 63 | // Returns false if |mode_number| does not exist. |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 64 | static bool GetPrimaryDisplayMode(DWORD mode_number, |
| 65 | DWORD flags, |
| 66 | DEVMODE* mode); |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 67 | |
| 68 | // Returns true if the mode has width, height, bits-per-pixel, frequency |
| 69 | // and orientation fields. |
| 70 | static bool IsModeValid(const DEVMODE& mode); |
| 71 | |
| 72 | // Returns the width & height of |mode|, or 0x0 if they are missing. |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 73 | static ScreenResolution GetModeResolution(const DEVMODE& mode); |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 74 | |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 75 | std::map<ScreenResolution, DEVMODE> best_mode_for_resolution_; |
Jamie Walch | 10eefba7 | 2020-10-26 19:30:35 | [diff] [blame] | 76 | DEVMODE initial_mode_; |
[email protected] | 05a6071 | 2012-09-26 02:02:18 | [diff] [blame] | 77 | }; |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 78 | |
| 79 | DesktopResizerWin::DesktopResizerWin() { |
Jamie Walch | 10eefba7 | 2020-10-26 19:30:35 | [diff] [blame] | 80 | if (!GetPrimaryDisplayMode(ENUM_CURRENT_SETTINGS, 0, &initial_mode_) || |
| 81 | !IsModeValid(initial_mode_)) { |
| 82 | LOG(ERROR) << "GetPrimaryDisplayMode failed. Resize will not prefer " |
| 83 | << "initial orientation or frequency settings."; |
| 84 | initial_mode_.dmFields = 0; |
| 85 | } |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 86 | } |
| 87 | |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 88 | DesktopResizerWin::~DesktopResizerWin() {} |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 89 | |
Lambros Lambrou | bf61f84 | 2022-05-20 19:40:57 | [diff] [blame] | 90 | ScreenResolution DesktopResizerWin::GetCurrentResolution( |
Lambros Lambrou | de710cd2 | 2022-07-06 18:57:57 | [diff] [blame] | 91 | webrtc::ScreenId screen_id) { |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 92 | DEVMODE current_mode; |
| 93 | if (GetPrimaryDisplayMode(ENUM_CURRENT_SETTINGS, 0, ¤t_mode) && |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 94 | IsModeValid(current_mode)) { |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 95 | return GetModeResolution(current_mode); |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 96 | } |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 97 | return ScreenResolution(); |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 98 | } |
| 99 | |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 100 | std::list<ScreenResolution> DesktopResizerWin::GetSupportedResolutions( |
Lambros Lambrou | bf61f84 | 2022-05-20 19:40:57 | [diff] [blame] | 101 | const ScreenResolution& preferred, |
Lambros Lambrou | de710cd2 | 2022-07-06 18:57:57 | [diff] [blame] | 102 | webrtc::ScreenId screen_id) { |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 103 | if (!IsResizeSupported()) { |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 104 | return std::list<ScreenResolution>(); |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 105 | } |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 106 | |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 107 | // Enumerate the resolutions to return, and where there are multiple modes of |
| 108 | // the same resolution, store the one most closely matching the current mode |
| 109 | // in |best_mode_for_resolution_|. |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 110 | DEVMODE current_mode; |
| 111 | if (!GetPrimaryDisplayMode(ENUM_CURRENT_SETTINGS, 0, ¤t_mode) || |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 112 | !IsModeValid(current_mode)) { |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 113 | return std::list<ScreenResolution>(); |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 114 | } |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 115 | |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 116 | best_mode_for_resolution_.clear(); |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 117 | for (DWORD i = 0;; ++i) { |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 118 | DEVMODE candidate_mode; |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 119 | if (!GetPrimaryDisplayMode(i, EDS_ROTATEDMODE, &candidate_mode)) { |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 120 | break; |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 121 | } |
Jamie Walch | a981ffa | 2020-07-07 18:55:44 | [diff] [blame] | 122 | UpdateBestModeForResolution(current_mode, candidate_mode); |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 123 | } |
| 124 | |
Jamie Walch | a981ffa | 2020-07-07 18:55:44 | [diff] [blame] | 125 | std::list<ScreenResolution> resolutions; |
| 126 | for (const auto& kv : best_mode_for_resolution_) { |
| 127 | resolutions.push_back(kv.first); |
| 128 | } |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 129 | return resolutions; |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 130 | } |
| 131 | |
Lambros Lambrou | de710cd2 | 2022-07-06 18:57:57 | [diff] [blame] | 132 | void DesktopResizerWin::SetResolution(const ScreenResolution& resolution, |
| 133 | webrtc::ScreenId screen_id) { |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 134 | if (best_mode_for_resolution_.count(resolution) == 0) { |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 135 | return; |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 136 | } |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 137 | |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 138 | DEVMODE new_mode = best_mode_for_resolution_[resolution]; |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 139 | DWORD result = ChangeDisplaySettings(&new_mode, CDS_FULLSCREEN); |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 140 | if (result != DISP_CHANGE_SUCCESSFUL) { |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 141 | LOG(ERROR) << "SetResolution failed: " << result; |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 142 | } |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 143 | } |
| 144 | |
Lambros Lambrou | de710cd2 | 2022-07-06 18:57:57 | [diff] [blame] | 145 | void DesktopResizerWin::RestoreResolution(const ScreenResolution& original, |
| 146 | webrtc::ScreenId screen_id) { |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 147 | // Restore the display mode based on the registry configuration. |
sergeyu | c5f104b | 2015-01-09 19:33:24 | [diff] [blame] | 148 | DWORD result = ChangeDisplaySettings(nullptr, 0); |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 149 | if (result != DISP_CHANGE_SUCCESSFUL) { |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 150 | LOG(ERROR) << "RestoreResolution failed: " << result; |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 151 | } |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 152 | } |
| 153 | |
Yuwei Huang | 6b9099b | 2022-09-13 00:03:58 | [diff] [blame] | 154 | void DesktopResizerWin::SetVideoLayout(const protocol::VideoLayout& layout) { |
| 155 | NOTIMPLEMENTED(); |
| 156 | } |
| 157 | |
Jamie Walch | a981ffa | 2020-07-07 18:55:44 | [diff] [blame] | 158 | void DesktopResizerWin::UpdateBestModeForResolution( |
| 159 | const DEVMODE& current_mode, |
| 160 | const DEVMODE& candidate_mode) { |
| 161 | // Ignore modes missing the fields that we expect. |
| 162 | if (!IsModeValid(candidate_mode)) { |
| 163 | LOG(INFO) << "Ignoring mode " << candidate_mode.dmPelsWidth << "x" |
| 164 | << candidate_mode.dmPelsHeight << ": invalid fields " << std::hex |
| 165 | << candidate_mode.dmFields; |
| 166 | return; |
| 167 | } |
| 168 | |
| 169 | // Ignore modes with differing bits-per-pixel. |
| 170 | if (candidate_mode.dmBitsPerPel != current_mode.dmBitsPerPel) { |
| 171 | LOG(INFO) << "Ignoring mode " << candidate_mode.dmPelsWidth << "x" |
| 172 | << candidate_mode.dmPelsHeight << ": mismatched BPP: expected " |
| 173 | << current_mode.dmFields << " but got " |
| 174 | << candidate_mode.dmFields; |
| 175 | return; |
| 176 | } |
| 177 | |
| 178 | // If there are multiple modes with the same dimensions: |
Jamie Walch | 10eefba7 | 2020-10-26 19:30:35 | [diff] [blame] | 179 | // - Prefer the modes which match either the initial (preferred) or the |
| 180 | // current rotation. |
| 181 | // - Among those, prefer modes which match the initial (preferred) or the |
| 182 | // current frequency. |
Jamie Walch | a981ffa | 2020-07-07 18:55:44 | [diff] [blame] | 183 | // - Otherwise, prefer modes with a higher frequency. |
| 184 | ScreenResolution candidate_resolution = GetModeResolution(candidate_mode); |
| 185 | if (best_mode_for_resolution_.count(candidate_resolution) != 0) { |
| 186 | DEVMODE best_mode = best_mode_for_resolution_[candidate_resolution]; |
| 187 | |
Jamie Walch | 10eefba7 | 2020-10-26 19:30:35 | [diff] [blame] | 188 | bool best_mode_matches_initial_orientation = |
| 189 | (initial_mode_.dmDisplayOrientation & DM_DISPLAYORIENTATION) && |
| 190 | (best_mode.dmDisplayOrientation == initial_mode_.dmDisplayOrientation); |
| 191 | bool candidate_mode_matches_initial_orientation = |
| 192 | candidate_mode.dmDisplayOrientation == |
| 193 | initial_mode_.dmDisplayOrientation; |
| 194 | if (best_mode_matches_initial_orientation && |
| 195 | !candidate_mode_matches_initial_orientation) { |
Jamie Walch | a981ffa | 2020-07-07 18:55:44 | [diff] [blame] | 196 | LOG(INFO) << "Ignoring mode " << candidate_mode.dmPelsWidth << "x" |
| 197 | << candidate_mode.dmPelsHeight |
Jamie Walch | 10eefba7 | 2020-10-26 19:30:35 | [diff] [blame] | 198 | << ": mode matching initial orientation already found."; |
Jamie Walch | a981ffa | 2020-07-07 18:55:44 | [diff] [blame] | 199 | return; |
| 200 | } |
| 201 | |
Jamie Walch | 10eefba7 | 2020-10-26 19:30:35 | [diff] [blame] | 202 | bool best_mode_matches_current_orientation = |
| 203 | best_mode.dmDisplayOrientation == current_mode.dmDisplayOrientation; |
| 204 | bool candidate_mode_matches_current_orientation = |
| 205 | candidate_mode.dmDisplayOrientation == |
| 206 | current_mode.dmDisplayOrientation; |
| 207 | if (best_mode_matches_current_orientation && |
| 208 | !candidate_mode_matches_initial_orientation && |
| 209 | !candidate_mode_matches_current_orientation) { |
Jamie Walch | a981ffa | 2020-07-07 18:55:44 | [diff] [blame] | 210 | LOG(INFO) << "Ignoring mode " << candidate_mode.dmPelsWidth << "x" |
| 211 | << candidate_mode.dmPelsHeight |
Jamie Walch | 10eefba7 | 2020-10-26 19:30:35 | [diff] [blame] | 212 | << ": mode matching current orientation already found."; |
| 213 | return; |
| 214 | } |
| 215 | |
| 216 | bool best_mode_matches_initial_frequency = |
| 217 | (initial_mode_.dmDisplayOrientation & DM_DISPLAYFREQUENCY) && |
| 218 | (best_mode.dmDisplayFrequency == initial_mode_.dmDisplayFrequency); |
| 219 | bool candidate_mode_matches_initial_frequency = |
| 220 | candidate_mode.dmDisplayFrequency == initial_mode_.dmDisplayFrequency; |
| 221 | if (best_mode_matches_initial_frequency && |
| 222 | !candidate_mode_matches_initial_frequency) { |
| 223 | LOG(INFO) << "Ignoring mode " << candidate_mode.dmPelsWidth << "x" |
| 224 | << candidate_mode.dmPelsHeight |
| 225 | << ": mode matching initial frequency already found."; |
| 226 | return; |
| 227 | } |
| 228 | |
| 229 | bool best_mode_matches_current_frequency = |
| 230 | best_mode.dmDisplayFrequency == current_mode.dmDisplayFrequency; |
| 231 | bool candidate_mode_matches_current_frequency = |
| 232 | candidate_mode.dmDisplayFrequency == current_mode.dmDisplayFrequency; |
| 233 | if (best_mode_matches_current_frequency && |
| 234 | !candidate_mode_matches_initial_frequency && |
| 235 | !candidate_mode_matches_current_frequency) { |
| 236 | LOG(INFO) << "Ignoring mode " << candidate_mode.dmPelsWidth << "x" |
| 237 | << candidate_mode.dmPelsHeight |
| 238 | << ": mode matching current frequency already found."; |
Jamie Walch | a981ffa | 2020-07-07 18:55:44 | [diff] [blame] | 239 | return; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | // If we haven't seen this resolution before, or if it's a better match than |
| 244 | // one we enumerated previously, save it. |
| 245 | best_mode_for_resolution_[candidate_resolution] = candidate_mode; |
| 246 | } |
| 247 | |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 248 | // static |
| 249 | bool DesktopResizerWin::IsResizeSupported() { |
| 250 | // Resize is supported only on single-monitor systems. |
| 251 | return GetSystemMetrics(SM_CMONITORS) == 1; |
| 252 | } |
| 253 | |
| 254 | // static |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 255 | bool DesktopResizerWin::GetPrimaryDisplayMode(DWORD mode_number, |
| 256 | DWORD flags, |
| 257 | DEVMODE* mode) { |
| 258 | memset(mode, 0, sizeof(DEVMODE)); |
| 259 | mode->dmSize = sizeof(DEVMODE); |
| 260 | if (!EnumDisplaySettingsEx(nullptr, mode_number, mode, flags)) { |
| 261 | return false; |
| 262 | } |
| 263 | return true; |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | // static |
| 267 | bool DesktopResizerWin::IsModeValid(const DEVMODE& mode) { |
Joe Downing | fd8a422 | 2023-01-11 23:39:40 | [diff] [blame] | 268 | const DWORD kRequiredFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | |
| 269 | DM_DISPLAYFREQUENCY | DM_DISPLAYORIENTATION; |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 270 | return (mode.dmFields & kRequiredFields) == kRequiredFields; |
| 271 | } |
| 272 | |
| 273 | // static |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 274 | ScreenResolution DesktopResizerWin::GetModeResolution(const DEVMODE& mode) { |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 275 | DCHECK(IsModeValid(mode)); |
[email protected] | fcce48d | 2013-11-01 17:21:18 | [diff] [blame] | 276 | return ScreenResolution( |
| 277 | webrtc::DesktopSize(mode.dmPelsWidth, mode.dmPelsHeight), |
| 278 | webrtc::DesktopVector(kDefaultDPI, kDefaultDPI)); |
[email protected] | ae969fd0 | 2012-11-02 02:45:06 | [diff] [blame] | 279 | } |
[email protected] | 05a6071 | 2012-09-26 02:02:18 | [diff] [blame] | 280 | |
dcheng | 0765c49 | 2016-04-06 22:41:53 | [diff] [blame] | 281 | std::unique_ptr<DesktopResizer> DesktopResizer::Create() { |
| 282 | return base::WrapUnique(new DesktopResizerWin); |
[email protected] | 05a6071 | 2012-09-26 02:02:18 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | } // namespace remoting |