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