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

Unified Diff: components/exo/pointer.cc

Issue 2777343002: exo: Rotate cursor snapshot for rotated displays (Closed)
Patch Set: Add comment Created 3 years, 7 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/display.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 90551072ad04a24fbf7375224d7f6d47863c091b..360d0d95f9046ff10cacf07d26146caf94063d2c 100644
--- a/components/exo/pointer.cc
+++ b/components/exo/pointer.cc
@@ -281,6 +281,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_)
CaptureCursor();
@@ -336,19 +337,24 @@ void Pointer::CaptureCursor() {
gfx::Transform transform;
transform.Scale(layer_scale, layer_scale);
+ transform.Rotate(display::Display::RotateToDegree(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)));
+ gfx::ScaleToFlooredPoint(hotspot, scale)));
request->set_source(cursor_capture_source_id_);
cursor_->layer()->RequestCopyOfOutput(std::move(request));
}
-void Pointer::OnCursorCaptured(const gfx::Point& hotspot,
+void Pointer::OnCursorCaptured(gfx::Point hotspot,
std::unique_ptr<cc::CopyOutputResult> result) {
if (!focus_)
return;
@@ -358,6 +364,23 @@ void Pointer::OnCursorCaptured(const 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698