Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
| 8 #include "ui/gfx/geometry/point_conversions.h" | 8 #include "ui/gfx/geometry/point_conversions.h" |
| 9 #include "ui/ozone/platform/drm/host/drm_window_host.h" | 9 #include "ui/ozone/platform/drm/host/drm_window_host.h" |
| 10 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h" | 10 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h" |
| 11 | 11 |
| 12 #if defined(OS_CHROMEOS) | 12 #if defined(OS_CHROMEOS) |
| 13 #include "ui/events/ozone/chromeos/cursor_controller.h" | 13 #include "ui/events/ozone/chromeos/cursor_controller.h" |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 namespace ui { | 16 namespace ui { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 class NullProxy : public DrmCursorProxy { | 20 class NullProxy : public DrmCursorProxy { |
| 21 public: | 21 public: |
| 22 NullProxy() {} | 22 NullProxy() {} |
| 23 ~NullProxy() override {} | 23 ~NullProxy() override {} |
| 24 | 24 |
| 25 void CursorSet(gfx::AcceleratedWidget window, | 25 void CursorSet(gfx::AcceleratedWidget window, |
| 26 const std::vector<SkBitmap>& bitmaps, | 26 const std::vector<SkBitmap>& bitmaps, |
| 27 const gfx::Point& point, | 27 const gfx::Point& point, |
| 28 int frame_delay_ms) override {} | 28 int frame_delay_ms) override {} |
| 29 void Move(gfx::AcceleratedWidget window, const gfx::Point& point) override {} | 29 void Move(gfx::AcceleratedWidget window, const gfx::Point& point) override {} |
| 30 void MoveEvdev(gfx::AcceleratedWidget window, | |
| 31 const gfx::Point& point) override {} | |
| 30 void InitializeOnEvdev() override {} | 32 void InitializeOnEvdev() override {} |
| 31 | 33 |
| 32 private: | 34 private: |
| 33 DISALLOW_COPY_AND_ASSIGN(NullProxy); | 35 DISALLOW_COPY_AND_ASSIGN(NullProxy); |
| 34 }; | 36 }; |
| 35 | 37 |
| 36 } // namespace | 38 } // namespace |
| 37 | 39 |
| 38 DrmCursor::DrmCursor(DrmWindowHostManager* window_manager) | 40 DrmCursor::DrmCursor(DrmWindowHostManager* window_manager) |
| 39 : window_(gfx::kNullAcceleratedWidget), | 41 : window_(gfx::kNullAcceleratedWidget), |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 DrmWindowHost* drm_window_host = window_manager_->GetWindow(window); | 158 DrmWindowHost* drm_window_host = window_manager_->GetWindow(window); |
| 157 display_bounds_in_screen_ = drm_window_host->GetBounds(); | 159 display_bounds_in_screen_ = drm_window_host->GetBounds(); |
| 158 confined_bounds_ = drm_window_host->GetCursorConfinedBounds(); | 160 confined_bounds_ = drm_window_host->GetCursorConfinedBounds(); |
| 159 window_ = window; | 161 window_ = window; |
| 160 } | 162 } |
| 161 | 163 |
| 162 SetCursorLocationLocked(location); | 164 SetCursorLocationLocked(location); |
| 163 if (window != old_window) | 165 if (window != old_window) |
| 164 SendCursorShowLocked(); | 166 SendCursorShowLocked(); |
| 165 else | 167 else |
| 166 SendCursorMoveLocked(); | 168 SendCursorMoveLocked(UI); |
| 167 } | 169 } |
| 168 | 170 |
| 169 void DrmCursor::MoveCursorTo(const gfx::PointF& screen_location) { | 171 void DrmCursor::MoveCursorTo(const gfx::PointF& screen_location) { |
| 170 TRACE_EVENT0("drmcursor", "DrmCursor::MoveCursorTo"); | 172 TRACE_EVENT0("drmcursor", "DrmCursor::MoveCursorTo"); |
| 171 DCHECK(thread_checker_.CalledOnValidThread()); | 173 DCHECK(thread_checker_.CalledOnValidThread()); |
| 172 base::AutoLock lock(lock_); | 174 base::AutoLock lock(lock_); |
| 173 | 175 |
| 174 // TODO(spang): Moving between windows doesn't work here, but | 176 // TODO(spang): Moving between windows doesn't work here, but |
| 175 // is not needed for current uses. | 177 // is not needed for current uses. |
| 176 SetCursorLocationLocked(screen_location - | 178 SetCursorLocationLocked(screen_location - |
| 177 display_bounds_in_screen_.OffsetFromOrigin()); | 179 display_bounds_in_screen_.OffsetFromOrigin()); |
| 178 | 180 |
| 179 SendCursorMoveLocked(); | 181 SendCursorMoveLocked(UI); |
|
spang
2016/07/22 19:52:54
Assuming MoveCursorTo() is called from UI is broke
| |
| 180 } | 182 } |
| 181 | 183 |
| 182 void DrmCursor::MoveCursor(const gfx::Vector2dF& delta) { | 184 void DrmCursor::MoveCursor(const gfx::Vector2dF& delta) { |
| 183 DCHECK(evdev_thread_checker_.CalledOnValidThread()); | 185 DCHECK(evdev_thread_checker_.CalledOnValidThread()); |
| 184 TRACE_EVENT0("drmcursor", "DrmCursor::MoveCursor"); | 186 TRACE_EVENT0("drmcursor", "DrmCursor::MoveCursor"); |
| 185 base::AutoLock lock(lock_); | 187 base::AutoLock lock(lock_); |
| 186 | 188 |
| 187 if (window_ == gfx::kNullAcceleratedWidget) | 189 if (window_ == gfx::kNullAcceleratedWidget) |
| 188 return; | 190 return; |
| 189 | 191 |
| 190 gfx::Point location; | 192 gfx::Point location; |
| 191 #if defined(OS_CHROMEOS) | 193 #if defined(OS_CHROMEOS) |
| 192 gfx::Vector2dF transformed_delta = delta; | 194 gfx::Vector2dF transformed_delta = delta; |
| 193 ui::CursorController::GetInstance()->ApplyCursorConfigForWindow( | 195 ui::CursorController::GetInstance()->ApplyCursorConfigForWindow( |
| 194 window_, &transformed_delta); | 196 window_, &transformed_delta); |
| 195 SetCursorLocationLocked(location_ + transformed_delta); | 197 SetCursorLocationLocked(location_ + transformed_delta); |
| 196 #else | 198 #else |
| 197 SetCursorLocationLocked(location_ + delta); | 199 SetCursorLocationLocked(location_ + delta); |
| 198 #endif | 200 #endif |
| 199 SendCursorMoveLocked(); | 201 SendCursorMoveLocked(EVDEV); |
| 200 } | 202 } |
| 201 | 203 |
| 202 bool DrmCursor::IsCursorVisible() { | 204 bool DrmCursor::IsCursorVisible() { |
| 203 base::AutoLock lock(lock_); | 205 base::AutoLock lock(lock_); |
| 204 return static_cast<bool>(bitmap_); | 206 return static_cast<bool>(bitmap_); |
| 205 } | 207 } |
| 206 | 208 |
| 207 gfx::PointF DrmCursor::GetLocation() { | 209 gfx::PointF DrmCursor::GetLocation() { |
| 208 base::AutoLock lock(lock_); | 210 base::AutoLock lock(lock_); |
| 209 return location_ + display_bounds_in_screen_.OffsetFromOrigin(); | 211 return location_ + display_bounds_in_screen_.OffsetFromOrigin(); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 235 return; | 237 return; |
| 236 } | 238 } |
| 237 CursorSetLockTested(window_, bitmap_->bitmaps(), GetBitmapLocationLocked(), | 239 CursorSetLockTested(window_, bitmap_->bitmaps(), GetBitmapLocationLocked(), |
| 238 bitmap_->frame_delay_ms()); | 240 bitmap_->frame_delay_ms()); |
| 239 } | 241 } |
| 240 | 242 |
| 241 void DrmCursor::SendCursorHideLocked() { | 243 void DrmCursor::SendCursorHideLocked() { |
| 242 CursorSetLockTested(window_, std::vector<SkBitmap>(), gfx::Point(), 0); | 244 CursorSetLockTested(window_, std::vector<SkBitmap>(), gfx::Point(), 0); |
| 243 } | 245 } |
| 244 | 246 |
| 245 void DrmCursor::SendCursorMoveLocked() { | 247 void DrmCursor::SendCursorMoveLocked(ThreadType thread_type) { |
| 246 if (!bitmap_) | 248 if (!bitmap_) |
| 247 return; | 249 return; |
| 248 MoveLockTested(window_, GetBitmapLocationLocked()); | 250 MoveLockTested(thread_type, window_, GetBitmapLocationLocked()); |
| 249 } | 251 } |
| 250 | 252 |
| 251 // Lock-testing helpers. | 253 // Lock-testing helpers. |
| 252 void DrmCursor::CursorSetLockTested(gfx::AcceleratedWidget window, | 254 void DrmCursor::CursorSetLockTested(gfx::AcceleratedWidget window, |
| 253 const std::vector<SkBitmap>& bitmaps, | 255 const std::vector<SkBitmap>& bitmaps, |
| 254 const gfx::Point& point, | 256 const gfx::Point& point, |
| 255 int frame_delay_ms) { | 257 int frame_delay_ms) { |
| 256 lock_.AssertAcquired(); | 258 lock_.AssertAcquired(); |
| 257 proxy_->CursorSet(window, bitmaps, point, frame_delay_ms); | 259 proxy_->CursorSet(window, bitmaps, point, frame_delay_ms); |
| 258 } | 260 } |
| 259 | 261 |
| 260 void DrmCursor::MoveLockTested(gfx::AcceleratedWidget window, | 262 void DrmCursor::MoveLockTested(ThreadType thread_type, |
| 263 gfx::AcceleratedWidget window, | |
| 261 const gfx::Point& point) { | 264 const gfx::Point& point) { |
| 262 lock_.AssertAcquired(); | 265 lock_.AssertAcquired(); |
| 263 proxy_->Move(window, point); | 266 if (thread_type == EVDEV) |
| 267 proxy_->MoveEvdev(window, point); | |
| 268 else | |
| 269 proxy_->Move(window, point); | |
| 264 } | 270 } |
| 265 | 271 |
| 266 | 272 |
| 267 } // namespace ui | 273 } // namespace ui |
| OLD | NEW |