summaryrefslogtreecommitdiffstats
path: root/ui/ozone/public/cursor_factory_ozone.h
blob: 4950a3186ee6fd7911dc7024b8123f8ab5ca73df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_OZONE_PUBLIC_CURSOR_FACTORY_OZONE_H_
#define UI_OZONE_PUBLIC_CURSOR_FACTORY_OZONE_H_

#include <vector>

#include "ui/gfx/native_widget_types.h"
#include "ui/ozone/ozone_base_export.h"

namespace gfx {
class Point;
}

namespace ui {

typedef void* PlatformCursor;

class OZONE_BASE_EXPORT CursorFactoryOzone {
 public:
  CursorFactoryOzone();
  virtual ~CursorFactoryOzone();

  // Returns the singleton instance.
  static CursorFactoryOzone* GetInstance();

  // Return the default cursor of the specified type. The types are listed in
  // ui/base/cursor/cursor.h. Default cursors are managed by the implementation
  // and must live indefinitely; there's no way to know when to free them.
  virtual PlatformCursor GetDefaultCursor(int type);

  // Return a image cursor from the specified image & hotspot. Image cursors
  // are referenced counted and have an initial refcount of 1. Therefore, each
  // CreateImageCursor call must be matched with a call to UnrefImageCursor.
  virtual PlatformCursor CreateImageCursor(const SkBitmap& bitmap,
                                           const gfx::Point& hotspot);

  // Return a animated cursor from the specified image & hotspot. Animated
  // cursors are referenced counted and have an initial refcount of 1.
  // Therefore, each CreateAnimatedCursor call must be matched with a call to
  // UnrefImageCursor.
  virtual PlatformCursor CreateAnimatedCursor(
      const std::vector<SkBitmap>& bitmaps,
      const gfx::Point& hotspot,
      int frame_delay_ms);

  // Increment platform image cursor refcount.
  virtual void RefImageCursor(PlatformCursor cursor);

  // Decrement platform image cursor refcount.
  virtual void UnrefImageCursor(PlatformCursor cursor);

 private:
  static CursorFactoryOzone* impl_;  // not owned
};

}  // namespace ui

#endif  // UI_OZONE_PUBLIC_CURSOR_FACTORY_OZONE_H_