| OLD | NEW |
| 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/display/win/screen_win.h" | 5 #include "ui/display/win/screen_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shellscalingapi.h> | 8 #include <shellscalingapi.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 HWND hwnd = view ? GetHWNDFromNativeView(view) : nullptr; | 423 HWND hwnd = view ? GetHWNDFromNativeView(view) : nullptr; |
| 424 return ScreenToDIPRect(hwnd, screen_rect); | 424 return ScreenToDIPRect(hwnd, screen_rect); |
| 425 } | 425 } |
| 426 | 426 |
| 427 gfx::Rect ScreenWin::DIPToScreenRectInWindow(gfx::NativeView view, | 427 gfx::Rect ScreenWin::DIPToScreenRectInWindow(gfx::NativeView view, |
| 428 const gfx::Rect& dip_rect) const { | 428 const gfx::Rect& dip_rect) const { |
| 429 HWND hwnd = view ? GetHWNDFromNativeView(view) : nullptr; | 429 HWND hwnd = view ? GetHWNDFromNativeView(view) : nullptr; |
| 430 return DIPToScreenRect(hwnd, dip_rect); | 430 return DIPToScreenRect(hwnd, dip_rect); |
| 431 } | 431 } |
| 432 | 432 |
| 433 void ScreenWin::SetDeviceScaleFactorForTest(float scale_factor) { |
| 434 LOG(ERROR) << "Set DSF:" << scale_factor; |
| 435 display::Display::SetForceDeviceScaleFactorForTesting(scale_factor); |
| 436 std::vector<display::Display> old_displays = GetAllDisplays(); |
| 437 UpdateFromDisplayInfos(GetDisplayInfosFromSystem()); |
| 438 change_notifier_.NotifyDisplaysChanged(old_displays, GetAllDisplays()); |
| 439 } |
| 440 |
| 433 void ScreenWin::UpdateFromDisplayInfos( | 441 void ScreenWin::UpdateFromDisplayInfos( |
| 434 const std::vector<DisplayInfo>& display_infos) { | 442 const std::vector<DisplayInfo>& display_infos) { |
| 435 screen_win_displays_ = DisplayInfosToScreenWinDisplays(display_infos); | 443 screen_win_displays_ = DisplayInfosToScreenWinDisplays(display_infos); |
| 436 } | 444 } |
| 437 | 445 |
| 438 void ScreenWin::Initialize() { | 446 void ScreenWin::Initialize() { |
| 439 singleton_hwnd_observer_.reset( | 447 singleton_hwnd_observer_.reset( |
| 440 new gfx::SingletonHwndObserver( | 448 new gfx::SingletonHwndObserver( |
| 441 base::Bind(&ScreenWin::OnWndProc, base::Unretained(this)))); | 449 base::Bind(&ScreenWin::OnWndProc, base::Unretained(this)))); |
| 442 UpdateFromDisplayInfos(GetDisplayInfosFromSystem()); | 450 UpdateFromDisplayInfos(GetDisplayInfosFromSystem()); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 if (std::find(unique_scale_factors.begin(), unique_scale_factors.end(), | 586 if (std::find(unique_scale_factors.begin(), unique_scale_factors.end(), |
| 579 reported_scale) == unique_scale_factors.end()) { | 587 reported_scale) == unique_scale_factors.end()) { |
| 580 unique_scale_factors.push_back(reported_scale); | 588 unique_scale_factors.push_back(reported_scale); |
| 581 UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale); | 589 UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale); |
| 582 } | 590 } |
| 583 } | 591 } |
| 584 } | 592 } |
| 585 | 593 |
| 586 } // namespace win | 594 } // namespace win |
| 587 } // namespace display | 595 } // namespace display |
| OLD | NEW |