[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / ui / base / cursor / ozone / bitmap_cursor_factory_ozone.h
blob916e1293f0a249d309b5293cfb6aa801ba89cca9
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
3 // found in the LICENSE file.
5 #ifndef UI_BASE_CURSOR_OZONE_BITMAP_CURSOR_FACTORY_OZONE_H_
6 #define UI_BASE_CURSOR_OZONE_BITMAP_CURSOR_FACTORY_OZONE_H_
8 #include <map>
10 #include "base/memory/ref_counted.h"
11 #include "third_party/skia/include/core/SkBitmap.h"
12 #include "ui/base/cursor/cursor.h"
13 #include "ui/base/ui_base_export.h"
14 #include "ui/gfx/geometry/point.h"
15 #include "ui/ozone/public/cursor_factory_ozone.h"
17 namespace ui {
19 // A cursor that is an SkBitmap combined with a gfx::Point hotspot.
20 class UI_BASE_EXPORT BitmapCursorOzone
21 : public base::RefCounted<BitmapCursorOzone> {
22 public:
23 BitmapCursorOzone(const SkBitmap& bitmap, const gfx::Point& hotspot)
24 : bitmap_(bitmap), hotspot_(hotspot) {}
26 const gfx::Point& hotspot() { return hotspot_; }
27 const SkBitmap& bitmap() { return bitmap_; }
29 private:
30 friend class base::RefCounted<BitmapCursorOzone>;
31 ~BitmapCursorOzone() {}
33 SkBitmap bitmap_;
34 gfx::Point hotspot_;
36 DISALLOW_COPY_AND_ASSIGN(BitmapCursorOzone);
39 // CursorFactoryOzone implementation for bitmapped cursors.
41 // This is a base class for platforms where PlatformCursor is an SkBitmap
42 // combined with a gfx::Point for the hotspot.
44 // Subclasses need only implement SetBitmapCursor() as everything else is
45 // implemented here.
46 class UI_BASE_EXPORT BitmapCursorFactoryOzone : public CursorFactoryOzone {
47 public:
48 BitmapCursorFactoryOzone();
49 virtual ~BitmapCursorFactoryOzone();
51 // CursorFactoryOzone:
52 virtual PlatformCursor GetDefaultCursor(int type) OVERRIDE;
53 virtual PlatformCursor CreateImageCursor(const SkBitmap& bitmap,
54 const gfx::Point& hotspot) OVERRIDE;
55 virtual void RefImageCursor(PlatformCursor cursor) OVERRIDE;
56 virtual void UnrefImageCursor(PlatformCursor cursor) OVERRIDE;
57 virtual void SetCursor(gfx::AcceleratedWidget widget,
58 PlatformCursor cursor) OVERRIDE;
60 // Set a bitmap cursor for the given window. This must be overridden by
61 // subclasses. If the cursor is hidden (kCursorNone) then cursor is NULL.
62 virtual void SetBitmapCursor(gfx::AcceleratedWidget window,
63 scoped_refptr<BitmapCursorOzone> cursor);
65 private:
66 // Default cursors are cached & owned by the factory.
67 typedef std::map<int, scoped_refptr<BitmapCursorOzone> > DefaultCursorMap;
68 DefaultCursorMap default_cursors_;
70 DISALLOW_COPY_AND_ASSIGN(BitmapCursorFactoryOzone);
73 } // namespace ui
75 #endif // UI_BASE_CURSOR_OZONE_BITMAP_CURSOR_FACTORY_OZONE_H_