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 |