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