| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/ozone/platform/drm/host/drm_cursor.h" | 5 #include "ui/ozone/platform/drm/host/drm_cursor.h" |
| 6 | 6 |
| 7 #include "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
| 8 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" | 8 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" |
| 9 #include "ui/gfx/geometry/point.h" | 9 #include "ui/gfx/geometry/point.h" |
| 10 #include "ui/gfx/geometry/point_conversions.h" | 10 #include "ui/gfx/geometry/point_conversions.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 ui_task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 51 ui_task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
| 52 #endif | 52 #endif |
| 53 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 53 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
| 54 base::AutoLock lock(state_.lock); | 54 base::AutoLock lock(state_.lock); |
| 55 | 55 |
| 56 if (state_.window == gfx::kNullAcceleratedWidget) { | 56 if (state_.window == gfx::kNullAcceleratedWidget) { |
| 57 // First window added & cursor is not placed. Place it. | 57 // First window added & cursor is not placed. Place it. |
| 58 state_.window = window; | 58 state_.window = window; |
| 59 state_.display_bounds_in_screen = bounds_in_screen; | 59 state_.display_bounds_in_screen = bounds_in_screen; |
| 60 state_.confined_bounds = cursor_confined_bounds; | 60 state_.confined_bounds = cursor_confined_bounds; |
| 61 SetCursorLocationLocked(cursor_confined_bounds.CenterPoint()); | 61 SetCursorLocationLocked(gfx::PointF(cursor_confined_bounds.CenterPoint())); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 void DrmCursor::OnWindowRemoved(gfx::AcceleratedWidget window) { | 65 void DrmCursor::OnWindowRemoved(gfx::AcceleratedWidget window) { |
| 66 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 66 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
| 67 base::AutoLock lock(state_.lock); | 67 base::AutoLock lock(state_.lock); |
| 68 | 68 |
| 69 if (state_.window == window) { | 69 if (state_.window == window) { |
| 70 // Try to find a new location for the cursor. | 70 // Try to find a new location for the cursor. |
| 71 DrmWindowHost* dest_window = window_manager_->GetPrimaryWindow(); | 71 DrmWindowHost* dest_window = window_manager_->GetPrimaryWindow(); |
| 72 | 72 |
| 73 if (dest_window) { | 73 if (dest_window) { |
| 74 state_.window = dest_window->GetAcceleratedWidget(); | 74 state_.window = dest_window->GetAcceleratedWidget(); |
| 75 state_.display_bounds_in_screen = dest_window->GetBounds(); | 75 state_.display_bounds_in_screen = dest_window->GetBounds(); |
| 76 state_.confined_bounds = dest_window->GetCursorConfinedBounds(); | 76 state_.confined_bounds = dest_window->GetCursorConfinedBounds(); |
| 77 SetCursorLocationLocked(state_.confined_bounds.CenterPoint()); | 77 SetCursorLocationLocked( |
| 78 gfx::PointF(state_.confined_bounds.CenterPoint())); |
| 78 SendCursorShowLocked(); | 79 SendCursorShowLocked(); |
| 79 } else { | 80 } else { |
| 80 state_.window = gfx::kNullAcceleratedWidget; | 81 state_.window = gfx::kNullAcceleratedWidget; |
| 81 state_.display_bounds_in_screen = gfx::Rect(); | 82 state_.display_bounds_in_screen = gfx::Rect(); |
| 82 state_.confined_bounds = gfx::Rect(); | 83 state_.confined_bounds = gfx::Rect(); |
| 83 state_.location = gfx::Point(); | 84 state_.location = gfx::PointF(); |
| 84 } | 85 } |
| 85 } | 86 } |
| 86 } | 87 } |
| 87 | 88 |
| 88 void DrmCursor::CommitBoundsChange( | 89 void DrmCursor::CommitBoundsChange( |
| 89 gfx::AcceleratedWidget window, | 90 gfx::AcceleratedWidget window, |
| 90 const gfx::Rect& new_display_bounds_in_screen, | 91 const gfx::Rect& new_display_bounds_in_screen, |
| 91 const gfx::Rect& new_confined_bounds) { | 92 const gfx::Rect& new_confined_bounds) { |
| 92 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 93 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
| 93 base::AutoLock lock(state_.lock); | 94 base::AutoLock lock(state_.lock); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 } | 200 } |
| 200 | 201 |
| 201 bool DrmCursor::OnMessageReceived(const IPC::Message& message) { | 202 bool DrmCursor::OnMessageReceived(const IPC::Message& message) { |
| 202 return false; | 203 return false; |
| 203 } | 204 } |
| 204 | 205 |
| 205 void DrmCursor::SetCursorLocationLocked(const gfx::PointF& location) { | 206 void DrmCursor::SetCursorLocationLocked(const gfx::PointF& location) { |
| 206 state_.lock.AssertAcquired(); | 207 state_.lock.AssertAcquired(); |
| 207 | 208 |
| 208 gfx::PointF clamped_location = location; | 209 gfx::PointF clamped_location = location; |
| 209 clamped_location.SetToMax(state_.confined_bounds.origin()); | 210 clamped_location.SetToMax(gfx::PointF(state_.confined_bounds.origin())); |
| 210 // Right and bottom edges are exclusive. | 211 // Right and bottom edges are exclusive. |
| 211 clamped_location.SetToMin(gfx::PointF(state_.confined_bounds.right() - 1, | 212 clamped_location.SetToMin(gfx::PointF(state_.confined_bounds.right() - 1, |
| 212 state_.confined_bounds.bottom() - 1)); | 213 state_.confined_bounds.bottom() - 1)); |
| 213 | 214 |
| 214 state_.location = clamped_location; | 215 state_.location = clamped_location; |
| 215 } | 216 } |
| 216 | 217 |
| 217 gfx::Point DrmCursor::GetBitmapLocationLocked() { | 218 gfx::Point DrmCursor::GetBitmapLocationLocked() { |
| 218 return gfx::ToFlooredPoint(state_.location) - | 219 return gfx::ToFlooredPoint(state_.location) - |
| 219 state_.bitmap->hotspot().OffsetFromOrigin(); | 220 state_.bitmap->hotspot().OffsetFromOrigin(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 } | 263 } |
| 263 | 264 |
| 264 DrmCursor::CursorState::CursorState() | 265 DrmCursor::CursorState::CursorState() |
| 265 : window(gfx::kNullAcceleratedWidget), host_id(-1) { | 266 : window(gfx::kNullAcceleratedWidget), host_id(-1) { |
| 266 } | 267 } |
| 267 | 268 |
| 268 DrmCursor::CursorState::~CursorState() { | 269 DrmCursor::CursorState::~CursorState() { |
| 269 } | 270 } |
| 270 | 271 |
| 271 } // namespace ui | 272 } // namespace ui |
| OLD | NEW |