Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(711)

Unified Diff: ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc

Issue 540103002: ozone: Handle default cursors with no bitmap in BitmapCursorFactoryOzone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc
diff --git a/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc b/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc
index 728c17475275003701a733d264421351a2e917e8..394ec7ab44503c6b0edbc44f7a3f60f8c104af4d 100644
--- a/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc
+++ b/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc
@@ -20,6 +20,14 @@ PlatformCursor ToPlatformCursor(BitmapCursorOzone* cursor) {
return static_cast<PlatformCursor>(cursor);
}
+scoped_refptr<BitmapCursorOzone> CreateDefaultBitmapCursor(int type) {
+ SkBitmap bitmap;
+ gfx::Point hotspot;
+ if (GetCursorBitmap(type, &bitmap, &hotspot))
+ return new BitmapCursorOzone(bitmap, hotspot);
+ return NULL;
+}
+
} // namespace
BitmapCursorFactoryOzone::BitmapCursorFactoryOzone() {}
@@ -33,19 +41,7 @@ scoped_refptr<BitmapCursorOzone> BitmapCursorFactoryOzone::GetBitmapCursor(
}
PlatformCursor BitmapCursorFactoryOzone::GetDefaultCursor(int type) {
- if (type == kCursorNone)
- return NULL; // NULL is used for hidden cursor.
-
- if (!default_cursors_.count(type)) {
- // Create new owned image cursor from default aura bitmap for this type.
- SkBitmap bitmap;
- gfx::Point hotspot;
- CHECK(GetCursorBitmap(type, &bitmap, &hotspot));
- default_cursors_[type] = new BitmapCursorOzone(bitmap, hotspot);
- }
-
- // Returned owned default cursor for this type.
- return default_cursors_[type];
+ return GetDefaultCursorInternal(type);
}
PlatformCursor BitmapCursorFactoryOzone::CreateImageCursor(
@@ -64,4 +60,23 @@ void BitmapCursorFactoryOzone::UnrefImageCursor(PlatformCursor cursor) {
ToBitmapCursorOzone(cursor)->Release();
}
+scoped_refptr<BitmapCursorOzone>
+BitmapCursorFactoryOzone::GetDefaultCursorInternal(int type) {
+ if (type == kCursorNone)
+ return NULL; // NULL is used for hidden cursor.
+
+ if (!default_cursors_.count(type)) {
+ // Create new image cursor from default aura bitmap for this type. We hold a
+ // ref forever because clients do not do refcounting for default cursors.
+ scoped_refptr<BitmapCursorOzone> cursor = CreateDefaultBitmapCursor(type);
+ if (!cursor && type != kCursorPointer)
+ cursor = GetDefaultCursorInternal(kCursorPointer);
+ DCHECK(cursor) << "Failed to load default cursor bitmap";
+ default_cursors_[type] = cursor;
+ }
+
+ // Returned owned default cursor for this type.
+ return default_cursors_[type];
+}
+
} // namespace ui
« no previous file with comments | « ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698