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