Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Unified Diff: components/exo/pointer.cc

Issue 2944063002: exo: Fix cursor scaling for 1.25 DSF (Closed)
Patch Set: Rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/exo/pointer.h ('k') | ui/display/manager/managed_display_info.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/pointer.cc
diff --git a/components/exo/pointer.cc b/components/exo/pointer.cc
index 5d2b915e85b8e37c13916cec856420c72b182329..6e7b55f2f62a10175565c3408db886856f0b189c 100644
--- a/components/exo/pointer.cc
+++ b/components/exo/pointer.cc
@@ -4,8 +4,8 @@
#include "components/exo/pointer.h"
-#include <algorithm>
#include <numeric>
+#include <tuple>
#include <utility>
#include "ash/public/cpp/shell_window_ids.h"
@@ -272,12 +272,16 @@ void Pointer::OnDisplayConfigurationChanged() {
UpdatePointerSurface(surface_);
const auto& displays = display::Screen::GetScreen()->GetAllDisplays();
- capture_scale_ = std::accumulate(
- displays.begin(), displays.end(), 1.0f,
- [](float scale, const display::Display& display) -> float {
+ using ScalePair = std::pair<float, float>;
+ 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.
+ displays.begin(), displays.end(), ScalePair(1.0f, 1.0f),
+ [](const ScalePair& pair, const display::Display& display) -> ScalePair {
const auto& info =
WMHelper::GetInstance()->GetDisplayInfo(display.id());
- return std::max(scale, info.device_scale_factor());
+ return info.device_scale_factor() > pair.first
+ ? ScalePair(info.device_scale_factor(),
+ info.GetDensityRatio())
+ : pair;
});
}
@@ -389,12 +393,12 @@ void Pointer::UpdateCursor() {
cursor_ = ui::CursorType::kNone;
} else {
SkBitmap bitmap = cursor_bitmap_;
- gfx::Point hotspot = gfx::ScaleToFlooredPoint(hotspot_, capture_scale_);
+ gfx::Point hotspot = gfx::ScaleToFlooredPoint(hotspot_, capture_ratio_);
auto* helper = WMHelper::GetInstance();
const display::Display& display = helper->GetCursorDisplay();
- float scale = helper->GetDisplayInfo(display.id()).device_scale_factor() /
- capture_scale_;
+ float scale =
+ helper->GetDisplayInfo(display.id()).GetDensityRatio() / capture_ratio_;
if (helper->GetCursorSet() == ui::CURSOR_SET_LARGE)
scale *= kLargeCursorScale;
« no previous file with comments | « components/exo/pointer.h ('k') | ui/display/manager/managed_display_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698