diff options
author | spang@chromium.org <spang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-24 19:29:45 +0000 |
---|---|---|
committer | spang@chromium.org <spang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-24 19:29:45 +0000 |
commit | 085e0a1102bbe182369aed6c9dfe206ed6320b8c (patch) | |
tree | ed22f44c4995112201cc7dc9640bbba28c7a74a2 /ui | |
parent | 602b031ddfca16a43e5e8610004ea1afa3215549 (diff) | |
download | chromium_src-085e0a1102bbe182369aed6c9dfe206ed6320b8c.zip chromium_src-085e0a1102bbe182369aed6c9dfe206ed6320b8c.tar.gz chromium_src-085e0a1102bbe182369aed6c9dfe206ed6320b8c.tar.bz2 |
ozone: Add default cursor support to BitmapCursorFactoryOzone
This uses the aura bitmap cursors as the default cursors.
TEST=content_shell --ozone-platform=dri
BUG=252315
Review URL: https://codereview.chromium.org/208643005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258990 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc | 16 | ||||
-rw-r--r-- | ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h | 11 |
2 files changed, 24 insertions, 3 deletions
diff --git a/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc b/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc index 4472023..c24c80f 100644 --- a/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc +++ b/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc @@ -5,6 +5,8 @@ #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" #include "base/logging.h" +#include "third_party/skia/include/core/SkBitmap.h" +#include "ui/base/cursor/cursors_aura.h" namespace ui { @@ -27,9 +29,17 @@ BitmapCursorFactoryOzone::~BitmapCursorFactoryOzone() {} PlatformCursor BitmapCursorFactoryOzone::GetDefaultCursor(int type) { if (type == kCursorNone) return NULL; // NULL is used for hidden cursor. - // TODO(spang): Use ChromeOS cursor bitmaps as default cursors. - LOG(FATAL) << "default cursors not yet supported"; - return NULL; // not reached + + 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]; } PlatformCursor BitmapCursorFactoryOzone::CreateImageCursor( diff --git a/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h b/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h index 88b2404..aef4d7ce 100644 --- a/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h +++ b/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h @@ -5,6 +5,8 @@ #ifndef UI_BASE_CURSOR_OZONE_BITMAP_CURSOR_FACTORY_OZONE_H_ #define UI_BASE_CURSOR_OZONE_BITMAP_CURSOR_FACTORY_OZONE_H_ +#include <map> + #include "base/memory/ref_counted.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/cursor/cursor.h" @@ -30,6 +32,8 @@ class UI_BASE_EXPORT BitmapCursorOzone SkBitmap bitmap_; gfx::Point hotspot_; + + DISALLOW_COPY_AND_ASSIGN(BitmapCursorOzone); }; // CursorFactoryOzone implementation for bitmapped cursors. @@ -57,6 +61,13 @@ class UI_BASE_EXPORT BitmapCursorFactoryOzone : public CursorFactoryOzone { // subclasses. If the cursor is hidden (kCursorNone) then cursor is NULL. virtual void SetBitmapCursor(gfx::AcceleratedWidget window, scoped_refptr<BitmapCursorOzone> cursor); + + private: + // Default cursors are cached & owned by the factory. + typedef std::map<int, scoped_refptr<BitmapCursorOzone> > DefaultCursorMap; + DefaultCursorMap default_cursors_; + + DISALLOW_COPY_AND_ASSIGN(BitmapCursorFactoryOzone); }; } // namespace ui |