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

Unified Diff: components/exo/pointer.cc

Issue 2933133002: exo: Select cursor capture scale at run time (Closed)
Patch Set: Remove std::accumulate 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') | no next file » | 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 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;
« no previous file with comments | « components/exo/pointer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698