Chromium Code Reviews| Index: components/exo/pointer.cc |
| diff --git a/components/exo/pointer.cc b/components/exo/pointer.cc |
| index 2271212085be6ee4ae72f40f096ca8100cd30ceb..23f99aa17ccf0e925901f62f9f20bcf0b48e9585 100644 |
| --- a/components/exo/pointer.cc |
| +++ b/components/exo/pointer.cc |
| @@ -4,6 +4,7 @@ |
| #include "components/exo/pointer.h" |
| +#include <algorithm> |
|
reveman
2017/06/22 21:24:01
nit: remove if not needed
Dominik Laskowski
2017/06/22 22:31:14
Removed along with std::max.
|
| #include <utility> |
| #include "ash/public/cpp/shell_window_ids.h" |
| @@ -41,10 +42,6 @@ namespace { |
| // for now. See crbug.com/708378. |
| const float kLargeCursorScale = 2.8f; |
| -// Scale at which cursor snapshot is captured. The resulting bitmap is scaled on |
| -// displays whose DSF does not match this scale. |
| -const float kCursorCaptureScale = 2.0f; |
| - |
| const double kLocatedEventEpsilonSquared = 1.0 / (2000.0 * 2000.0); |
| // Synthesized events typically lack floating point precision so to avoid |
| @@ -79,6 +76,8 @@ Pointer::Pointer(PointerDelegate* delegate) |
| helper->AddPreTargetHandler(this); |
| helper->AddCursorObserver(this); |
| helper->AddDisplayConfigurationObserver(this); |
| + |
| + OnDisplayConfigurationChanged(); |
|
reveman
2017/06/22 21:24:01
nit: don't call this here. see comment below
Dominik Laskowski
2017/06/22 22:31:14
Done.
|
| } |
| Pointer::~Pointer() { |
| @@ -270,6 +269,12 @@ void Pointer::OnCursorDisplayChanged(const display::Display& display) { |
| void Pointer::OnDisplayConfigurationChanged() { |
| UpdatePointerSurface(surface_); |
| + |
| + capture_scale_ = 1.0f; |
| + for (const auto& display : display::Screen::GetScreen()->GetAllDisplays()) { |
| + const auto& info = WMHelper::GetInstance()->GetDisplayInfo(display.id()); |
| + capture_scale_ = std::max(capture_scale_, info.device_scale_factor()); |
| + } |
|
reveman
2017/06/22 21:24:01
nit: please move this logic into a GetCaptureScale
Dominik Laskowski
2017/06/22 22:31:14
Done.
|
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| @@ -345,7 +350,7 @@ void Pointer::CaptureCursor(const gfx::Point& hotspot) { |
| display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| auto* helper = WMHelper::GetInstance(); |
| float scale = helper->GetDisplayInfo(display.id()).GetEffectiveUIScale() * |
| - kCursorCaptureScale / display.device_scale_factor(); |
| + capture_scale_ / display.device_scale_factor(); |
| surface_->window()->SetTransform(gfx::GetScaleTransform(gfx::Point(), scale)); |
| std::unique_ptr<cc::CopyOutputRequest> request = |
| @@ -380,13 +385,12 @@ void Pointer::UpdateCursor() { |
| cursor_ = ui::CursorType::kNone; |
| } else { |
| SkBitmap bitmap = cursor_bitmap_; |
| - gfx::Point hotspot = |
| - gfx::ScaleToFlooredPoint(hotspot_, kCursorCaptureScale); |
| + gfx::Point hotspot = gfx::ScaleToFlooredPoint(hotspot_, capture_scale_); |
| auto* helper = WMHelper::GetInstance(); |
| const display::Display& display = helper->GetCursorDisplay(); |
| float scale = helper->GetDisplayInfo(display.id()).device_scale_factor() / |
| - kCursorCaptureScale; |
| + capture_scale_; |
| if (helper->GetCursorSet() == ui::CURSOR_SET_LARGE) |
| scale *= kLargeCursorScale; |