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

Unified Diff: components/exo/pointer.cc

Issue 2777343002: exo: Rotate cursor snapshot for rotated displays (Closed)
Patch Set: Created 3 years, 9 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
Index: components/exo/pointer.cc
diff --git a/components/exo/pointer.cc b/components/exo/pointer.cc
index 40c0e1ff73a5d74d61651d896ceef578bfc6721e..17c8511058a2b541db9d485236fe9424cb1b9984 100644
--- a/components/exo/pointer.cc
+++ b/components/exo/pointer.cc
@@ -267,6 +267,7 @@ void Pointer::OnCursorDisplayChanging(const display::Display& display) {
auto info = helper->GetDisplayInfo(display.id());
display_scale_ = info.GetEffectiveUIScale() * info.device_scale_factor();
device_scale_factor_ = display.device_scale_factor();
+ rotation_ = display.rotation();
if (focus_ && surface_) {
// Capture is asynchronous, so avoid rendering old cursor in the meantime.
@@ -327,13 +328,18 @@ void Pointer::CaptureCursor(bool force) {
gfx::Transform transform;
transform.Scale(layer_scale, layer_scale);
+ transform.Rotate(display::Display::RotationAsDegree(rotation_));
surface_->window()->SetTransform(transform);
+ gfx::Point hotspot = hotspot_;
+ aura::Window::ConvertPointToTarget(surface_->window(), cursor_.get(),
+ &hotspot);
+
std::unique_ptr<cc::CopyOutputRequest> request =
cc::CopyOutputRequest::CreateBitmapRequest(
base::Bind(&Pointer::OnCursorCaptured,
cursor_capture_weak_ptr_factory_.GetWeakPtr(),
- gfx::ScaleToFlooredPoint(hotspot_, scale), force));
+ gfx::ScaleToFlooredPoint(hotspot, scale), force));
request->set_source(cursor_capture_source_id_);
cursor_->layer()->RequestCopyOfOutput(std::move(request));
@@ -354,6 +360,23 @@ void Pointer::OnCursorCaptured(gfx::Point hotspot,
DCHECK(result->HasBitmap());
std::unique_ptr<SkBitmap> bitmap = result->TakeBitmap();
+ switch (rotation_) {
+ case display::Display::ROTATE_0:
+ break;
+
+ case display::Display::ROTATE_90:
+ hotspot += gfx::Vector2d(bitmap->height(), 0);
+ break;
+
+ case display::Display::ROTATE_180:
+ hotspot += gfx::Vector2d(bitmap->width(), bitmap->height());
+ break;
+
+ case display::Display::ROTATE_270:
+ hotspot += gfx::Vector2d(0, bitmap->width());
+ break;
+ }
+
ui::PlatformCursor platform_cursor;
#if defined(USE_OZONE)
// TODO(reveman): Add interface for creating cursors from GpuMemoryBuffers
« no previous file with comments | « components/exo/pointer.h ('k') | ui/display/display.h » ('j') | ui/display/display.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698