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 #include "services/ui/surfaces/display_compositor.h" | 5 #include "services/ui/surfaces/display_compositor.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
12 #include "cc/base/switches.h" | 12 #include "cc/base/switches.h" |
13 #include "cc/output/in_process_context_provider.h" | 13 #include "cc/output/in_process_context_provider.h" |
14 #include "cc/output/texture_mailbox_deleter.h" | 14 #include "cc/output/texture_mailbox_deleter.h" |
15 #include "cc/surfaces/display.h" | 15 #include "cc/surfaces/display.h" |
16 #include "cc/surfaces/display_scheduler.h" | 16 #include "cc/surfaces/display_scheduler.h" |
17 #include "cc/surfaces/surface.h" | 17 #include "cc/surfaces/surface.h" |
18 #include "components/display_compositor/gpu_display_compositor_frame_sink.h" | 18 #include "components/display_compositor/gpu_display_compositor_frame_sink.h" |
19 #include "components/display_compositor/gpu_offscreen_compositor_frame_sink.h" | 19 #include "components/display_compositor/gpu_offscreen_compositor_frame_sink.h" |
| 20 #include "components/display_compositor/offscreen_canvas_compositor_frame_sink.h
" |
20 #include "gpu/command_buffer/client/shared_memory_limits.h" | 21 #include "gpu/command_buffer/client/shared_memory_limits.h" |
21 #include "gpu/ipc/gpu_in_process_thread_service.h" | 22 #include "gpu/ipc/gpu_in_process_thread_service.h" |
22 #include "mojo/public/cpp/bindings/strong_binding.h" | 23 #include "mojo/public/cpp/bindings/strong_binding.h" |
23 #include "services/ui/surfaces/display_output_surface.h" | 24 #include "services/ui/surfaces/display_output_surface.h" |
24 | 25 |
25 #if defined(USE_OZONE) | 26 #if defined(USE_OZONE) |
26 #include "gpu/command_buffer/client/gles2_interface.h" | 27 #include "gpu/command_buffer/client/gles2_interface.h" |
27 #include "services/ui/surfaces/display_output_surface_ozone.h" | 28 #include "services/ui/surfaces/display_output_surface_ozone.h" |
28 #endif | 29 #endif |
29 | 30 |
30 namespace ui { | 31 namespace ui { |
31 | 32 |
32 DisplayCompositor::DisplayCompositor( | 33 DisplayCompositor::DisplayCompositor( |
33 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service, | 34 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service, |
34 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager, | 35 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager, |
35 gpu::ImageFactory* image_factory, | 36 gpu::ImageFactory* image_factory, |
36 cc::mojom::DisplayCompositorRequest request, | 37 cc::mojom::DisplayCompositorRequest request, |
37 cc::mojom::DisplayCompositorClientPtr client) | 38 cc::mojom::DisplayCompositorClientPtr client) |
38 : manager_(cc::SurfaceManager::LifetimeType::REFERENCES), | 39 : manager_(cc::SurfaceManager::LifetimeType::REFERENCES), |
39 gpu_service_(std::move(gpu_service)), | 40 gpu_service_(std::move(gpu_service)), |
40 gpu_memory_buffer_manager_(std::move(gpu_memory_buffer_manager)), | 41 gpu_memory_buffer_manager_(std::move(gpu_memory_buffer_manager)), |
41 image_factory_(image_factory), | 42 image_factory_(image_factory), |
42 task_runner_(base::ThreadTaskRunnerHandle::Get()), | 43 task_runner_(base::ThreadTaskRunnerHandle::Get()), |
43 client_(std::move(client)), | 44 client_(std::move(client)), |
44 binding_(this, std::move(request)) { | 45 binding_(this, std::move(request)) { |
45 manager_.AddObserver(this); | 46 manager_.AddObserver(this); |
46 } | 47 } |
| 48 DisplayCompositor::DisplayCompositor( |
| 49 cc::mojom::DisplayCompositorRequest request, |
| 50 cc::SurfaceManager* surfacemanager) |
| 51 : manager_of_system_(surfacemanager), binding_(this, std::move(request)) { |
| 52 if (manager_of_system_) |
| 53 manager_of_system_->AddObserver(this); |
| 54 } |
47 | 55 |
48 DisplayCompositor::~DisplayCompositor() { | 56 DisplayCompositor::~DisplayCompositor() { |
49 DCHECK(thread_checker_.CalledOnValidThread()); | 57 DCHECK(thread_checker_.CalledOnValidThread()); |
50 manager_.RemoveObserver(this); | 58 manager_.RemoveObserver(this); |
| 59 if (manager_of_system_) |
| 60 manager_of_system_->RemoveObserver(this); |
51 } | 61 } |
52 | 62 |
53 void DisplayCompositor::OnClientConnectionLost( | 63 void DisplayCompositor::OnClientConnectionLost( |
54 const cc::FrameSinkId& frame_sink_id, | 64 const cc::FrameSinkId& frame_sink_id, |
55 bool destroy_compositor_frame_sink) { | 65 bool destroy_compositor_frame_sink) { |
56 DCHECK(thread_checker_.CalledOnValidThread()); | 66 DCHECK(thread_checker_.CalledOnValidThread()); |
57 if (destroy_compositor_frame_sink) | 67 if (destroy_compositor_frame_sink) |
58 DestroyCompositorFrameSink(frame_sink_id); | 68 DestroyCompositorFrameSink(frame_sink_id); |
59 // TODO(fsamuel): Tell the display compositor host that the client connection | 69 // TODO(fsamuel): Tell the display compositor host that the client connection |
60 // has been lost so that it can drop its private connection and allow a new | 70 // has been lost so that it can drop its private connection and allow a new |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 cc::mojom::MojoCompositorFrameSinkClientPtr client) { | 111 cc::mojom::MojoCompositorFrameSinkClientPtr client) { |
102 DCHECK(thread_checker_.CalledOnValidThread()); | 112 DCHECK(thread_checker_.CalledOnValidThread()); |
103 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); | 113 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); |
104 | 114 |
105 compositor_frame_sinks_[frame_sink_id] = | 115 compositor_frame_sinks_[frame_sink_id] = |
106 base::MakeUnique<display_compositor::GpuOffscreenCompositorFrameSink>( | 116 base::MakeUnique<display_compositor::GpuOffscreenCompositorFrameSink>( |
107 this, &manager_, frame_sink_id, std::move(request), | 117 this, &manager_, frame_sink_id, std::move(request), |
108 std::move(private_request), std::move(client)); | 118 std::move(private_request), std::move(client)); |
109 } | 119 } |
110 | 120 |
| 121 void DisplayCompositor::CreateOffscreenCanvasCompositorFrameSink( |
| 122 const cc::FrameSinkId& frame_sink_id, |
| 123 cc::mojom::MojoCompositorFrameSinkRequest request, |
| 124 cc::mojom::MojoCompositorFrameSinkClientPtr client) { |
| 125 DCHECK(thread_checker_.CalledOnValidThread()); |
| 126 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); |
| 127 |
| 128 compositor_frame_sinks_[frame_sink_id] = |
| 129 base::MakeUnique<display_compositor::OffscreenCanvasCompositorFrameSink>( |
| 130 this, manager_of_system_, frame_sink_id, std::move(request), |
| 131 std::move(client)); |
| 132 } |
| 133 |
111 std::unique_ptr<cc::Display> DisplayCompositor::CreateDisplay( | 134 std::unique_ptr<cc::Display> DisplayCompositor::CreateDisplay( |
112 const cc::FrameSinkId& frame_sink_id, | 135 const cc::FrameSinkId& frame_sink_id, |
113 gpu::SurfaceHandle surface_handle, | 136 gpu::SurfaceHandle surface_handle, |
114 cc::SyntheticBeginFrameSource* begin_frame_source) { | 137 cc::SyntheticBeginFrameSource* begin_frame_source) { |
115 scoped_refptr<cc::InProcessContextProvider> context_provider = | 138 scoped_refptr<cc::InProcessContextProvider> context_provider = |
116 new cc::InProcessContextProvider( | 139 new cc::InProcessContextProvider( |
117 gpu_service_, surface_handle, gpu_memory_buffer_manager_.get(), | 140 gpu_service_, surface_handle, gpu_memory_buffer_manager_.get(), |
118 image_factory_, gpu::SharedMemoryLimits(), | 141 image_factory_, gpu::SharedMemoryLimits(), |
119 nullptr /* shared_context */); | 142 nullptr /* shared_context */); |
120 | 143 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 DCHECK_GT(surface_info.device_scale_factor(), 0.0f); | 187 DCHECK_GT(surface_info.device_scale_factor(), 0.0f); |
165 | 188 |
166 if (client_) | 189 if (client_) |
167 client_->OnSurfaceCreated(surface_info); | 190 client_->OnSurfaceCreated(surface_info); |
168 } | 191 } |
169 | 192 |
170 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id, | 193 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id, |
171 bool* changed) {} | 194 bool* changed) {} |
172 | 195 |
173 } // namespace ui | 196 } // namespace ui |
OLD | NEW |