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 SERVICES_UI_PUBLIC_CPP_WINDOW_SURFACE_H_ | 5 #ifndef SERVICES_UI_PUBLIC_CPP_WINDOW_SURFACE_H_ |
6 #define SERVICES_UI_PUBLIC_CPP_WINDOW_SURFACE_H_ | 6 #define SERVICES_UI_PUBLIC_CPP_WINDOW_SURFACE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
14 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" | |
14 #include "mojo/public/cpp/bindings/binding.h" | 15 #include "mojo/public/cpp/bindings/binding.h" |
15 #include "mojo/public/cpp/bindings/interface_ptr_info.h" | 16 #include "mojo/public/cpp/bindings/interface_ptr_info.h" |
16 #include "services/ui/public/interfaces/surface.mojom.h" | 17 #include "services/ui/public/cpp/window_surface_client.h" |
17 | 18 |
18 namespace ui { | 19 namespace ui { |
19 | 20 |
20 class WindowSurfaceBinding; | 21 class WindowSurfaceBinding; |
21 class WindowSurfaceClient; | 22 class WindowMojoCompositorFrameSinkClient; |
22 class Window; | 23 class Window; |
23 | 24 |
24 // A WindowSurface is wrapper to simplify submitting CompositorFrames to | 25 // A WindowSurface is wrapper to simplify submitting CompositorFrames to |
25 // Windows, and receiving ReturnedResources. | 26 // Windows, and receiving ReturnedResources. |
26 class WindowSurface : public mojom::SurfaceClient { | 27 class WindowSurface : public cc::mojom::MojoCompositorFrameSinkClient { |
27 public: | 28 public: |
28 // static | 29 // static |
29 static std::unique_ptr<WindowSurface> Create( | 30 static std::unique_ptr<WindowSurface> Create( |
30 std::unique_ptr<WindowSurfaceBinding>* surface_binding); | 31 std::unique_ptr<WindowSurfaceBinding>* surface_binding); |
31 | 32 |
32 ~WindowSurface() override; | 33 ~WindowSurface() override; |
33 | 34 |
34 // Called to indicate that the current thread has assumed control of this | 35 // Called to indicate that the current thread has assumed control of this |
35 // object. | 36 // object. |
36 void BindToThread(); | 37 void BindToThread(); |
37 | 38 |
38 void SubmitCompositorFrame(cc::CompositorFrame frame, | 39 void SubmitCompositorFrame(cc::CompositorFrame frame); |
39 const base::Closure& callback); | |
40 | 40 |
41 void set_client(WindowSurfaceClient* client) { client_ = client; } | 41 void set_client(WindowSurfaceClient* client) { client_ = client; } |
42 | 42 |
43 private: | 43 private: |
44 friend class Window; | 44 friend class Window; |
45 | 45 |
46 WindowSurface(mojo::InterfacePtrInfo<mojom::Surface> surface_info, | 46 WindowSurface( |
47 mojo::InterfaceRequest<mojom::SurfaceClient> client_request); | 47 mojo::InterfacePtrInfo<cc::mojom::MojoCompositorFrameSink> surface_info, |
rjkroege
2016/10/20 21:33:18
how about a using to make these types less ridicul
Fady Samuel
2016/10/20 23:04:10
Apparently mojo autogenerates one for you. I'll do
| |
48 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSinkClient> | |
49 client_request); | |
48 | 50 |
49 // SurfaceClient implementation: | 51 // MojoCompositorFrameSinkClient implementation: |
50 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | 52 void DidReceiveCompositorFrameAck() override; |
53 void ReclaimResources(const cc::ReturnedResourceArray& resources) override; | |
51 | 54 |
52 WindowSurfaceClient* client_; | 55 WindowSurfaceClient* client_; |
53 mojo::InterfacePtrInfo<mojom::Surface> surface_info_; | 56 mojo::InterfacePtrInfo<cc::mojom::MojoCompositorFrameSink> surface_info_; |
54 mojo::InterfaceRequest<mojom::SurfaceClient> client_request_; | 57 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSinkClient> |
55 mojom::SurfacePtr surface_; | 58 client_request_; |
56 std::unique_ptr<mojo::Binding<mojom::SurfaceClient>> client_binding_; | 59 cc::mojom::MojoCompositorFrameSinkPtr surface_; |
60 std::unique_ptr<mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient>> | |
61 client_binding_; | |
57 std::unique_ptr<base::ThreadChecker> thread_checker_; | 62 std::unique_ptr<base::ThreadChecker> thread_checker_; |
58 | 63 |
59 DISALLOW_COPY_AND_ASSIGN(WindowSurface); | 64 DISALLOW_COPY_AND_ASSIGN(WindowSurface); |
60 }; | 65 }; |
61 | 66 |
62 // A WindowSurfaceBinding is a bundle of mojo interfaces that are to be used by | 67 // A WindowSurfaceBinding is a bundle of mojo interfaces that are to be used by |
63 // or implemented by the Mus window server when passed into | 68 // or implemented by the Mus window server when passed into |
64 // Window::AttachSurface. WindowSurfaceBinding has no standalone functionality. | 69 // Window::AttachSurface. WindowSurfaceBinding has no standalone functionality. |
65 class WindowSurfaceBinding { | 70 class WindowSurfaceBinding { |
66 public: | 71 public: |
67 ~WindowSurfaceBinding(); | 72 ~WindowSurfaceBinding(); |
68 | 73 |
69 private: | 74 private: |
70 friend class WindowSurface; | 75 friend class WindowSurface; |
71 friend class Window; | 76 friend class Window; |
72 | 77 |
73 WindowSurfaceBinding( | 78 WindowSurfaceBinding( |
74 mojo::InterfaceRequest<mojom::Surface> surface_request, | 79 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink> |
75 mojo::InterfacePtrInfo<mojom::SurfaceClient> surface_client); | 80 surface_request, |
81 mojo::InterfacePtrInfo<cc::mojom::MojoCompositorFrameSinkClient> | |
82 surface_client); | |
76 | 83 |
77 mojo::InterfaceRequest<mojom::Surface> surface_request_; | 84 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink> surface_request_; |
78 mojo::InterfacePtrInfo<mojom::SurfaceClient> surface_client_; | 85 mojo::InterfacePtrInfo<cc::mojom::MojoCompositorFrameSinkClient> |
86 surface_client_; | |
79 | 87 |
80 DISALLOW_COPY_AND_ASSIGN(WindowSurfaceBinding); | 88 DISALLOW_COPY_AND_ASSIGN(WindowSurfaceBinding); |
81 }; | 89 }; |
82 | 90 |
83 } // namespace ui | 91 } // namespace ui |
84 | 92 |
85 #endif // SERVICES_UI_PUBLIC_CPP_WINDOW_SURFACE_H_ | 93 #endif // SERVICES_UI_PUBLIC_CPP_WINDOW_SURFACE_H_ |
OLD | NEW |