| 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_DESKTOP_H_ | 5 #ifndef REMOTING_CLIENT_DISPLAY_GL_DESKTOP_H_ |
| 6 #define REMOTING_CLIENT_DISPLAY_GL_DESKTOP_H_ | 6 #define REMOTING_CLIENT_DISPLAY_GL_DESKTOP_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/threading/thread_checker.h" |
| 14 #include "remoting/client/display/drawable.h" |
| 12 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 15 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
| 13 | 16 |
| 14 namespace webrtc { | 17 namespace webrtc { |
| 15 class DesktopFrame; | 18 class DesktopFrame; |
| 16 } // namespace webrtc | 19 } // namespace webrtc |
| 17 | 20 |
| 18 namespace remoting { | 21 namespace remoting { |
| 19 | 22 |
| 20 class GlCanvas; | 23 class Canvas; |
| 21 | 24 |
| 22 // This class draws the desktop on the canvas. | 25 // This class draws the desktop on the canvas. |
| 23 class GlDesktop { | 26 class GlDesktop : public Drawable { |
| 24 public: | 27 public: |
| 25 GlDesktop(); | 28 GlDesktop(); |
| 26 virtual ~GlDesktop(); | 29 ~GlDesktop() override; |
| 27 | 30 |
| 28 // |frame| can be either a full frame or updated regions only frame. | 31 // |frame| can be either a full frame or updated regions only frame. |
| 29 void SetVideoFrame(const webrtc::DesktopFrame& frame); | 32 void SetVideoFrame(const webrtc::DesktopFrame& frame); |
| 30 | 33 |
| 31 // Sets the canvas on which the desktop will be drawn. Caller must feed a | 34 // Drawable implementation. |
| 32 // full desktop frame after calling this function. | 35 void SetCanvas(base::WeakPtr<Canvas> canvas) override; |
| 33 // If |canvas| is nullptr, nothing will happen when calling Draw(). | 36 bool Draw() override; |
| 34 void SetCanvas(GlCanvas* canvas); | 37 int ZIndex() override; |
| 35 | 38 base::WeakPtr<Drawable> GetWeakPtr() override; |
| 36 // Draws the desktop on the canvas. | |
| 37 void Draw(); | |
| 38 | 39 |
| 39 private: | 40 private: |
| 40 struct GlDesktopTextureContainer; | 41 struct GlDesktopTextureContainer; |
| 41 | 42 |
| 42 void ReallocateTextures(const webrtc::DesktopSize& size); | 43 void ReallocateTextures(const webrtc::DesktopSize& size); |
| 43 | 44 |
| 44 std::vector<std::unique_ptr<GlDesktopTextureContainer>> textures_; | 45 std::vector<std::unique_ptr<GlDesktopTextureContainer>> textures_; |
| 45 | 46 |
| 46 webrtc::DesktopSize last_desktop_size_; | 47 webrtc::DesktopSize last_desktop_size_; |
| 47 int max_texture_size_ = 0; | 48 int max_texture_size_ = 0; |
| 48 GlCanvas* canvas_ = nullptr; | 49 base::WeakPtr<Canvas> canvas_ = nullptr; |
| 50 base::ThreadChecker thread_checker_; |
| 51 base::WeakPtrFactory<Drawable> weak_factory_; |
| 49 | 52 |
| 50 DISALLOW_COPY_AND_ASSIGN(GlDesktop); | 53 DISALLOW_COPY_AND_ASSIGN(GlDesktop); |
| 51 }; | 54 }; |
| 52 | 55 |
| 53 } // namespace remoting | 56 } // namespace remoting |
| 54 | 57 |
| 55 #endif // REMOTING_CLIENT_DISPLAY_GL_DESKTOP_H_ | 58 #endif // REMOTING_CLIENT_DISPLAY_GL_DESKTOP_H_ |
| OLD | NEW |