OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/cursor_data_factory_ozone.h" | 5 #include "ui/base/cursor/ozone/cursor_data_factory_ozone.h" |
6 | 6 |
7 #include "ui/base/cursor/cursor.h" | 7 #include "ui/base/cursor/cursor.h" |
8 | 8 |
9 namespace ui { | 9 namespace ui { |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 CursorDataFactoryOzone::CursorDataFactoryOzone() {} | 43 CursorDataFactoryOzone::CursorDataFactoryOzone() {} |
44 | 44 |
45 CursorDataFactoryOzone::~CursorDataFactoryOzone() {} | 45 CursorDataFactoryOzone::~CursorDataFactoryOzone() {} |
46 | 46 |
47 // static | 47 // static |
48 const ui::CursorData& CursorDataFactoryOzone::GetCursorData( | 48 const ui::CursorData& CursorDataFactoryOzone::GetCursorData( |
49 PlatformCursor platform_cursor) { | 49 PlatformCursor platform_cursor) { |
50 return ToCursorDataOzone(platform_cursor)->data(); | 50 return ToCursorDataOzone(platform_cursor)->data(); |
51 } | 51 } |
52 | 52 |
53 PlatformCursor CursorDataFactoryOzone::GetDefaultCursor(int type) { | 53 PlatformCursor CursorDataFactoryOzone::GetDefaultCursor(CursorType type) { |
54 // Unlike BitmapCursorFactoryOzone, we aren't making heavyweight bitmaps, but | 54 // Unlike BitmapCursorFactoryOzone, we aren't making heavyweight bitmaps, but |
55 // we still have to cache these forever because objects that come out of the | 55 // we still have to cache these forever because objects that come out of the |
56 // GetDefaultCursor() method aren't treated as refcounted by the ozone | 56 // GetDefaultCursor() method aren't treated as refcounted by the ozone |
57 // interfaces. | 57 // interfaces. |
58 return GetDefaultCursorInternal(type).get(); | 58 return GetDefaultCursorInternal(type).get(); |
59 } | 59 } |
60 | 60 |
61 PlatformCursor CursorDataFactoryOzone::CreateImageCursor( | 61 PlatformCursor CursorDataFactoryOzone::CreateImageCursor( |
62 const SkBitmap& bitmap, | 62 const SkBitmap& bitmap, |
63 const gfx::Point& hotspot, | 63 const gfx::Point& hotspot, |
(...skipping 18 matching lines...) Expand all Loading... |
82 | 82 |
83 void CursorDataFactoryOzone::RefImageCursor(PlatformCursor cursor) { | 83 void CursorDataFactoryOzone::RefImageCursor(PlatformCursor cursor) { |
84 ToCursorDataOzone(cursor)->AddRef(); | 84 ToCursorDataOzone(cursor)->AddRef(); |
85 } | 85 } |
86 | 86 |
87 void CursorDataFactoryOzone::UnrefImageCursor(PlatformCursor cursor) { | 87 void CursorDataFactoryOzone::UnrefImageCursor(PlatformCursor cursor) { |
88 ToCursorDataOzone(cursor)->Release(); | 88 ToCursorDataOzone(cursor)->Release(); |
89 } | 89 } |
90 | 90 |
91 scoped_refptr<CursorDataOzone> CursorDataFactoryOzone::GetDefaultCursorInternal( | 91 scoped_refptr<CursorDataOzone> CursorDataFactoryOzone::GetDefaultCursorInternal( |
92 int type) { | 92 CursorType type) { |
93 if (type == kCursorNone) | 93 if (type == CursorType::kNone) |
94 return nullptr; // nullptr is used for hidden cursor. | 94 return nullptr; // nullptr is used for hidden cursor. |
95 | 95 |
96 if (!default_cursors_.count(type)) { | 96 if (!default_cursors_.count(type)) { |
97 // We hold a ref forever because clients do not do refcounting for default | 97 // We hold a ref forever because clients do not do refcounting for default |
98 // cursors. | 98 // cursors. |
99 scoped_refptr<CursorDataOzone> cursor = | 99 scoped_refptr<CursorDataOzone> cursor = |
100 make_scoped_refptr(new CursorDataOzone(ui::CursorData(type))); | 100 make_scoped_refptr(new CursorDataOzone(ui::CursorData(type))); |
101 default_cursors_[type] = std::move(cursor); | 101 default_cursors_[type] = std::move(cursor); |
102 } | 102 } |
103 | 103 |
104 // Returned owned default cursor for this type. | 104 // Returned owned default cursor for this type. |
105 return default_cursors_[type]; | 105 return default_cursors_[type]; |
106 } | 106 } |
107 | 107 |
108 } // namespace ui | 108 } // namespace ui |
OLD | NEW |