| 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> |
| 11 #include <unordered_map> | 11 #include <unordered_map> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 16 #include "cc/ipc/display_compositor.mojom.h" | 16 #include "cc/ipc/display_compositor.mojom.h" |
| 17 #include "cc/surfaces/frame_sink_id.h" | 17 #include "cc/surfaces/frame_sink_id.h" |
| 18 #include "cc/surfaces/local_frame_id.h" | 18 #include "cc/surfaces/local_frame_id.h" |
| 19 #include "cc/surfaces/surface_id.h" | 19 #include "cc/surfaces/surface_id.h" |
| 20 #include "cc/surfaces/surface_manager.h" | 20 #include "cc/surfaces/surface_manager.h" |
| 21 #include "cc/surfaces/surface_observer.h" | 21 #include "cc/surfaces/surface_observer.h" |
| 22 #include "components/display_compositor/gpu_compositor_frame_sink_delegate.h" |
| 22 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 23 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
| 23 #include "gpu/ipc/common/surface_handle.h" | 24 #include "gpu/ipc/common/surface_handle.h" |
| 24 #include "gpu/ipc/in_process_command_buffer.h" | 25 #include "gpu/ipc/in_process_command_buffer.h" |
| 25 #include "ipc/ipc_channel_handle.h" | 26 #include "ipc/ipc_channel_handle.h" |
| 26 #include "mojo/public/cpp/bindings/binding.h" | 27 #include "mojo/public/cpp/bindings/binding.h" |
| 27 | 28 |
| 28 namespace gpu { | 29 namespace gpu { |
| 29 class GpuMemoryBufferManager; | 30 class GpuMemoryBufferManager; |
| 30 class ImageFactory; | 31 class ImageFactory; |
| 31 } | 32 } |
| 32 | 33 |
| 33 namespace cc { | 34 namespace cc { |
| 34 class Display; | 35 class Display; |
| 35 class SurfaceManager; | 36 class SurfaceManager; |
| 36 class SyntheticBeginFrameSource; | 37 class SyntheticBeginFrameSource; |
| 37 } | 38 } |
| 38 | 39 |
| 40 namespace display_compositor { |
| 41 class GpuCompositorFrameSink; |
| 42 } |
| 43 |
| 39 namespace ui { | 44 namespace ui { |
| 40 | 45 |
| 41 class GpuCompositorFrameSink; | |
| 42 | |
| 43 // The DisplayCompositor object is an object global to the Window Server app | 46 // The DisplayCompositor object is an object global to the Window Server app |
| 44 // that holds the SurfaceServer and allocates new Surfaces namespaces. | 47 // that holds the SurfaceServer and allocates new Surfaces namespaces. |
| 45 // This object lives on the main thread of the Window Server. | 48 // This object lives on the main thread of the Window Server. |
| 46 // TODO(rjkroege, fsamuel): This object will need to change to support multiple | 49 // TODO(rjkroege, fsamuel): This object will need to change to support multiple |
| 47 // displays. | 50 // displays. |
| 48 class DisplayCompositor : public cc::SurfaceObserver, | 51 class DisplayCompositor |
| 49 public cc::mojom::DisplayCompositor { | 52 : public cc::SurfaceObserver, |
| 53 public display_compositor::GpuCompositorFrameSinkDelegate, |
| 54 public cc::mojom::DisplayCompositor { |
| 50 public: | 55 public: |
| 51 DisplayCompositor( | 56 DisplayCompositor( |
| 52 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service, | 57 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service, |
| 53 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager, | 58 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager, |
| 54 gpu::ImageFactory* image_factory, | 59 gpu::ImageFactory* image_factory, |
| 55 cc::mojom::DisplayCompositorRequest request, | 60 cc::mojom::DisplayCompositorRequest request, |
| 56 cc::mojom::DisplayCompositorClientPtr client); | 61 cc::mojom::DisplayCompositorClientPtr client); |
| 57 ~DisplayCompositor() override; | 62 ~DisplayCompositor() override; |
| 58 | 63 |
| 59 cc::SurfaceManager* manager() { return &manager_; } | 64 cc::SurfaceManager* manager() { return &manager_; } |
| 60 | 65 |
| 61 // Adds surface references. For each reference added, this will remove the | 66 // display_compositor::GpuCompositorFrameSinkDelegate implementation. |
| 62 // temporary reference to the child surface if one exists. | 67 void OnClientConnectionLost(const cc::FrameSinkId& frame_sink_id, |
| 63 void AddSurfaceReferences( | 68 bool destroy_compositor_frame_sink) override; |
| 64 const std::vector<cc::SurfaceReference>& references); | 69 void OnPrivateConnectionLost(const cc::FrameSinkId& frame_sink_id, |
| 65 | 70 bool destroy_compositor_frame_sink) override; |
| 66 // Removes surface references. | |
| 67 void RemoveSurfaceReferences( | |
| 68 const std::vector<cc::SurfaceReference>& references); | |
| 69 | |
| 70 // We must avoid destroying a GpuCompositorFrameSink until both the display | |
| 71 // compositor host and the client drop their connection to avoid getting into | |
| 72 // a state where surfaces references are inconsistent. | |
| 73 void OnCompositorFrameSinkClientConnectionLost( | |
| 74 const cc::FrameSinkId& frame_sink_id, | |
| 75 bool destroy_compositor_frame_sink); | |
| 76 void OnCompositorFrameSinkPrivateConnectionLost( | |
| 77 const cc::FrameSinkId& frame_sink_id, | |
| 78 bool destroy_compositor_frame_sink); | |
| 79 | 71 |
| 80 // cc::mojom::DisplayCompositor implementation: | 72 // cc::mojom::DisplayCompositor implementation: |
| 81 void CreateDisplayCompositorFrameSink( | 73 void CreateDisplayCompositorFrameSink( |
| 82 const cc::FrameSinkId& frame_sink_id, | 74 const cc::FrameSinkId& frame_sink_id, |
| 83 gpu::SurfaceHandle surface_handle, | 75 gpu::SurfaceHandle surface_handle, |
| 84 cc::mojom::MojoCompositorFrameSinkAssociatedRequest request, | 76 cc::mojom::MojoCompositorFrameSinkAssociatedRequest request, |
| 85 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, | 77 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, |
| 86 cc::mojom::MojoCompositorFrameSinkClientPtr client, | 78 cc::mojom::MojoCompositorFrameSinkClientPtr client, |
| 87 cc::mojom::DisplayPrivateAssociatedRequest display_private_request) | 79 cc::mojom::DisplayPrivateAssociatedRequest display_private_request) |
| 88 override; | 80 override; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 cc::SurfaceManager manager_; | 113 cc::SurfaceManager manager_; |
| 122 | 114 |
| 123 // Will normally point to |manager_| as it provides the interface. For tests | 115 // Will normally point to |manager_| as it provides the interface. For tests |
| 124 // it will be swapped out with a mock implementation. | 116 // it will be swapped out with a mock implementation. |
| 125 cc::SurfaceReferenceManager* reference_manager_; | 117 cc::SurfaceReferenceManager* reference_manager_; |
| 126 | 118 |
| 127 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service_; | 119 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service_; |
| 128 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager_; | 120 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager_; |
| 129 gpu::ImageFactory* image_factory_; | 121 gpu::ImageFactory* image_factory_; |
| 130 | 122 |
| 131 std::unordered_map<cc::FrameSinkId, | 123 std::unordered_map< |
| 132 std::unique_ptr<GpuCompositorFrameSink>, | 124 cc::FrameSinkId, |
| 133 cc::FrameSinkIdHash> | 125 std::unique_ptr<display_compositor::GpuCompositorFrameSink>, |
| 126 cc::FrameSinkIdHash> |
| 134 compositor_frame_sinks_; | 127 compositor_frame_sinks_; |
| 135 | 128 |
| 136 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 129 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 137 | 130 |
| 138 base::ThreadChecker thread_checker_; | 131 base::ThreadChecker thread_checker_; |
| 139 | 132 |
| 140 cc::mojom::DisplayCompositorClientPtr client_; | 133 cc::mojom::DisplayCompositorClientPtr client_; |
| 141 mojo::Binding<cc::mojom::DisplayCompositor> binding_; | 134 mojo::Binding<cc::mojom::DisplayCompositor> binding_; |
| 142 | 135 |
| 143 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); | 136 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); |
| 144 }; | 137 }; |
| 145 | 138 |
| 146 } // namespace ui | 139 } // namespace ui |
| 147 | 140 |
| 148 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ | 141 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ |
| OLD | NEW |