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