| 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 InitializeOnEvdev() override {} | 30 void InitializeOnEvdevIfNecessary() override {} |
| 31 void SendToDelegate(DrmCursorProxy* delegate) override {} |
| 31 | 32 |
| 32 private: | 33 private: |
| 33 DISALLOW_COPY_AND_ASSIGN(NullProxy); | 34 DISALLOW_COPY_AND_ASSIGN(NullProxy); |
| 34 }; | 35 }; |
| 35 | 36 |
| 36 } // namespace | 37 } // namespace |
| 37 | 38 |
| 38 DrmCursor::DrmCursor(DrmWindowHostManager* window_manager) | 39 DrmCursor::DrmCursor(DrmWindowHostManager* window_manager) |
| 39 : window_(gfx::kNullAcceleratedWidget), | 40 : window_(gfx::kNullAcceleratedWidget), |
| 40 window_manager_(window_manager), | 41 window_manager_(window_manager), |
| 41 proxy_(new NullProxy()) { | 42 proxy_(new NullProxy()) { |
| 42 evdev_thread_checker_.DetachFromThread(); | 43 evdev_thread_checker_.DetachFromThread(); |
| 43 } | 44 } |
| 44 | 45 |
| 45 DrmCursor::~DrmCursor() {} | 46 DrmCursor::~DrmCursor() {} |
| 46 | 47 |
| 47 void DrmCursor::SetDrmCursorProxy(DrmCursorProxy* proxy) { | 48 std::unique_ptr<DrmCursorProxy> DrmCursor::SetDrmCursorProxy( |
| 49 std::unique_ptr<DrmCursorProxy> proxy) { |
| 48 TRACE_EVENT0("drmcursor", "DrmCursor::SetDrmCursorProxy"); | 50 TRACE_EVENT0("drmcursor", "DrmCursor::SetDrmCursorProxy"); |
| 49 DCHECK(thread_checker_.CalledOnValidThread()); | 51 DCHECK(thread_checker_.CalledOnValidThread()); |
| 50 base::AutoLock lock(lock_); | 52 base::AutoLock lock(lock_); |
| 51 proxy_.reset(proxy); | 53 std::swap(proxy, proxy_); |
| 54 return proxy; |
| 52 } | 55 } |
| 53 | 56 |
| 54 void DrmCursor::ResetDrmCursorProxy() { | 57 void DrmCursor::ResetDrmCursorProxy() { |
| 55 TRACE_EVENT0("drmcursor", "DrmCursor::ResetDrmCursorProxy"); | 58 TRACE_EVENT0("drmcursor", "DrmCursor::ResetDrmCursorProxy"); |
| 56 DCHECK(thread_checker_.CalledOnValidThread()); | 59 DCHECK(thread_checker_.CalledOnValidThread()); |
| 57 | 60 |
| 58 NullProxy* np = new NullProxy(); | 61 NullProxy* np = new NullProxy(); |
| 59 base::AutoLock lock(lock_); | 62 base::AutoLock lock(lock_); |
| 60 proxy_.reset(np); | 63 proxy_.reset(np); |
| 61 } | 64 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 return location_ + display_bounds_in_screen_.OffsetFromOrigin(); | 212 return location_ + display_bounds_in_screen_.OffsetFromOrigin(); |
| 210 } | 213 } |
| 211 | 214 |
| 212 gfx::Rect DrmCursor::GetCursorConfinedBounds() { | 215 gfx::Rect DrmCursor::GetCursorConfinedBounds() { |
| 213 base::AutoLock lock(lock_); | 216 base::AutoLock lock(lock_); |
| 214 return confined_bounds_ + display_bounds_in_screen_.OffsetFromOrigin(); | 217 return confined_bounds_ + display_bounds_in_screen_.OffsetFromOrigin(); |
| 215 } | 218 } |
| 216 | 219 |
| 217 void DrmCursor::InitializeOnEvdev() { | 220 void DrmCursor::InitializeOnEvdev() { |
| 218 DCHECK(evdev_thread_checker_.CalledOnValidThread()); | 221 DCHECK(evdev_thread_checker_.CalledOnValidThread()); |
| 219 proxy_->InitializeOnEvdev(); | 222 proxy_->InitializeOnEvdevIfNecessary(); |
| 220 } | 223 } |
| 221 | 224 |
| 222 void DrmCursor::SetCursorLocationLocked(const gfx::PointF& location) { | 225 void DrmCursor::SetCursorLocationLocked(const gfx::PointF& location) { |
| 223 gfx::PointF clamped_location = location; | 226 gfx::PointF clamped_location = location; |
| 224 clamped_location.SetToMax(gfx::PointF(confined_bounds_.origin())); | 227 clamped_location.SetToMax(gfx::PointF(confined_bounds_.origin())); |
| 225 // Right and bottom edges are exclusive. | 228 // Right and bottom edges are exclusive. |
| 226 clamped_location.SetToMin( | 229 clamped_location.SetToMin( |
| 227 gfx::PointF(confined_bounds_.right() - 1, confined_bounds_.bottom() - 1)); | 230 gfx::PointF(confined_bounds_.right() - 1, confined_bounds_.bottom() - 1)); |
| 228 | 231 |
| 229 location_ = clamped_location; | 232 location_ = clamped_location; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 258 } | 261 } |
| 259 | 262 |
| 260 void DrmCursor::MoveLockTested(gfx::AcceleratedWidget window, | 263 void DrmCursor::MoveLockTested(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 proxy_->Move(window, point); |
| 264 } | 267 } |
| 265 | 268 |
| 266 | 269 |
| 267 } // namespace ui | 270 } // namespace ui |
| OLD | NEW |