| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef REMOTING_CLIENT_UI_RENDERER_PROXY_H_ | |
| 6 #define REMOTING_CLIENT_UI_RENDERER_PROXY_H_ | |
| 7 | |
| 8 #include "base/memory/ref_counted.h" | |
| 9 #include "base/memory/weak_ptr.h" | |
| 10 #include "base/single_thread_task_runner.h" | |
| 11 | |
| 12 namespace remoting { | |
| 13 | |
| 14 class GlRenderer; | |
| 15 class QueuedTaskPoster; | |
| 16 class ViewMatrix; | |
| 17 | |
| 18 // A class to proxy calls to GlRenderer from one thread to another. | |
| 19 // TODO(yuweih): This should be removed once we have moved Drawables out of | |
| 20 // GlRenderer. | |
| 21 class RendererProxy { | |
| 22 public: | |
| 23 // task_runner: The task runner that |renderer_| should be run on. | |
| 24 RendererProxy(scoped_refptr<base::SingleThreadTaskRunner> task_runner); | |
| 25 ~RendererProxy(); | |
| 26 | |
| 27 // Initialize with the renderer to be proxied. | |
| 28 void Initialize(base::WeakPtr<GlRenderer> renderer); | |
| 29 | |
| 30 void SetTransformation(const ViewMatrix& transformation); | |
| 31 void SetCursorPosition(float x, float y); | |
| 32 void SetCursorVisibility(bool visible); | |
| 33 void StartInputFeedback(float x, float y, float diameter); | |
| 34 | |
| 35 base::WeakPtr<RendererProxy> GetWeakPtr(); | |
| 36 | |
| 37 private: | |
| 38 // Runs the |task| on the thread of |task_runner_|. All tasks run with | |
| 39 // |needs_synchronization| set to true inside the same tick will be run on | |
| 40 // |task_runner_| within the same tick. | |
| 41 void RunTaskOnProperThread(const base::Closure& task, | |
| 42 bool needs_synchronization); | |
| 43 | |
| 44 base::WeakPtr<GlRenderer> renderer_; | |
| 45 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
| 46 std::unique_ptr<remoting::QueuedTaskPoster> ui_task_poster_; | |
| 47 | |
| 48 base::WeakPtrFactory<RendererProxy> weak_factory_; | |
| 49 | |
| 50 // RenderStubProxy is neither copyable nor movable. | |
| 51 RendererProxy(const RendererProxy&) = delete; | |
| 52 RendererProxy& operator=(const RendererProxy&) = delete; | |
| 53 }; | |
| 54 | |
| 55 } // namespace remoting | |
| 56 #endif // REMOTING_CLIENT_UI_RENDERER_PROXY_H_ | |
| OLD | NEW |