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/base/cursor/ozone/bitmap_cursor_factory_ozone.h" | 5 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/skia/include/core/SkBitmap.h" | 8 #include "third_party/skia/include/core/SkBitmap.h" |
9 #include "ui/base/cursor/cursors_aura.h" | 9 #include "ui/base/cursor/cursors_aura.h" |
10 | 10 |
11 namespace ui { | 11 namespace ui { |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 BitmapCursorOzone* ToBitmapCursorOzone(PlatformCursor cursor) { | 15 BitmapCursorOzone* ToBitmapCursorOzone(PlatformCursor cursor) { |
16 return static_cast<BitmapCursorOzone*>(cursor); | 16 return static_cast<BitmapCursorOzone*>(cursor); |
17 } | 17 } |
18 | 18 |
19 PlatformCursor ToPlatformCursor(BitmapCursorOzone* cursor) { | 19 PlatformCursor ToPlatformCursor(BitmapCursorOzone* cursor) { |
20 return static_cast<PlatformCursor>(cursor); | 20 return static_cast<PlatformCursor>(cursor); |
21 } | 21 } |
22 | 22 |
23 } // namespace | 23 } // namespace |
24 | 24 |
25 BitmapCursorFactoryOzone::BitmapCursorFactoryOzone() {} | 25 BitmapCursorFactoryOzone::BitmapCursorFactoryOzone() {} |
26 | 26 |
27 BitmapCursorFactoryOzone::~BitmapCursorFactoryOzone() {} | 27 BitmapCursorFactoryOzone::~BitmapCursorFactoryOzone() {} |
28 | 28 |
| 29 // static |
| 30 scoped_refptr<BitmapCursorOzone> BitmapCursorFactoryOzone::GetBitmapCursor( |
| 31 PlatformCursor platform_cursor) { |
| 32 return make_scoped_refptr(ToBitmapCursorOzone(platform_cursor)); |
| 33 } |
| 34 |
29 PlatformCursor BitmapCursorFactoryOzone::GetDefaultCursor(int type) { | 35 PlatformCursor BitmapCursorFactoryOzone::GetDefaultCursor(int type) { |
30 if (type == kCursorNone) | 36 if (type == kCursorNone) |
31 return NULL; // NULL is used for hidden cursor. | 37 return NULL; // NULL is used for hidden cursor. |
32 | 38 |
33 if (!default_cursors_.count(type)) { | 39 if (!default_cursors_.count(type)) { |
34 // Create new owned image cursor from default aura bitmap for this type. | 40 // Create new owned image cursor from default aura bitmap for this type. |
35 SkBitmap bitmap; | 41 SkBitmap bitmap; |
36 gfx::Point hotspot; | 42 gfx::Point hotspot; |
37 CHECK(GetCursorBitmap(type, &bitmap, &hotspot)); | 43 CHECK(GetCursorBitmap(type, &bitmap, &hotspot)); |
38 default_cursors_[type] = new BitmapCursorOzone(bitmap, hotspot); | 44 default_cursors_[type] = new BitmapCursorOzone(bitmap, hotspot); |
(...skipping 12 matching lines...) Expand all Loading... |
51 } | 57 } |
52 | 58 |
53 void BitmapCursorFactoryOzone::RefImageCursor(PlatformCursor cursor) { | 59 void BitmapCursorFactoryOzone::RefImageCursor(PlatformCursor cursor) { |
54 ToBitmapCursorOzone(cursor)->AddRef(); | 60 ToBitmapCursorOzone(cursor)->AddRef(); |
55 } | 61 } |
56 | 62 |
57 void BitmapCursorFactoryOzone::UnrefImageCursor(PlatformCursor cursor) { | 63 void BitmapCursorFactoryOzone::UnrefImageCursor(PlatformCursor cursor) { |
58 ToBitmapCursorOzone(cursor)->Release(); | 64 ToBitmapCursorOzone(cursor)->Release(); |
59 } | 65 } |
60 | 66 |
61 void BitmapCursorFactoryOzone::SetCursor(gfx::AcceleratedWidget widget, | |
62 PlatformCursor platform_cursor) { | |
63 BitmapCursorOzone* cursor = ToBitmapCursorOzone(platform_cursor); | |
64 SetBitmapCursor(widget, make_scoped_refptr(cursor)); | |
65 } | |
66 | |
67 void BitmapCursorFactoryOzone::SetBitmapCursor( | |
68 gfx::AcceleratedWidget widget, | |
69 scoped_refptr<BitmapCursorOzone>) { | |
70 NOTIMPLEMENTED(); | |
71 } | |
72 | |
73 } // namespace ui | 67 } // namespace ui |
OLD | NEW |