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_DISPLAY_COMPOSITOR_H_ | 5 #ifndef SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ |
6 #define SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ | 6 #define SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 DisplayCompositor( | 55 DisplayCompositor( |
56 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service, | 56 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service, |
57 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager, | 57 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager, |
58 gpu::ImageFactory* image_factory, | 58 gpu::ImageFactory* image_factory, |
59 cc::mojom::DisplayCompositorRequest request, | 59 cc::mojom::DisplayCompositorRequest request, |
60 cc::mojom::DisplayCompositorClientPtr client); | 60 cc::mojom::DisplayCompositorClientPtr client); |
61 ~DisplayCompositor() override; | 61 ~DisplayCompositor() override; |
62 | 62 |
63 cc::SurfaceManager* manager() { return &manager_; } | 63 cc::SurfaceManager* manager() { return &manager_; } |
64 | 64 |
65 // display_compositor::GpuCompositorFrameSinkDelegate implementation. | |
66 void OnClientConnectionLost(const cc::FrameSinkId& frame_sink_id, | |
67 bool destroy_compositor_frame_sink) override; | |
68 void OnPrivateConnectionLost(const cc::FrameSinkId& frame_sink_id, | |
69 bool destroy_compositor_frame_sink) override; | |
70 | |
71 // cc::mojom::DisplayCompositor implementation: | 65 // cc::mojom::DisplayCompositor implementation: |
72 void CreateRootCompositorFrameSink( | 66 void CreateRootCompositorFrameSink( |
73 const cc::FrameSinkId& frame_sink_id, | 67 const cc::FrameSinkId& frame_sink_id, |
74 gpu::SurfaceHandle surface_handle, | 68 gpu::SurfaceHandle surface_handle, |
75 cc::mojom::MojoCompositorFrameSinkAssociatedRequest request, | 69 cc::mojom::MojoCompositorFrameSinkAssociatedRequest request, |
76 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, | 70 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, |
77 cc::mojom::MojoCompositorFrameSinkClientPtr client, | 71 cc::mojom::MojoCompositorFrameSinkClientPtr client, |
78 cc::mojom::DisplayPrivateAssociatedRequest display_private_request) | 72 cc::mojom::DisplayPrivateAssociatedRequest display_private_request) |
79 override; | 73 override; |
80 void CreateCompositorFrameSink( | 74 void CreateCompositorFrameSink( |
81 const cc::FrameSinkId& frame_sink_id, | 75 const cc::FrameSinkId& frame_sink_id, |
82 cc::mojom::MojoCompositorFrameSinkRequest request, | 76 cc::mojom::MojoCompositorFrameSinkRequest request, |
83 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, | 77 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, |
84 cc::mojom::MojoCompositorFrameSinkClientPtr client) override; | 78 cc::mojom::MojoCompositorFrameSinkClientPtr client) override; |
| 79 void RegisterFrameSinkHierarchy( |
| 80 const cc::FrameSinkId& parent_frame_sink_id, |
| 81 const cc::FrameSinkId& child_frame_sink_id) override; |
| 82 void UnregisterFrameSinkHierarchy( |
| 83 const cc::FrameSinkId& parent_frame_sink_id, |
| 84 const cc::FrameSinkId& child_frame_sink_id) override; |
85 | 85 |
86 private: | 86 private: |
87 std::unique_ptr<cc::Display> CreateDisplay( | 87 std::unique_ptr<cc::Display> CreateDisplay( |
88 const cc::FrameSinkId& frame_sink_id, | 88 const cc::FrameSinkId& frame_sink_id, |
89 gpu::SurfaceHandle surface_handle, | 89 gpu::SurfaceHandle surface_handle, |
90 cc::SyntheticBeginFrameSource* begin_frame_source); | 90 cc::SyntheticBeginFrameSource* begin_frame_source); |
91 | 91 |
92 void CreateCompositorFrameSinkInternal( | |
93 const cc::FrameSinkId& frame_sink_id, | |
94 gpu::SurfaceHandle surface_handle, | |
95 std::unique_ptr<cc::Display> display, | |
96 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source, | |
97 cc::mojom::MojoCompositorFrameSinkRequest request, | |
98 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, | |
99 cc::mojom::MojoCompositorFrameSinkClientPtr client, | |
100 cc::mojom::DisplayPrivateRequest display_private_request); | |
101 | |
102 // It is necessary to pass |frame_sink_id| by value because the id | 92 // It is necessary to pass |frame_sink_id| by value because the id |
103 // is owned by the GpuCompositorFrameSink in the map. When the sink is | 93 // is owned by the GpuCompositorFrameSink in the map. When the sink is |
104 // removed from the map, |frame_sink_id| would also be destroyed if it were a | 94 // removed from the map, |frame_sink_id| would also be destroyed if it were a |
105 // reference. But the map can continue to iterate and try to use it. Passing | 95 // reference. But the map can continue to iterate and try to use it. Passing |
106 // by value avoids this. | 96 // by value avoids this. |
107 void DestroyCompositorFrameSink(cc::FrameSinkId frame_sink_id); | 97 void DestroyCompositorFrameSink(cc::FrameSinkId frame_sink_id); |
108 | 98 |
109 // cc::SurfaceObserver implementation. | 99 // cc::SurfaceObserver implementation. |
110 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override; | 100 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override; |
111 void OnSurfaceDamaged(const cc::SurfaceId& surface_id, | 101 void OnSurfaceDamaged(const cc::SurfaceId& surface_id, |
112 bool* changed) override; | 102 bool* changed) override; |
113 | 103 |
| 104 // display_compositor::GpuCompositorFrameSinkDelegate implementation. |
| 105 void OnClientConnectionLost(const cc::FrameSinkId& frame_sink_id, |
| 106 bool destroy_compositor_frame_sink) override; |
| 107 void OnPrivateConnectionLost(const cc::FrameSinkId& frame_sink_id, |
| 108 bool destroy_compositor_frame_sink) override; |
| 109 |
114 // SurfaceManager should be the first object constructed and the last object | 110 // SurfaceManager should be the first object constructed and the last object |
115 // destroyed in order to ensure that all other objects that depend on it have | 111 // destroyed in order to ensure that all other objects that depend on it have |
116 // access to a valid pointer for the entirety of their liftimes. | 112 // access to a valid pointer for the entirety of their liftimes. |
117 cc::SurfaceManager manager_; | 113 cc::SurfaceManager manager_; |
118 | 114 |
119 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service_; | 115 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service_; |
120 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager_; | 116 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager_; |
121 gpu::ImageFactory* image_factory_; | 117 gpu::ImageFactory* image_factory_; |
122 | 118 |
123 std::unordered_map<cc::FrameSinkId, | 119 std::unordered_map<cc::FrameSinkId, |
124 std::unique_ptr<cc::mojom::MojoCompositorFrameSink>, | 120 std::unique_ptr<cc::mojom::MojoCompositorFrameSink>, |
125 cc::FrameSinkIdHash> | 121 cc::FrameSinkIdHash> |
126 compositor_frame_sinks_; | 122 compositor_frame_sinks_; |
127 | 123 |
128 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 124 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
129 | 125 |
130 base::ThreadChecker thread_checker_; | 126 base::ThreadChecker thread_checker_; |
131 | 127 |
132 cc::mojom::DisplayCompositorClientPtr client_; | 128 cc::mojom::DisplayCompositorClientPtr client_; |
133 mojo::Binding<cc::mojom::DisplayCompositor> binding_; | 129 mojo::Binding<cc::mojom::DisplayCompositor> binding_; |
134 | 130 |
135 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); | 131 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); |
136 }; | 132 }; |
137 | 133 |
138 } // namespace ui | 134 } // namespace ui |
139 | 135 |
140 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ | 136 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ |
OLD | NEW |