Chromium Code Reviews| 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())); |
|
danakj
2015/10/30 23:25:54
+dnicoara@chromium.org
It's not obvious to me tha
| |
| 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 168 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 |