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/dri/cursor_factory_evdev_dri.h" | 5 #include "ui/ozone/platform/dri/dri_cursor.h" |
6 | 6 |
| 7 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" |
| 8 #include "ui/gfx/geometry/point.h" |
7 #include "ui/gfx/geometry/point_conversions.h" | 9 #include "ui/gfx/geometry/point_conversions.h" |
| 10 #include "ui/gfx/geometry/point_f.h" |
8 #include "ui/ozone/platform/dri/dri_surface_factory.h" | 11 #include "ui/ozone/platform/dri/dri_surface_factory.h" |
9 #include "ui/ozone/platform/dri/hardware_cursor_delegate.h" | 12 #include "ui/ozone/platform/dri/hardware_cursor_delegate.h" |
10 | 13 |
11 namespace ui { | 14 namespace ui { |
12 | 15 |
13 CursorFactoryEvdevDri::CursorFactoryEvdevDri(HardwareCursorDelegate* hardware) | 16 DriCursor::DriCursor(HardwareCursorDelegate* hardware) : hardware_(hardware) { |
14 : hardware_(hardware) { | |
15 // TODO(dnicoara) Assume the first widget since at this point there are no | 17 // TODO(dnicoara) Assume the first widget since at this point there are no |
16 // widgets initialized. | 18 // widgets initialized. |
17 cursor_window_ = DriSurfaceFactory::kDefaultWidgetHandle; | 19 cursor_window_ = DriSurfaceFactory::kDefaultWidgetHandle; |
18 cursor_location_ = gfx::PointF(2560 / 2, 1700 / 2); // TODO(spang): Argh! | 20 cursor_location_ = gfx::PointF(2560 / 2, 1700 / 2); // TODO(spang): Argh! |
19 } | 21 } |
20 | 22 |
21 CursorFactoryEvdevDri::~CursorFactoryEvdevDri() {} | 23 DriCursor::~DriCursor() { |
| 24 } |
22 | 25 |
23 void CursorFactoryEvdevDri::SetBitmapCursor( | 26 void DriCursor::SetCursor(gfx::AcceleratedWidget widget, |
24 gfx::AcceleratedWidget widget, | 27 PlatformCursor platform_cursor) { |
25 scoped_refptr<BitmapCursorOzone> cursor) { | 28 scoped_refptr<BitmapCursorOzone> cursor = |
| 29 BitmapCursorFactoryOzone::GetBitmapCursor(platform_cursor); |
26 if (cursor_ == cursor) | 30 if (cursor_ == cursor) |
27 return; | 31 return; |
28 | 32 |
29 cursor_ = cursor; | 33 cursor_ = cursor; |
30 if (cursor_) | 34 if (cursor_) |
31 hardware_->SetHardwareCursor( | 35 hardware_->SetHardwareCursor( |
32 cursor_window_, cursor_->bitmap(), bitmap_location()); | 36 cursor_window_, cursor_->bitmap(), bitmap_location()); |
33 else | 37 else |
34 hardware_->SetHardwareCursor(cursor_window_, SkBitmap(), gfx::Point()); | 38 hardware_->SetHardwareCursor(cursor_window_, SkBitmap(), gfx::Point()); |
35 } | 39 } |
36 | 40 |
37 void CursorFactoryEvdevDri::MoveCursorTo(gfx::AcceleratedWidget widget, | 41 void DriCursor::MoveCursorTo(gfx::AcceleratedWidget widget, |
38 const gfx::PointF& location) { | 42 const gfx::PointF& location) { |
39 if (widget != cursor_window_) | 43 if (widget != cursor_window_) |
40 hardware_->SetHardwareCursor(cursor_window_, SkBitmap(), gfx::Point()); | 44 hardware_->SetHardwareCursor(cursor_window_, SkBitmap(), gfx::Point()); |
41 | 45 |
42 cursor_window_ = widget; | 46 cursor_window_ = widget; |
43 cursor_location_ = location; | 47 cursor_location_ = location; |
44 | 48 |
45 gfx::Size size = gfx::Size(2560, 1700); // TODO(spang): Fix. | 49 gfx::Size size = gfx::Size(2560, 1700); // TODO(spang): Fix. |
46 cursor_location_.SetToMax(gfx::PointF(0, 0)); | 50 cursor_location_.SetToMax(gfx::PointF(0, 0)); |
47 cursor_location_.SetToMin(gfx::PointF(size.width(), size.height())); | 51 cursor_location_.SetToMin(gfx::PointF(size.width(), size.height())); |
48 | 52 |
49 if (cursor_) | 53 if (cursor_) |
50 hardware_->MoveHardwareCursor(cursor_window_, bitmap_location()); | 54 hardware_->MoveHardwareCursor(cursor_window_, bitmap_location()); |
51 } | 55 } |
52 | 56 |
53 void CursorFactoryEvdevDri::MoveCursor(const gfx::Vector2dF& delta) { | 57 void DriCursor::MoveCursor(const gfx::Vector2dF& delta) { |
54 MoveCursorTo(cursor_window_, cursor_location_ + delta); | 58 MoveCursorTo(cursor_window_, cursor_location_ + delta); |
55 } | 59 } |
56 | 60 |
57 gfx::AcceleratedWidget CursorFactoryEvdevDri::GetCursorWindow() { | 61 gfx::AcceleratedWidget DriCursor::GetCursorWindow() { |
58 return cursor_window_; | 62 return cursor_window_; |
59 } | 63 } |
60 | 64 |
61 bool CursorFactoryEvdevDri::IsCursorVisible() { return cursor_; } | 65 bool DriCursor::IsCursorVisible() { |
| 66 return cursor_; |
| 67 } |
62 | 68 |
63 gfx::PointF CursorFactoryEvdevDri::location() { return cursor_location_; } | 69 gfx::PointF DriCursor::location() { |
| 70 return cursor_location_; |
| 71 } |
64 | 72 |
65 gfx::Point CursorFactoryEvdevDri::bitmap_location() { | 73 gfx::Point DriCursor::bitmap_location() { |
66 return gfx::ToFlooredPoint(cursor_location_) - | 74 return gfx::ToFlooredPoint(cursor_location_) - |
67 cursor_->hotspot().OffsetFromOrigin(); | 75 cursor_->hotspot().OffsetFromOrigin(); |
68 } | 76 } |
69 | 77 |
70 } // namespace ui | 78 } // namespace ui |
OLD | NEW |