| 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 13 matching lines...) Expand all Loading... |
| 24 #include "gpu/ipc/in_process_command_buffer.h" | 24 #include "gpu/ipc/in_process_command_buffer.h" |
| 25 #include "ipc/ipc_channel_handle.h" | 25 #include "ipc/ipc_channel_handle.h" |
| 26 #include "mojo/public/cpp/bindings/binding.h" | 26 #include "mojo/public/cpp/bindings/binding.h" |
| 27 | 27 |
| 28 namespace gpu { | 28 namespace gpu { |
| 29 class GpuMemoryBufferManager; | 29 class GpuMemoryBufferManager; |
| 30 class ImageFactory; | 30 class ImageFactory; |
| 31 } | 31 } |
| 32 | 32 |
| 33 namespace cc { | 33 namespace cc { |
| 34 class SurfaceHittest; | 34 class Display; |
| 35 class SurfaceManager; | 35 class SurfaceManager; |
| 36 } // namespace cc | 36 } |
| 37 | 37 |
| 38 namespace ui { | 38 namespace ui { |
| 39 | 39 |
| 40 namespace test { | 40 namespace test { |
| 41 class DisplayCompositorTest; | 41 class DisplayCompositorTest; |
| 42 } | 42 } |
| 43 | 43 |
| 44 class DisplayCompositorClient; | 44 class DisplayCompositorClient; |
| 45 class GpuCompositorFrameSink; | 45 class GpuCompositorFrameSink; |
| 46 | 46 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 void OnCompositorFrameSinkClientConnectionLost( | 82 void OnCompositorFrameSinkClientConnectionLost( |
| 83 const cc::FrameSinkId& frame_sink_id, | 83 const cc::FrameSinkId& frame_sink_id, |
| 84 bool destroy_compositor_frame_sink); | 84 bool destroy_compositor_frame_sink); |
| 85 void OnCompositorFrameSinkPrivateConnectionLost( | 85 void OnCompositorFrameSinkPrivateConnectionLost( |
| 86 const cc::FrameSinkId& frame_sink_id, | 86 const cc::FrameSinkId& frame_sink_id, |
| 87 bool destroy_compositor_frame_sink); | 87 bool destroy_compositor_frame_sink); |
| 88 | 88 |
| 89 private: | 89 private: |
| 90 friend class test::DisplayCompositorTest; | 90 friend class test::DisplayCompositorTest; |
| 91 | 91 |
| 92 std::unique_ptr<cc::Display> CreateDisplay( |
| 93 const cc::FrameSinkId& frame_sink_id, |
| 94 gpu::SurfaceHandle surface_handle); |
| 95 |
| 92 const cc::SurfaceId& GetRootSurfaceId() const; | 96 const cc::SurfaceId& GetRootSurfaceId() const; |
| 93 | 97 |
| 94 // cc::SurfaceObserver implementation. | 98 // cc::SurfaceObserver implementation. |
| 95 void OnSurfaceCreated(const cc::SurfaceId& surface_id, | 99 void OnSurfaceCreated(const cc::SurfaceId& surface_id, |
| 96 const gfx::Size& frame_size, | 100 const gfx::Size& frame_size, |
| 97 float device_scale_factor) override; | 101 float device_scale_factor) override; |
| 98 void OnSurfaceDamaged(const cc::SurfaceId& surface_id, | 102 void OnSurfaceDamaged(const cc::SurfaceId& surface_id, |
| 99 bool* changed) override; | 103 bool* changed) override; |
| 100 | 104 |
| 101 // SurfaceManager should be the first object constructed and the last object | 105 // SurfaceManager should be the first object constructed and the last object |
| 102 // destroyed in order to ensure that all other objects that depend on it have | 106 // destroyed in order to ensure that all other objects that depend on it have |
| 103 // access to a valid pointer for the entirety of their liftimes. | 107 // access to a valid pointer for the entirety of their liftimes. |
| 104 cc::SurfaceManager manager_; | 108 cc::SurfaceManager manager_; |
| 105 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service_; | |
| 106 std::unordered_map<cc::FrameSinkId, | |
| 107 std::unique_ptr<GpuCompositorFrameSink>, | |
| 108 cc::FrameSinkIdHash> | |
| 109 compositor_frame_sinks_; | |
| 110 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager_; | |
| 111 gpu::ImageFactory* image_factory_; | |
| 112 cc::mojom::DisplayCompositorClientPtr client_; | |
| 113 | 109 |
| 114 // Will normally point to |manager_| as it provides the interface. For tests | 110 // Will normally point to |manager_| as it provides the interface. For tests |
| 115 // it will be swapped out with a mock implementation. | 111 // it will be swapped out with a mock implementation. |
| 116 cc::SurfaceReferenceManager* reference_manager_; | 112 cc::SurfaceReferenceManager* reference_manager_; |
| 117 | 113 |
| 114 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service_; |
| 115 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager_; |
| 116 gpu::ImageFactory* image_factory_; |
| 117 |
| 118 std::unordered_map<cc::FrameSinkId, |
| 119 std::unique_ptr<GpuCompositorFrameSink>, |
| 120 cc::FrameSinkIdHash> |
| 121 compositor_frame_sinks_; |
| 122 |
| 123 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 124 |
| 118 // SurfaceIds that have temporary references from top level root so they | 125 // SurfaceIds that have temporary references from top level root so they |
| 119 // aren't GC'd before DisplayCompositorClient can add a real reference. This | 126 // aren't GC'd before DisplayCompositorClient can add a real reference. This |
| 120 // is basically a collection of surface ids, for example: | 127 // is basically a collection of surface ids, for example: |
| 121 // cc::SurfaceId surface_id(key, value[index]); | 128 // cc::SurfaceId surface_id(key, value[index]); |
| 122 // The LocalFrameIds are stored in the order the surfaces are created in. | 129 // The LocalFrameIds are stored in the order the surfaces are created in. |
| 123 std::unordered_map<cc::FrameSinkId, | 130 std::unordered_map<cc::FrameSinkId, |
| 124 std::vector<cc::LocalFrameId>, | 131 std::vector<cc::LocalFrameId>, |
| 125 cc::FrameSinkIdHash> | 132 cc::FrameSinkIdHash> |
| 126 temp_references_; | 133 temp_references_; |
| 127 | 134 |
| 128 base::ThreadChecker thread_checker_; | 135 base::ThreadChecker thread_checker_; |
| 129 | 136 |
| 137 cc::mojom::DisplayCompositorClientPtr client_; |
| 130 mojo::Binding<cc::mojom::DisplayCompositor> binding_; | 138 mojo::Binding<cc::mojom::DisplayCompositor> binding_; |
| 131 | 139 |
| 132 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); | 140 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); |
| 133 }; | 141 }; |
| 134 | 142 |
| 135 } // namespace ui | 143 } // namespace ui |
| 136 | 144 |
| 137 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ | 145 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ |
| OLD | NEW |