Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_ | 5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_ |
| 6 #define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_ | 6 #define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | |
| 8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| 11 #include "base/threading/thread_checker.h" | |
| 10 #include "components/mus/public/interfaces/compositor_frame.mojom.h" | 12 #include "components/mus/public/interfaces/compositor_frame.mojom.h" |
| 11 #include "mojo/public/cpp/bindings/binding.h" | 13 #include "mojo/public/cpp/bindings/binding.h" |
| 12 #include "mojo/public/cpp/bindings/interface_ptr_info.h" | 14 #include "mojo/public/cpp/bindings/interface_ptr_info.h" |
| 13 | 15 |
| 14 namespace mus { | 16 namespace mus { |
| 15 | 17 |
| 18 class WindowSurfaceBinding; | |
| 16 class WindowSurfaceClient; | 19 class WindowSurfaceClient; |
| 17 class Window; | 20 class Window; |
| 18 | 21 |
| 19 // A WindowSurface is wrapper to simplify submitting CompositorFrames to Views, | 22 // A WindowSurface is wrapper to simplify submitting CompositorFrames to |
| 20 // and receiving ReturnedResources. | 23 // Windows, and receiving ReturnedResources. |
| 21 class WindowSurface : public mojom::SurfaceClient { | 24 class WindowSurface : public mojom::SurfaceClient { |
| 22 public: | 25 public: |
| 26 // static | |
| 27 static scoped_ptr<WindowSurface> Create( | |
| 28 scoped_ptr<WindowSurfaceBinding>* surface_binding); | |
| 29 | |
| 23 ~WindowSurface() override; | 30 ~WindowSurface() override; |
| 24 | 31 |
| 25 // Called to indicate that the current thread has assumed control of this | 32 // Called to indicate that the current thread has assumed control of this |
| 26 // object. | 33 // object. |
| 27 void BindToThread(); | 34 void BindToThread(); |
| 28 | 35 |
| 29 void SubmitCompositorFrame(mojom::CompositorFramePtr frame, | 36 void SubmitCompositorFrame(mojom::CompositorFramePtr frame, |
| 30 const mojo::Closure& callback); | 37 const mojo::Closure& callback); |
| 31 | 38 |
| 32 void set_client(WindowSurfaceClient* client) { client_ = client; } | 39 void set_client(WindowSurfaceClient* client) { client_ = client; } |
| 33 | 40 |
| 34 private: | 41 private: |
| 35 friend class Window; | 42 friend class Window; |
| 36 | 43 |
| 37 WindowSurface(mojo::InterfacePtrInfo<mojom::Surface> surface_info, | 44 WindowSurface(mojo::InterfacePtrInfo<mojom::Surface> surface_info, |
| 38 mojo::InterfaceRequest<mojom::SurfaceClient> client_request); | 45 mojo::InterfaceRequest<mojom::SurfaceClient> client_request); |
| 39 | 46 |
| 40 // SurfaceClient implementation: | 47 // SurfaceClient implementation: |
| 41 void ReturnResources( | 48 void ReturnResources( |
| 42 mojo::Array<mojom::ReturnedResourcePtr> resources) override; | 49 mojo::Array<mojom::ReturnedResourcePtr> resources) override; |
| 43 | 50 |
| 44 WindowSurfaceClient* client_; | 51 WindowSurfaceClient* client_; |
| 45 mojo::InterfacePtrInfo<mojom::Surface> surface_info_; | 52 mojo::InterfacePtrInfo<mojom::Surface> surface_info_; |
| 46 mojo::InterfaceRequest<mojom::SurfaceClient> client_request_; | 53 mojo::InterfaceRequest<mojom::SurfaceClient> client_request_; |
| 47 mojom::SurfacePtr surface_; | 54 mojom::SurfacePtr surface_; |
| 48 scoped_ptr<mojo::Binding<mojom::SurfaceClient>> client_binding_; | 55 scoped_ptr<mojo::Binding<mojom::SurfaceClient>> client_binding_; |
| 49 bool bound_to_thread_; | 56 scoped_ptr<base::ThreadChecker> thread_checker_; |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(WindowSurface); | |
| 59 }; | |
| 60 | |
| 61 class WindowSurfaceBinding { | |
|
sadrul
2015/11/27 21:21:37
Document
Fady Samuel
2015/11/28 21:47:36
Done.
| |
| 62 public: | |
| 63 ~WindowSurfaceBinding(); | |
| 64 | |
| 65 private: | |
| 66 friend class WindowSurface; | |
| 67 friend class Window; | |
| 68 | |
| 69 WindowSurfaceBinding(mojo::InterfaceRequest<mojom::Surface> surface_request, | |
| 70 mojom::SurfaceClientPtr surface_client); | |
| 71 | |
| 72 mojo::InterfaceRequest<mojom::Surface> surface_request_; | |
| 73 mojom::SurfaceClientPtr surface_client_; | |
| 74 | |
| 75 DISALLOW_COPY_AND_ASSIGN(WindowSurfaceBinding); | |
| 50 }; | 76 }; |
| 51 | 77 |
| 52 } // namespace mus | 78 } // namespace mus |
| 53 | 79 |
| 54 #endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_ | 80 #endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_ |
| OLD | NEW |