OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/exo/pointer.h" | 5 #include "components/exo/pointer.h" |
6 | 6 |
7 #include <algorithm> | |
8 #include <numeric> | 7 #include <numeric> |
8 #include <tuple> | |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "ash/public/cpp/shell_window_ids.h" | 11 #include "ash/public/cpp/shell_window_ids.h" |
12 #include "cc/output/copy_output_request.h" | 12 #include "cc/output/copy_output_request.h" |
13 #include "cc/output/copy_output_result.h" | 13 #include "cc/output/copy_output_result.h" |
14 #include "components/exo/pointer_delegate.h" | 14 #include "components/exo/pointer_delegate.h" |
15 #include "components/exo/pointer_stylus_delegate.h" | 15 #include "components/exo/pointer_stylus_delegate.h" |
16 #include "components/exo/surface.h" | 16 #include "components/exo/surface.h" |
17 #include "components/exo/wm_helper.h" | 17 #include "components/exo/wm_helper.h" |
18 #include "ui/aura/client/cursor_client.h" | 18 #include "ui/aura/client/cursor_client.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 UpdateCursor(); | 265 UpdateCursor(); |
266 } | 266 } |
267 | 267 |
268 //////////////////////////////////////////////////////////////////////////////// | 268 //////////////////////////////////////////////////////////////////////////////// |
269 // WMHelper::DisplayConfigurationObserver overrides: | 269 // WMHelper::DisplayConfigurationObserver overrides: |
270 | 270 |
271 void Pointer::OnDisplayConfigurationChanged() { | 271 void Pointer::OnDisplayConfigurationChanged() { |
272 UpdatePointerSurface(surface_); | 272 UpdatePointerSurface(surface_); |
273 | 273 |
274 const auto& displays = display::Screen::GetScreen()->GetAllDisplays(); | 274 const auto& displays = display::Screen::GetScreen()->GetAllDisplays(); |
275 capture_scale_ = std::accumulate( | 275 using ScalePair = std::pair<float, float>; |
276 displays.begin(), displays.end(), 1.0f, | 276 std::tie(capture_scale_, capture_ratio_) = std::accumulate( |
reveman
2017/06/19 22:20:39
heh, cool; but I think you've crossed the line to
Dominik Laskowski
2017/06/20 15:52:35
Yeah, even the original was pushing it. Done.
| |
277 [](float scale, const display::Display& display) -> float { | 277 displays.begin(), displays.end(), ScalePair(1.0f, 1.0f), |
278 [](const ScalePair& pair, const display::Display& display) -> ScalePair { | |
278 const auto& info = | 279 const auto& info = |
279 WMHelper::GetInstance()->GetDisplayInfo(display.id()); | 280 WMHelper::GetInstance()->GetDisplayInfo(display.id()); |
280 return std::max(scale, info.device_scale_factor()); | 281 return info.device_scale_factor() > pair.first |
282 ? ScalePair(info.device_scale_factor(), | |
283 info.GetDensityRatio()) | |
284 : pair; | |
281 }); | 285 }); |
282 } | 286 } |
283 | 287 |
284 //////////////////////////////////////////////////////////////////////////////// | 288 //////////////////////////////////////////////////////////////////////////////// |
285 // SurfaceDelegate overrides: | 289 // SurfaceDelegate overrides: |
286 | 290 |
287 void Pointer::OnSurfaceCommit() { | 291 void Pointer::OnSurfaceCommit() { |
288 surface_->CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); | 292 surface_->CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); |
289 surface_->CommitSurfaceHierarchy(); | 293 surface_->CommitSurfaceHierarchy(); |
290 | 294 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 UpdateCursor(); | 386 UpdateCursor(); |
383 } | 387 } |
384 | 388 |
385 void Pointer::UpdateCursor() { | 389 void Pointer::UpdateCursor() { |
386 DCHECK(focus_); | 390 DCHECK(focus_); |
387 | 391 |
388 if (cursor_bitmap_.drawsNothing()) { | 392 if (cursor_bitmap_.drawsNothing()) { |
389 cursor_ = ui::CursorType::kNone; | 393 cursor_ = ui::CursorType::kNone; |
390 } else { | 394 } else { |
391 SkBitmap bitmap = cursor_bitmap_; | 395 SkBitmap bitmap = cursor_bitmap_; |
392 gfx::Point hotspot = gfx::ScaleToFlooredPoint(hotspot_, capture_scale_); | 396 gfx::Point hotspot = gfx::ScaleToFlooredPoint(hotspot_, capture_ratio_); |
393 | 397 |
394 auto* helper = WMHelper::GetInstance(); | 398 auto* helper = WMHelper::GetInstance(); |
395 const display::Display& display = helper->GetCursorDisplay(); | 399 const display::Display& display = helper->GetCursorDisplay(); |
396 float scale = helper->GetDisplayInfo(display.id()).device_scale_factor() / | 400 float scale = |
397 capture_scale_; | 401 helper->GetDisplayInfo(display.id()).GetDensityRatio() / capture_ratio_; |
398 | 402 |
399 if (helper->GetCursorSet() == ui::CURSOR_SET_LARGE) | 403 if (helper->GetCursorSet() == ui::CURSOR_SET_LARGE) |
400 scale *= kLargeCursorScale; | 404 scale *= kLargeCursorScale; |
401 | 405 |
402 ui::ScaleAndRotateCursorBitmapAndHotpoint(scale, display.rotation(), | 406 ui::ScaleAndRotateCursorBitmapAndHotpoint(scale, display.rotation(), |
403 &bitmap, &hotspot); | 407 &bitmap, &hotspot); |
404 | 408 |
405 ui::PlatformCursor platform_cursor; | 409 ui::PlatformCursor platform_cursor; |
406 #if defined(USE_OZONE) | 410 #if defined(USE_OZONE) |
407 // TODO(reveman): Add interface for creating cursors from GpuMemoryBuffers | 411 // TODO(reveman): Add interface for creating cursors from GpuMemoryBuffers |
(...skipping 17 matching lines...) Expand all Loading... | |
425 if (!root_window) | 429 if (!root_window) |
426 return; | 430 return; |
427 | 431 |
428 aura::client::CursorClient* cursor_client = | 432 aura::client::CursorClient* cursor_client = |
429 aura::client::GetCursorClient(root_window); | 433 aura::client::GetCursorClient(root_window); |
430 if (cursor_client) | 434 if (cursor_client) |
431 cursor_client->SetCursor(cursor_); | 435 cursor_client->SetCursor(cursor_); |
432 } | 436 } |
433 | 437 |
434 } // namespace exo | 438 } // namespace exo |
OLD | NEW |