Add ICU message format support
[chromium-blink-merge.git] / ui / base / cursor / ozone / bitmap_cursor_factory_ozone.h
blob53c599903b6a14c7c85bc229d26015b7f9255bf0
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 BitmapCursorOzone(const std::vector<SkBitmap>& bitmaps,
25 const gfx::Point& hotspot,
26 int frame_delay_ms);
28 const gfx::Point& hotspot();
29 const SkBitmap& bitmap();
31 // For animated cursors.
32 const std::vector<SkBitmap>& bitmaps();
33 int frame_delay_ms();
35 private:
36 friend class base::RefCounted<BitmapCursorOzone>;
37 ~BitmapCursorOzone();
39 std::vector<SkBitmap> bitmaps_;
40 gfx::Point hotspot_;
41 int frame_delay_ms_;
43 DISALLOW_COPY_AND_ASSIGN(BitmapCursorOzone);
46 // CursorFactoryOzone implementation for bitmapped cursors.
48 // This is a base class for platforms where PlatformCursor is an SkBitmap
49 // combined with a gfx::Point for the hotspot.
51 // Subclasses need only implement SetBitmapCursor() as everything else is
52 // implemented here.
53 class UI_BASE_EXPORT BitmapCursorFactoryOzone : public CursorFactoryOzone {
54 public:
55 BitmapCursorFactoryOzone();
56 ~BitmapCursorFactoryOzone() override;
58 // Convert PlatformCursor to BitmapCursorOzone.
59 static scoped_refptr<BitmapCursorOzone> GetBitmapCursor(
60 PlatformCursor platform_cursor);
62 // CursorFactoryOzone:
63 PlatformCursor GetDefaultCursor(int type) override;
64 PlatformCursor CreateImageCursor(const SkBitmap& bitmap,
65 const gfx::Point& hotspot) override;
66 PlatformCursor CreateAnimatedCursor(
67 const std::vector<SkBitmap>& bitmaps,
68 const gfx::Point& hotspot,
69 int frame_delay_ms) override;
70 void RefImageCursor(PlatformCursor cursor) override;
71 void UnrefImageCursor(PlatformCursor cursor) override;
73 private:
74 // Get cached BitmapCursorOzone for a default cursor.
75 scoped_refptr<BitmapCursorOzone> GetDefaultCursorInternal(int type);
77 // Default cursors are cached & owned by the factory.
78 typedef std::map<int, scoped_refptr<BitmapCursorOzone> > DefaultCursorMap;
79 DefaultCursorMap default_cursors_;
81 DISALLOW_COPY_AND_ASSIGN(BitmapCursorFactoryOzone);
84 } // namespace ui
86 #endif // UI_BASE_CURSOR_OZONE_BITMAP_CURSOR_FACTORY_OZONE_H_