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/dri_cursor.h" | 5 #include "ui/ozone/platform/dri/dri_cursor.h" |
6 | 6 |
7 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" | 7 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" |
8 #include "ui/gfx/geometry/point.h" | 8 #include "ui/gfx/geometry/point.h" |
9 #include "ui/gfx/geometry/point_conversions.h" | 9 #include "ui/gfx/geometry/point_conversions.h" |
10 #include "ui/gfx/geometry/point_f.h" | 10 #include "ui/gfx/geometry/point_f.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 | 25 |
26 void DriCursor::SetCursor(gfx::AcceleratedWidget widget, | 26 void DriCursor::SetCursor(gfx::AcceleratedWidget widget, |
27 PlatformCursor platform_cursor) { | 27 PlatformCursor platform_cursor) { |
28 scoped_refptr<BitmapCursorOzone> cursor = | 28 scoped_refptr<BitmapCursorOzone> cursor = |
29 BitmapCursorFactoryOzone::GetBitmapCursor(platform_cursor); | 29 BitmapCursorFactoryOzone::GetBitmapCursor(platform_cursor); |
30 if (cursor_ == cursor) | 30 if (cursor_ == cursor) |
31 return; | 31 return; |
32 | 32 |
33 cursor_ = cursor; | 33 cursor_ = cursor; |
34 if (cursor_) | 34 if (cursor_.get()) |
35 hardware_->SetHardwareCursor( | 35 hardware_->SetHardwareCursor( |
36 cursor_window_, cursor_->bitmap(), bitmap_location()); | 36 cursor_window_, cursor_->bitmap(), bitmap_location()); |
37 else | 37 else |
38 hardware_->SetHardwareCursor(cursor_window_, SkBitmap(), gfx::Point()); | 38 hardware_->SetHardwareCursor(cursor_window_, SkBitmap(), gfx::Point()); |
39 } | 39 } |
40 | 40 |
41 void DriCursor::MoveCursorTo(gfx::AcceleratedWidget widget, | 41 void DriCursor::MoveCursorTo(gfx::AcceleratedWidget widget, |
42 const gfx::PointF& location) { | 42 const gfx::PointF& location) { |
43 if (widget != cursor_window_) | 43 if (widget != cursor_window_) |
44 hardware_->SetHardwareCursor(cursor_window_, SkBitmap(), gfx::Point()); | 44 hardware_->SetHardwareCursor(cursor_window_, SkBitmap(), gfx::Point()); |
45 | 45 |
46 cursor_window_ = widget; | 46 cursor_window_ = widget; |
47 cursor_location_ = location; | 47 cursor_location_ = location; |
48 | 48 |
49 gfx::Size size = gfx::Size(2560, 1700); // TODO(spang): Fix. | 49 gfx::Size size = gfx::Size(2560, 1700); // TODO(spang): Fix. |
50 cursor_location_.SetToMax(gfx::PointF(0, 0)); | 50 cursor_location_.SetToMax(gfx::PointF(0, 0)); |
51 cursor_location_.SetToMin(gfx::PointF(size.width(), size.height())); | 51 cursor_location_.SetToMin(gfx::PointF(size.width(), size.height())); |
52 | 52 |
53 if (cursor_) | 53 if (cursor_.get()) |
54 hardware_->MoveHardwareCursor(cursor_window_, bitmap_location()); | 54 hardware_->MoveHardwareCursor(cursor_window_, bitmap_location()); |
55 } | 55 } |
56 | 56 |
57 void DriCursor::MoveCursor(const gfx::Vector2dF& delta) { | 57 void DriCursor::MoveCursor(const gfx::Vector2dF& delta) { |
58 MoveCursorTo(cursor_window_, cursor_location_ + delta); | 58 MoveCursorTo(cursor_window_, cursor_location_ + delta); |
59 } | 59 } |
60 | 60 |
61 gfx::AcceleratedWidget DriCursor::GetCursorWindow() { | 61 gfx::AcceleratedWidget DriCursor::GetCursorWindow() { |
62 return cursor_window_; | 62 return cursor_window_; |
63 } | 63 } |
64 | 64 |
65 bool DriCursor::IsCursorVisible() { | 65 bool DriCursor::IsCursorVisible() { |
66 return cursor_; | 66 return cursor_.get(); |
67 } | 67 } |
68 | 68 |
69 gfx::PointF DriCursor::location() { | 69 gfx::PointF DriCursor::location() { |
70 return cursor_location_; | 70 return cursor_location_; |
71 } | 71 } |
72 | 72 |
73 gfx::Point DriCursor::bitmap_location() { | 73 gfx::Point DriCursor::bitmap_location() { |
74 return gfx::ToFlooredPoint(cursor_location_) - | 74 return gfx::ToFlooredPoint(cursor_location_) - |
75 cursor_->hotspot().OffsetFromOrigin(); | 75 cursor_->hotspot().OffsetFromOrigin(); |
76 } | 76 } |
77 | 77 |
78 } // namespace ui | 78 } // namespace ui |
OLD | NEW |