| 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 void SetCanvas(Canvas* canvas) override; |
| 39 // state of the cursor to the context of the new canvas. | |
| 40 // If |canvas| is nullptr, nothing will happen when calling Draw(). | |
| 41 void SetCanvas(GlCanvas* canvas); | |
| 42 | 41 |
| 43 void Draw(); | 42 bool Draw() override; |
| 43 |
| 44 base::WeakPtr<Drawable> GetWeakPtr() override; |
| 44 | 45 |
| 45 private: | 46 private: |
| 46 void SetCurrentCursorShape(bool size_changed); | 47 void SetCurrentCursorShape(bool size_changed); |
| 47 | 48 |
| 48 bool visible_ = true; | 49 bool visible_ = true; |
| 49 | 50 |
| 50 std::unique_ptr<GlRenderLayer> layer_; | 51 std::unique_ptr<GlRenderLayer> layer_; |
| 51 | 52 |
| 52 std::unique_ptr<uint8_t[]> current_cursor_data_; | 53 std::unique_ptr<uint8_t[]> current_cursor_data_; |
| 53 int current_cursor_data_size_ = 0; | 54 int current_cursor_data_size_ = 0; |
| 54 int current_cursor_width_ = 0; | 55 int current_cursor_width_ = 0; |
| 55 int current_cursor_height_ = 0; | 56 int current_cursor_height_ = 0; |
| 56 int current_cursor_hotspot_x_ = 0; | 57 int current_cursor_hotspot_x_ = 0; |
| 57 int current_cursor_hotspot_y_ = 0; | 58 int current_cursor_hotspot_y_ = 0; |
| 58 | 59 |
| 59 float cursor_x_ = 0; | 60 float cursor_x_ = 0; |
| 60 float cursor_y_ = 0; | 61 float cursor_y_ = 0; |
| 61 | 62 |
| 63 base::WeakPtrFactory<Drawable> weak_factory_; |
| 64 |
| 62 DISALLOW_COPY_AND_ASSIGN(GlCursor); | 65 DISALLOW_COPY_AND_ASSIGN(GlCursor); |
| 63 }; | 66 }; |
| 64 | 67 |
| 65 } // namespace remoting | 68 } // namespace remoting |
| 66 #endif // REMOTING_CLIENT_DISPLAY_GL_CURSOR_H_ | 69 #endif // REMOTING_CLIENT_DISPLAY_GL_CURSOR_H_ |
| OLD | NEW |