OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 REMOTING_CLIENT_DISPLAY_GL_CURSOR_H_ | 5 #ifndef REMOTING_CLIENT_DISPLAY_GL_CURSOR_H_ |
6 #define REMOTING_CLIENT_DISPLAY_GL_CURSOR_H_ | 6 #define REMOTING_CLIENT_DISPLAY_GL_CURSOR_H_ |
7 | 7 |
8 #include <array> | 8 #include <array> |
9 #include <cstdint> | 9 #include <cstdint> |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/weak_ptr.h" | |
14 #include "remoting/client/display/drawable.h" | |
13 | 15 |
14 namespace remoting { | 16 namespace remoting { |
15 | 17 |
16 namespace protocol { | 18 namespace protocol { |
17 class CursorShapeInfo; | 19 class CursorShapeInfo; |
18 } // namespace protocol | 20 } // namespace protocol |
19 | 21 |
20 class GlCanvas; | 22 class Canvas; |
21 class GlRenderLayer; | 23 class GlRenderLayer; |
22 | 24 |
23 // This class draws the cursor on the canvas. | 25 // This class draws the cursor on the canvas. |
24 class GlCursor { | 26 class GlCursor : public Drawable { |
25 public: | 27 public: |
26 GlCursor(); | 28 GlCursor(); |
27 ~GlCursor(); | 29 ~GlCursor() override; |
28 | 30 |
29 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape); | 31 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape); |
30 | 32 |
31 // Sets the cursor hotspot positions. Does nothing if the cursor shape or the | 33 // Sets the cursor hotspot positions. Does nothing if the cursor shape or the |
32 // canvas size has not been set. | 34 // canvas size has not been set. |
33 void SetCursorPosition(float x, float y); | 35 void SetCursorPosition(float x, float y); |
34 | 36 |
35 // Draw() will do nothing if cursor is not visible. | 37 // Draw() will do nothing if cursor is not visible. |
36 void SetCursorVisible(bool visible); | 38 void SetCursorVisible(bool visible); |
37 | 39 |
38 // Sets the canvas on which the cursor will be drawn. Resumes the current | 40 // Sets the canvas on which the cursor will be drawn. Resumes the current |
39 // state of the cursor to the context of the new canvas. | 41 // state of the cursor to the context of the new canvas. |
40 // If |canvas| is nullptr, nothing will happen when calling Draw(). | 42 // If |canvas| is nullptr, nothing will happen when calling Draw(). |
41 void SetCanvas(GlCanvas* canvas); | 43 void SetCanvas(Canvas* canvas) override; |
42 | 44 |
joedow
2017/01/10 00:19:44
smoosh the overrides together, remove the duplicat
nicholss
2017/01/10 21:43:10
Done.
| |
43 void Draw(); | 45 bool Draw() override; |
46 base::WeakPtr<Drawable> GetWeakPtr() override; | |
44 | 47 |
45 private: | 48 private: |
46 void SetCurrentCursorShape(bool size_changed); | 49 void SetCurrentCursorShape(bool size_changed); |
47 | 50 |
48 bool visible_ = true; | 51 bool visible_ = true; |
49 | 52 |
50 std::unique_ptr<GlRenderLayer> layer_; | 53 std::unique_ptr<GlRenderLayer> layer_; |
51 | 54 |
52 std::unique_ptr<uint8_t[]> current_cursor_data_; | 55 std::unique_ptr<uint8_t[]> current_cursor_data_; |
53 int current_cursor_data_size_ = 0; | 56 int current_cursor_data_size_ = 0; |
54 int current_cursor_width_ = 0; | 57 int current_cursor_width_ = 0; |
55 int current_cursor_height_ = 0; | 58 int current_cursor_height_ = 0; |
56 int current_cursor_hotspot_x_ = 0; | 59 int current_cursor_hotspot_x_ = 0; |
57 int current_cursor_hotspot_y_ = 0; | 60 int current_cursor_hotspot_y_ = 0; |
58 | 61 |
59 float cursor_x_ = 0; | 62 float cursor_x_ = 0; |
60 float cursor_y_ = 0; | 63 float cursor_y_ = 0; |
61 | 64 |
65 base::WeakPtrFactory<Drawable> weak_factory_; | |
66 | |
62 DISALLOW_COPY_AND_ASSIGN(GlCursor); | 67 DISALLOW_COPY_AND_ASSIGN(GlCursor); |
63 }; | 68 }; |
64 | 69 |
65 } // namespace remoting | 70 } // namespace remoting |
66 #endif // REMOTING_CLIENT_DISPLAY_GL_CURSOR_H_ | 71 #endif // REMOTING_CLIENT_DISPLAY_GL_CURSOR_H_ |
OLD | NEW |