| 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> |
| 11 #include <unordered_map> |
| 12 #include <vector> |
| 13 |
| 10 #include "base/macros.h" | 14 #include "base/macros.h" |
| 11 #include "cc/ipc/display_compositor.mojom.h" | 15 #include "cc/ipc/display_compositor.mojom.h" |
| 12 #include "cc/surfaces/frame_sink_id.h" | 16 #include "cc/surfaces/frame_sink_id.h" |
| 13 #include "cc/surfaces/local_frame_id.h" | 17 #include "cc/surfaces/local_frame_id.h" |
| 14 #include "cc/surfaces/surface_id.h" | 18 #include "cc/surfaces/surface_id.h" |
| 15 #include "cc/surfaces/surface_manager.h" | 19 #include "cc/surfaces/surface_manager.h" |
| 16 #include "cc/surfaces/surface_observer.h" | 20 #include "cc/surfaces/surface_observer.h" |
| 17 #include "gpu/ipc/common/surface_handle.h" | 21 #include "gpu/ipc/common/surface_handle.h" |
| 18 #include "gpu/ipc/in_process_command_buffer.h" | 22 #include "gpu/ipc/in_process_command_buffer.h" |
| 19 #include "ipc/ipc_channel_handle.h" | 23 #include "ipc/ipc_channel_handle.h" |
| 20 #include "mojo/public/cpp/bindings/binding.h" | 24 #include "mojo/public/cpp/bindings/binding.h" |
| 21 #include "services/ui/surfaces/mus_gpu_memory_buffer_manager.h" | 25 #include "services/ui/surfaces/mus_gpu_memory_buffer_manager.h" |
| 22 | 26 |
| 23 namespace gpu { | 27 namespace gpu { |
| 24 class ImageFactory; | 28 class ImageFactory; |
| 25 } | 29 } |
| 26 | 30 |
| 27 namespace cc { | 31 namespace cc { |
| 28 class SurfaceHittest; | 32 class SurfaceHittest; |
| 29 class SurfaceManager; | 33 class SurfaceManager; |
| 30 } // namespace cc | 34 } // namespace cc |
| 31 | 35 |
| 32 namespace ui { | 36 namespace ui { |
| 33 | 37 |
| 38 namespace test { |
| 39 class DisplayCompositorTest; |
| 40 } |
| 41 |
| 34 class DisplayCompositorClient; | 42 class DisplayCompositorClient; |
| 35 class GpuCompositorFrameSink; | 43 class GpuCompositorFrameSink; |
| 36 class MusGpuMemoryBufferManager; | 44 class MusGpuMemoryBufferManager; |
| 37 | 45 |
| 38 // 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 |
| 39 // that holds the SurfaceServer and allocates new Surfaces namespaces. | 47 // that holds the SurfaceServer and allocates new Surfaces namespaces. |
| 40 // This object lives on the main thread of the Window Server. | 48 // This object lives on the main thread of the Window Server. |
| 41 // 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 |
| 42 // displays. | 50 // displays. |
| 43 class DisplayCompositor : public cc::SurfaceObserver, | 51 class DisplayCompositor : public cc::SurfaceObserver, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 71 // compositor host and the client drop their connection to avoid getting into | 79 // compositor host and the client drop their connection to avoid getting into |
| 72 // a state where surfaces references are inconsistent. | 80 // a state where surfaces references are inconsistent. |
| 73 void OnCompositorFrameSinkClientConnectionLost( | 81 void OnCompositorFrameSinkClientConnectionLost( |
| 74 const cc::FrameSinkId& frame_sink_id, | 82 const cc::FrameSinkId& frame_sink_id, |
| 75 bool destroy_compositor_frame_sink); | 83 bool destroy_compositor_frame_sink); |
| 76 void OnCompositorFrameSinkPrivateConnectionLost( | 84 void OnCompositorFrameSinkPrivateConnectionLost( |
| 77 const cc::FrameSinkId& frame_sink_id, | 85 const cc::FrameSinkId& frame_sink_id, |
| 78 bool destroy_compositor_frame_sink); | 86 bool destroy_compositor_frame_sink); |
| 79 | 87 |
| 80 private: | 88 private: |
| 89 friend class test::DisplayCompositorTest; |
| 90 |
| 91 const cc::SurfaceId& GetRootSurfaceId() const; |
| 81 | 92 |
| 82 // cc::SurfaceObserver implementation. | 93 // cc::SurfaceObserver implementation. |
| 83 void OnSurfaceCreated(const cc::SurfaceId& surface_id, | 94 void OnSurfaceCreated(const cc::SurfaceId& surface_id, |
| 84 const gfx::Size& frame_size, | 95 const gfx::Size& frame_size, |
| 85 float device_scale_factor) override; | 96 float device_scale_factor) override; |
| 86 void OnSurfaceDamaged(const cc::SurfaceId& surface_id, | 97 void OnSurfaceDamaged(const cc::SurfaceId& surface_id, |
| 87 bool* changed) override; | 98 bool* changed) override; |
| 88 | 99 |
| 89 // SurfaceManager should be the first object constructed and the last object | 100 // SurfaceManager should be the first object constructed and the last object |
| 90 // 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 |
| 91 // access to a valid pointer for the entirety of their liftimes. | 102 // access to a valid pointer for the entirety of their liftimes. |
| 92 cc::SurfaceManager manager_; | 103 cc::SurfaceManager manager_; |
| 93 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service_; | 104 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service_; |
| 94 std::unordered_map<cc::FrameSinkId, | 105 std::unordered_map<cc::FrameSinkId, |
| 95 std::unique_ptr<GpuCompositorFrameSink>, | 106 std::unique_ptr<GpuCompositorFrameSink>, |
| 96 cc::FrameSinkIdHash> | 107 cc::FrameSinkIdHash> |
| 97 compositor_frame_sinks_; | 108 compositor_frame_sinks_; |
| 98 std::unique_ptr<MusGpuMemoryBufferManager> gpu_memory_buffer_manager_; | 109 std::unique_ptr<MusGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
| 99 gpu::ImageFactory* image_factory_; | 110 gpu::ImageFactory* image_factory_; |
| 100 cc::mojom::DisplayCompositorClientPtr client_; | 111 cc::mojom::DisplayCompositorClientPtr client_; |
| 101 | 112 |
| 113 // Will normally point to |manager_| as it provides the interface. For tests |
| 114 // it will be swapped out with a mock implementation. |
| 115 cc::SurfaceReferenceManager* reference_manager_; |
| 116 |
| 102 // SurfaceIds that have temporary references from top level root so they | 117 // SurfaceIds that have temporary references from top level root so they |
| 103 // aren't GC'd before DisplayCompositorClient can add a real reference. This | 118 // aren't GC'd before DisplayCompositorClient can add a real reference. This |
| 104 // is basically a collection of surface ids, for example: | 119 // is basically a collection of surface ids, for example: |
| 105 // cc::SurfaceId surface_id(key, value[index]); | 120 // cc::SurfaceId surface_id(key, value[index]); |
| 106 // The LocalFrameIds are stored in the order the surfaces are created in. | 121 // The LocalFrameIds are stored in the order the surfaces are created in. |
| 107 std::unordered_map<cc::FrameSinkId, | 122 std::unordered_map<cc::FrameSinkId, |
| 108 std::vector<cc::LocalFrameId>, | 123 std::vector<cc::LocalFrameId>, |
| 109 cc::FrameSinkIdHash> | 124 cc::FrameSinkIdHash> |
| 110 temp_references_; | 125 temp_references_; |
| 111 | 126 |
| 112 mojo::Binding<cc::mojom::DisplayCompositor> binding_; | 127 mojo::Binding<cc::mojom::DisplayCompositor> binding_; |
| 113 | 128 |
| 114 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); | 129 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); |
| 115 }; | 130 }; |
| 116 | 131 |
| 117 } // namespace ui | 132 } // namespace ui |
| 118 | 133 |
| 119 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ | 134 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ |
| OLD | NEW |