| 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 COMPONENTS_FRAME_SINKS_DISPLAY_COMPOSITOR_H_ |
| 6 #define SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ | 6 #define COMPONENTS_FRAME_SINKS_DISPLAY_COMPOSITOR_H_ |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | 7 |
| 10 #include <memory> | 8 #include <memory> |
| 11 #include <unordered_map> | 9 #include <unordered_map> |
| 12 #include <vector> | |
| 13 | 10 |
| 14 #include "base/macros.h" | 11 #include "base/macros.h" |
| 15 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
| 16 #include "cc/ipc/display_compositor.mojom.h" | 13 #include "cc/ipc/display_compositor.mojom.h" |
| 17 #include "cc/surfaces/frame_sink_id.h" | 14 #include "cc/surfaces/frame_sink_id.h" |
| 18 #include "cc/surfaces/local_surface_id.h" | |
| 19 #include "cc/surfaces/surface_id.h" | |
| 20 #include "cc/surfaces/surface_manager.h" | 15 #include "cc/surfaces/surface_manager.h" |
| 21 #include "cc/surfaces/surface_observer.h" | 16 #include "cc/surfaces/surface_observer.h" |
| 22 #include "components/display_compositor/gpu_compositor_frame_sink_delegate.h" | 17 #include "components/frame_sinks/frame_sinks_export.h" |
| 18 #include "components/frame_sinks/gpu_compositor_frame_sink_delegate.h" |
| 23 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 19 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
| 24 #include "gpu/ipc/common/surface_handle.h" | 20 #include "gpu/ipc/common/surface_handle.h" |
| 25 #include "gpu/ipc/in_process_command_buffer.h" | 21 #include "gpu/ipc/in_process_command_buffer.h" |
| 26 #include "ipc/ipc_channel_handle.h" | |
| 27 #include "mojo/public/cpp/bindings/binding.h" | 22 #include "mojo/public/cpp/bindings/binding.h" |
| 28 | 23 |
| 29 namespace gpu { | 24 namespace gpu { |
| 30 class GpuMemoryBufferManager; | 25 class GpuMemoryBufferManager; |
| 31 class ImageFactory; | 26 class ImageFactory; |
| 32 } | 27 } |
| 33 | 28 |
| 34 namespace cc { | 29 namespace cc { |
| 35 class Display; | 30 class Display; |
| 36 class SyntheticBeginFrameSource; | 31 class SyntheticBeginFrameSource; |
| 37 } | 32 } |
| 38 | 33 |
| 39 namespace display_compositor { | 34 namespace frame_sinks { |
| 40 class GpuCompositorFrameSink; | |
| 41 } | |
| 42 | |
| 43 namespace ui { | |
| 44 | 35 |
| 45 // The DisplayCompositor object is an object global to the Window Server app | 36 // The DisplayCompositor object is an object global to the Window Server app |
| 46 // that holds the SurfaceServer and allocates new Surfaces namespaces. | 37 // that holds the SurfaceServer and allocates new Surfaces namespaces. |
| 47 // This object lives on the main thread of the Window Server. | 38 // This object lives on the main thread of the Window Server. |
| 48 // TODO(rjkroege, fsamuel): This object will need to change to support multiple | 39 class FRAME_SINKS_EXPORT DisplayCompositor |
| 49 // displays. | |
| 50 class DisplayCompositor | |
| 51 : public cc::SurfaceObserver, | 40 : public cc::SurfaceObserver, |
| 52 public display_compositor::GpuCompositorFrameSinkDelegate, | 41 public GpuCompositorFrameSinkDelegate, |
| 53 public cc::mojom::DisplayCompositor { | 42 public cc::mojom::DisplayCompositor { |
| 54 public: | 43 public: |
| 55 DisplayCompositor( | 44 DisplayCompositor( |
| 56 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service, | 45 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service, |
| 57 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager, | 46 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager, |
| 58 gpu::ImageFactory* image_factory, | 47 gpu::ImageFactory* image_factory, |
| 59 cc::mojom::DisplayCompositorRequest request, | 48 cc::mojom::DisplayCompositorRequest request, |
| 60 cc::mojom::DisplayCompositorClientPtr client); | 49 cc::mojom::DisplayCompositorClientPtr client); |
| 61 ~DisplayCompositor() override; | 50 ~DisplayCompositor() override; |
| 62 | 51 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // removed from the map, |frame_sink_id| would also be destroyed if it were a | 84 // removed from the map, |frame_sink_id| would also be destroyed if it were a |
| 96 // reference. But the map can continue to iterate and try to use it. Passing | 85 // reference. But the map can continue to iterate and try to use it. Passing |
| 97 // by value avoids this. | 86 // by value avoids this. |
| 98 void DestroyCompositorFrameSink(cc::FrameSinkId frame_sink_id); | 87 void DestroyCompositorFrameSink(cc::FrameSinkId frame_sink_id); |
| 99 | 88 |
| 100 // cc::SurfaceObserver implementation. | 89 // cc::SurfaceObserver implementation. |
| 101 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override; | 90 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override; |
| 102 void OnSurfaceDamaged(const cc::SurfaceId& surface_id, | 91 void OnSurfaceDamaged(const cc::SurfaceId& surface_id, |
| 103 bool* changed) override; | 92 bool* changed) override; |
| 104 | 93 |
| 105 // display_compositor::GpuCompositorFrameSinkDelegate implementation. | 94 // GpuCompositorFrameSinkDelegate implementation. |
| 106 void OnClientConnectionLost(const cc::FrameSinkId& frame_sink_id, | 95 void OnClientConnectionLost(const cc::FrameSinkId& frame_sink_id, |
| 107 bool destroy_compositor_frame_sink) override; | 96 bool destroy_compositor_frame_sink) override; |
| 108 void OnPrivateConnectionLost(const cc::FrameSinkId& frame_sink_id, | 97 void OnPrivateConnectionLost(const cc::FrameSinkId& frame_sink_id, |
| 109 bool destroy_compositor_frame_sink) override; | 98 bool destroy_compositor_frame_sink) override; |
| 110 | 99 |
| 111 // SurfaceManager should be the first object constructed and the last object | 100 // SurfaceManager should be the first object constructed and the last object |
| 112 // destroyed in order to ensure that all other objects that depend on it have | 101 // destroyed in order to ensure that all other objects that depend on it have |
| 113 // access to a valid pointer for the entirety of their liftimes. | 102 // access to a valid pointer for the entirety of their liftimes. |
| 114 cc::SurfaceManager manager_; | 103 cc::SurfaceManager manager_; |
| 115 | 104 |
| 116 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service_; | 105 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service_; |
| 117 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager_; | 106 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager_; |
| 118 gpu::ImageFactory* image_factory_; | 107 gpu::ImageFactory* image_factory_; |
| 119 | 108 |
| 120 std::unordered_map<cc::FrameSinkId, | 109 std::unordered_map<cc::FrameSinkId, |
| 121 std::unique_ptr<cc::mojom::MojoCompositorFrameSink>, | 110 std::unique_ptr<cc::mojom::MojoCompositorFrameSink>, |
| 122 cc::FrameSinkIdHash> | 111 cc::FrameSinkIdHash> |
| 123 compositor_frame_sinks_; | 112 compositor_frame_sinks_; |
| 124 | 113 |
| 125 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 114 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 126 | 115 |
| 127 base::ThreadChecker thread_checker_; | 116 base::ThreadChecker thread_checker_; |
| 128 | 117 |
| 129 cc::mojom::DisplayCompositorClientPtr client_; | 118 cc::mojom::DisplayCompositorClientPtr client_; |
| 130 mojo::Binding<cc::mojom::DisplayCompositor> binding_; | 119 mojo::Binding<cc::mojom::DisplayCompositor> binding_; |
| 131 | 120 |
| 132 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); | 121 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); |
| 133 }; | 122 }; |
| 134 | 123 |
| 135 } // namespace ui | 124 } // namespace frame_sinks |
| 136 | 125 |
| 137 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ | 126 #endif // COMPONENTS_FRAME_SINKS_DISPLAY_COMPOSITOR_H_ |
| OLD | NEW |