OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SERVICES_UI_WS_THREADED_IMAGE_CURSORS_H_ | 5 #ifndef SERVICES_UI_WS_THREADED_IMAGE_CURSORS_H_ |
6 #define SERVICES_UI_WS_THREADED_IMAGE_CURSORS_H_ | 6 #define SERVICES_UI_WS_THREADED_IMAGE_CURSORS_H_ |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "ui/base/cursor/image_cursors.h" | 9 #include "ui/base/cursor/image_cursors.h" |
10 | 10 |
11 namespace base { | 11 namespace base { |
12 class SingleThreadTaskRunner; | 12 class SingleThreadTaskRunner; |
13 } | 13 } |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 class PlatformWindow; | 16 class PlatformWindow; |
17 | 17 |
18 namespace ws { | 18 namespace ws { |
19 | 19 |
20 // Wrapper around ui::ImageCursors, capable of executing its methods | 20 // Wrapper around ui::ImageCursors, capable of executing its methods |
21 // asynchronously via the provided task runner. | 21 // asynchronously via the provided task runner. |
22 class ThreadedImageCursors { | 22 class ThreadedImageCursors { |
23 public: | 23 public: |
24 // |resource_runner| is the task runner for the thread which can be used to | 24 // |resource_runner| is the task runner for the thread which can be used to |
25 // load resources; |image_cursors_weak_ptr| is the object used to perform | 25 // load resources; |image_cursors_weak_ptr| is the object used to perform |
26 // cursor operations, and should only be dereferenced on |resource_runner|. | 26 // cursor operations, and should only be dereferenced on |resource_runner|. |
27 ThreadedImageCursors( | 27 ThreadedImageCursors( |
28 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_runner, | 28 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_runner, |
29 base::WeakPtr<ui::ImageCursors> image_cursors_weak_ptr); | 29 base::WeakPtr<ui::ImageCursorsHolder> image_cursors_holder_weak_ptr); |
30 ~ThreadedImageCursors(); | 30 ~ThreadedImageCursors(); |
31 | 31 |
32 // Executes ui::ImageCursors::SetDisplay asynchronously. | 32 // Executes ui::ImageCursors::SetDisplay asynchronously. |
33 // Sets the display the cursors are loaded for. |scale_factor| determines the | 33 // Sets the display the cursors are loaded for. |scale_factor| determines the |
34 // size of the image to load. Returns true if the cursor image is reloaded. | 34 // size of the image to load. Returns true if the cursor image is reloaded. |
35 void SetDisplay(const display::Display& display, float scale_factor); | 35 void SetDisplay(const display::Display& display, float scale_factor); |
36 | 36 |
37 // Asynchronously sets the size of the mouse cursor icon. | 37 // Asynchronously sets the size of the mouse cursor icon. |
38 void SetCursorSize(CursorSize cursor_size); | 38 void SetCursorSize(CursorSize cursor_size); |
39 | 39 |
(...skipping 10 matching lines...) Expand all Loading... |
50 private: | 50 private: |
51 // Task runner used for accessing |image_cursors_weak_ptr_. | 51 // Task runner used for accessing |image_cursors_weak_ptr_. |
52 scoped_refptr<base::SingleThreadTaskRunner> resource_task_runner_; | 52 scoped_refptr<base::SingleThreadTaskRunner> resource_task_runner_; |
53 | 53 |
54 // Task runner of the Window Server thread (where this object is created and | 54 // Task runner of the Window Server thread (where this object is created and |
55 // destroyed). | 55 // destroyed). |
56 scoped_refptr<base::SingleThreadTaskRunner> ws_task_runner_; | 56 scoped_refptr<base::SingleThreadTaskRunner> ws_task_runner_; |
57 | 57 |
58 // Weak pointer to the actual ui::ImageCursors object used to perform the | 58 // Weak pointer to the actual ui::ImageCursors object used to perform the |
59 // cursor operations. | 59 // cursor operations. |
60 base::WeakPtr<ui::ImageCursors> image_cursors_weak_ptr_; | 60 base::WeakPtr<ui::ImageCursorsHolder> image_cursors_holder_weak_ptr_; |
61 | 61 |
62 base::WeakPtrFactory<ThreadedImageCursors> weak_ptr_factory_; | 62 base::WeakPtrFactory<ThreadedImageCursors> weak_ptr_factory_; |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(ThreadedImageCursors); | 64 DISALLOW_COPY_AND_ASSIGN(ThreadedImageCursors); |
65 }; | 65 }; |
66 | 66 |
67 } // namespace ws | 67 } // namespace ws |
68 } // namespace ui | 68 } // namespace ui |
69 | 69 |
70 #endif // SERVICES_UI_WS_THREADED_IMAGE_CURSORS_H_ | 70 #endif // SERVICES_UI_WS_THREADED_IMAGE_CURSORS_H_ |
OLD | NEW |