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_SURFACES_MOJO_FRAME_SINK_MANAGER_H_ | 5 #ifndef COMPONENTS_VIZ_FRAME_SINKS_MOJO_FRAME_SINK_MANAGER_H_ |
6 #define SERVICES_UI_SURFACES_MOJO_FRAME_SINK_MANAGER_H_ | 6 #define COMPONENTS_VIZ_FRAME_SINKS_MOJO_FRAME_SINK_MANAGER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <unordered_map> | 11 #include <unordered_map> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "cc/ipc/frame_sink_manager.mojom.h" | 15 #include "cc/ipc/frame_sink_manager.mojom.h" |
16 #include "cc/surfaces/frame_sink_id.h" | 16 #include "cc/surfaces/frame_sink_id.h" |
17 #include "cc/surfaces/surface_manager.h" | 17 #include "cc/surfaces/surface_manager.h" |
18 #include "cc/surfaces/surface_observer.h" | 18 #include "cc/surfaces/surface_observer.h" |
19 #include "components/display_compositor/gpu_compositor_frame_sink_delegate.h" | 19 #include "components/viz/frame_sinks/gpu_compositor_frame_sink_delegate.h" |
20 #include "gpu/ipc/common/surface_handle.h" | 20 #include "gpu/ipc/common/surface_handle.h" |
21 #include "mojo/public/cpp/bindings/binding.h" | 21 #include "mojo/public/cpp/bindings/binding.h" |
22 | 22 |
23 namespace ui { | 23 namespace viz { |
24 | 24 |
25 class DisplayProvider; | 25 class DisplayProvider; |
26 | 26 |
27 // MojoFrameSinkManager manages state associated with CompositorFrameSinks. It | 27 // MojoFrameSinkManager manages state associated with CompositorFrameSinks. It |
28 // provides a Mojo interface to create CompositorFrameSinks, manages BeginFrame | 28 // provides a Mojo interface to create CompositorFrameSinks, manages BeginFrame |
29 // hierarchy and manages surface lifetime. | 29 // hierarchy and manages surface lifetime. |
30 // | 30 // |
31 // This is intended to be created in the viz or GPU process. For mus+ash this | 31 // This is intended to be created in the viz or GPU process. For mus+ash this |
32 // will be true after the mus process split. For non-mus Chrome this will be | 32 // will be true after the mus process split. For non-mus Chrome this will be |
33 // created in the browser process, at least until GPU implementations can be | 33 // created in the browser process, at least until GPU implementations can be |
34 // unified. | 34 // unified. |
35 class MojoFrameSinkManager | 35 class MojoFrameSinkManager : public cc::SurfaceObserver, |
36 : public cc::SurfaceObserver, | 36 public GpuCompositorFrameSinkDelegate, |
37 public display_compositor::GpuCompositorFrameSinkDelegate, | 37 public cc::mojom::FrameSinkManager { |
38 public cc::mojom::FrameSinkManager { | |
39 public: | 38 public: |
40 MojoFrameSinkManager(DisplayProvider* display_provider, | 39 MojoFrameSinkManager(DisplayProvider* display_provider, |
41 cc::mojom::FrameSinkManagerRequest request, | 40 cc::mojom::FrameSinkManagerRequest request, |
42 cc::mojom::FrameSinkManagerClientPtr client); | 41 cc::mojom::FrameSinkManagerClientPtr client); |
43 ~MojoFrameSinkManager() override; | 42 ~MojoFrameSinkManager() override; |
44 | 43 |
45 cc::SurfaceManager* manager() { return &manager_; } | 44 cc::SurfaceManager* manager() { return &manager_; } |
46 | 45 |
47 // cc::mojom::MojoFrameSinkManager implementation: | 46 // cc::mojom::MojoFrameSinkManager implementation: |
48 void CreateRootCompositorFrameSink( | 47 void CreateRootCompositorFrameSink( |
(...skipping 23 matching lines...) Expand all Loading... |
72 // removed from the map, |frame_sink_id| would also be destroyed if it were a | 71 // removed from the map, |frame_sink_id| would also be destroyed if it were a |
73 // reference. But the map can continue to iterate and try to use it. Passing | 72 // reference. But the map can continue to iterate and try to use it. Passing |
74 // by value avoids this. | 73 // by value avoids this. |
75 void DestroyCompositorFrameSink(cc::FrameSinkId frame_sink_id); | 74 void DestroyCompositorFrameSink(cc::FrameSinkId frame_sink_id); |
76 | 75 |
77 // cc::SurfaceObserver implementation. | 76 // cc::SurfaceObserver implementation. |
78 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override; | 77 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override; |
79 void OnSurfaceDamaged(const cc::SurfaceId& surface_id, | 78 void OnSurfaceDamaged(const cc::SurfaceId& surface_id, |
80 bool* changed) override; | 79 bool* changed) override; |
81 | 80 |
82 // display_compositor::GpuCompositorFrameSinkDelegate implementation. | 81 // GpuCompositorFrameSinkDelegate implementation. |
83 void OnClientConnectionLost(const cc::FrameSinkId& frame_sink_id, | 82 void OnClientConnectionLost(const cc::FrameSinkId& frame_sink_id, |
84 bool destroy_compositor_frame_sink) override; | 83 bool destroy_compositor_frame_sink) override; |
85 void OnPrivateConnectionLost(const cc::FrameSinkId& frame_sink_id, | 84 void OnPrivateConnectionLost(const cc::FrameSinkId& frame_sink_id, |
86 bool destroy_compositor_frame_sink) override; | 85 bool destroy_compositor_frame_sink) override; |
87 | 86 |
88 // SurfaceManager should be the first object constructed and the last object | 87 // SurfaceManager should be the first object constructed and the last object |
89 // destroyed in order to ensure that all other objects that depend on it have | 88 // destroyed in order to ensure that all other objects that depend on it have |
90 // access to a valid pointer for the entirety of their lifetimes. | 89 // access to a valid pointer for the entirety of their lifetimes. |
91 cc::SurfaceManager manager_; | 90 cc::SurfaceManager manager_; |
92 | 91 |
93 // Provides a cc::Display for CreateRootCompositorFrameSink(). | 92 // Provides a cc::Display for CreateRootCompositorFrameSink(). |
94 DisplayProvider* const display_provider_; | 93 DisplayProvider* const display_provider_; |
95 | 94 |
96 std::unordered_map<cc::FrameSinkId, | 95 std::unordered_map<cc::FrameSinkId, |
97 std::unique_ptr<cc::mojom::MojoCompositorFrameSink>, | 96 std::unique_ptr<cc::mojom::MojoCompositorFrameSink>, |
98 cc::FrameSinkIdHash> | 97 cc::FrameSinkIdHash> |
99 compositor_frame_sinks_; | 98 compositor_frame_sinks_; |
100 | 99 |
101 base::ThreadChecker thread_checker_; | 100 base::ThreadChecker thread_checker_; |
102 | 101 |
103 cc::mojom::FrameSinkManagerClientPtr client_; | 102 cc::mojom::FrameSinkManagerClientPtr client_; |
104 mojo::Binding<cc::mojom::FrameSinkManager> binding_; | 103 mojo::Binding<cc::mojom::FrameSinkManager> binding_; |
105 | 104 |
106 DISALLOW_COPY_AND_ASSIGN(MojoFrameSinkManager); | 105 DISALLOW_COPY_AND_ASSIGN(MojoFrameSinkManager); |
107 }; | 106 }; |
108 | 107 |
109 } // namespace ui | 108 } // namespace viz |
110 | 109 |
111 #endif // SERVICES_UI_SURFACES_MOJO_FRAME_SINK_MANAGER_H_ | 110 #endif // COMPONENTS_VIZ_FRAME_SINKS_MOJO_FRAME_SINK_MANAGER_H_ |
OLD | NEW |