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 "components/frame_sinks/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_compositor_frame_sink.h" | 18 #include "components/frame_sinks/gpu_compositor_frame_sink.h" |
19 #include "components/display_compositor/gpu_root_compositor_frame_sink.h" | 19 #include "components/frame_sinks/gpu_root_compositor_frame_sink.h" |
20 #include "gpu/command_buffer/client/shared_memory_limits.h" | 20 #include "gpu/command_buffer/client/shared_memory_limits.h" |
21 #include "gpu/ipc/gpu_in_process_thread_service.h" | 21 #include "gpu/ipc/gpu_in_process_thread_service.h" |
22 #include "mojo/public/cpp/bindings/strong_binding.h" | 22 #include "mojo/public/cpp/bindings/strong_binding.h" |
23 #include "services/ui/surfaces/display_output_surface.h" | 23 #include "services/ui/surfaces/display_output_surface.h" |
24 | 24 |
25 #if defined(USE_OZONE) | 25 #if defined(USE_OZONE) |
26 #include "gpu/command_buffer/client/gles2_interface.h" | 26 #include "gpu/command_buffer/client/gles2_interface.h" |
27 #include "services/ui/surfaces/display_output_surface_ozone.h" | 27 #include "services/ui/surfaces/display_output_surface_ozone.h" |
28 #endif | 28 #endif |
29 | 29 |
30 namespace ui { | 30 namespace frame_sinks { |
31 | 31 |
32 DisplayCompositor::DisplayCompositor( | 32 DisplayCompositor::DisplayCompositor( |
33 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service, | 33 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service, |
34 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager, | 34 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager, |
35 gpu::ImageFactory* image_factory, | 35 gpu::ImageFactory* image_factory, |
36 cc::mojom::DisplayCompositorRequest request, | 36 cc::mojom::DisplayCompositorRequest request, |
37 cc::mojom::DisplayCompositorClientPtr client) | 37 cc::mojom::DisplayCompositorClientPtr client) |
38 : manager_(cc::SurfaceManager::LifetimeType::REFERENCES), | 38 : manager_(cc::SurfaceManager::LifetimeType::REFERENCES), |
39 gpu_service_(std::move(gpu_service)), | 39 gpu_service_(std::move(gpu_service)), |
40 gpu_memory_buffer_manager_(std::move(gpu_memory_buffer_manager)), | 40 gpu_memory_buffer_manager_(std::move(gpu_memory_buffer_manager)), |
(...skipping 30 matching lines...) Expand all Loading... |
71 // synchronization is enabled. | 71 // synchronization is enabled. |
72 if (!manager_.dependency_tracker() && | 72 if (!manager_.dependency_tracker() && |
73 base::CommandLine::ForCurrentProcess()->HasSwitch( | 73 base::CommandLine::ForCurrentProcess()->HasSwitch( |
74 cc::switches::kEnableSurfaceSynchronization)) { | 74 cc::switches::kEnableSurfaceSynchronization)) { |
75 std::unique_ptr<cc::SurfaceDependencyTracker> dependency_tracker( | 75 std::unique_ptr<cc::SurfaceDependencyTracker> dependency_tracker( |
76 new cc::SurfaceDependencyTracker(&manager_, begin_frame_source.get())); | 76 new cc::SurfaceDependencyTracker(&manager_, begin_frame_source.get())); |
77 manager_.SetDependencyTracker(std::move(dependency_tracker)); | 77 manager_.SetDependencyTracker(std::move(dependency_tracker)); |
78 } | 78 } |
79 | 79 |
80 compositor_frame_sinks_[frame_sink_id] = | 80 compositor_frame_sinks_[frame_sink_id] = |
81 base::MakeUnique<display_compositor::GpuRootCompositorFrameSink>( | 81 base::MakeUnique<GpuRootCompositorFrameSink>( |
82 this, &manager_, frame_sink_id, std::move(display), | 82 this, &manager_, frame_sink_id, std::move(display), |
83 std::move(begin_frame_source), std::move(request), | 83 std::move(begin_frame_source), std::move(request), |
84 std::move(private_request), std::move(client), | 84 std::move(private_request), std::move(client), |
85 std::move(display_private_request)); | 85 std::move(display_private_request)); |
86 } | 86 } |
87 | 87 |
88 void DisplayCompositor::CreateCompositorFrameSink( | 88 void DisplayCompositor::CreateCompositorFrameSink( |
89 const cc::FrameSinkId& frame_sink_id, | 89 const cc::FrameSinkId& frame_sink_id, |
90 cc::mojom::MojoCompositorFrameSinkRequest request, | 90 cc::mojom::MojoCompositorFrameSinkRequest request, |
91 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, | 91 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, |
92 cc::mojom::MojoCompositorFrameSinkClientPtr client) { | 92 cc::mojom::MojoCompositorFrameSinkClientPtr client) { |
93 DCHECK(thread_checker_.CalledOnValidThread()); | 93 DCHECK(thread_checker_.CalledOnValidThread()); |
94 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); | 94 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); |
95 | 95 |
96 compositor_frame_sinks_[frame_sink_id] = | 96 compositor_frame_sinks_[frame_sink_id] = |
97 base::MakeUnique<display_compositor::GpuCompositorFrameSink>( | 97 base::MakeUnique<GpuCompositorFrameSink>( |
98 this, &manager_, frame_sink_id, std::move(request), | 98 this, &manager_, frame_sink_id, std::move(request), |
99 std::move(private_request), std::move(client)); | 99 std::move(private_request), std::move(client)); |
100 } | 100 } |
101 | 101 |
102 void DisplayCompositor::RegisterFrameSinkHierarchy( | 102 void DisplayCompositor::RegisterFrameSinkHierarchy( |
103 const cc::FrameSinkId& parent_frame_sink_id, | 103 const cc::FrameSinkId& parent_frame_sink_id, |
104 const cc::FrameSinkId& child_frame_sink_id) { | 104 const cc::FrameSinkId& child_frame_sink_id) { |
105 manager_.RegisterFrameSinkHierarchy(parent_frame_sink_id, | 105 manager_.RegisterFrameSinkHierarchy(parent_frame_sink_id, |
106 child_frame_sink_id); | 106 child_frame_sink_id); |
107 } | 107 } |
(...skipping 19 matching lines...) Expand all Loading... |
127 gpu_service_, surface_handle, gpu_memory_buffer_manager_.get(), | 127 gpu_service_, surface_handle, gpu_memory_buffer_manager_.get(), |
128 image_factory_, gpu::SharedMemoryLimits(), | 128 image_factory_, gpu::SharedMemoryLimits(), |
129 nullptr /* shared_context */); | 129 nullptr /* shared_context */); |
130 | 130 |
131 // TODO(rjkroege): If there is something better to do than CHECK, add it. | 131 // TODO(rjkroege): If there is something better to do than CHECK, add it. |
132 CHECK(context_provider->BindToCurrentThread()); | 132 CHECK(context_provider->BindToCurrentThread()); |
133 | 133 |
134 std::unique_ptr<cc::OutputSurface> display_output_surface; | 134 std::unique_ptr<cc::OutputSurface> display_output_surface; |
135 if (context_provider->ContextCapabilities().surfaceless) { | 135 if (context_provider->ContextCapabilities().surfaceless) { |
136 #if defined(USE_OZONE) | 136 #if defined(USE_OZONE) |
137 display_output_surface = base::MakeUnique<DisplayOutputSurfaceOzone>( | 137 display_output_surface = base::MakeUnique<ui::DisplayOutputSurfaceOzone>( |
138 std::move(context_provider), surface_handle, | 138 std::move(context_provider), surface_handle, begin_frame_source, |
139 begin_frame_source, gpu_memory_buffer_manager_.get(), | 139 gpu_memory_buffer_manager_.get(), GL_TEXTURE_2D, GL_RGB); |
140 GL_TEXTURE_2D, GL_RGB); | |
141 #else | 140 #else |
142 NOTREACHED(); | 141 NOTREACHED(); |
143 #endif | 142 #endif |
144 } else { | 143 } else { |
145 display_output_surface = base::MakeUnique<DisplayOutputSurface>( | 144 display_output_surface = base::MakeUnique<ui::DisplayOutputSurface>( |
146 std::move(context_provider), begin_frame_source); | 145 std::move(context_provider), begin_frame_source); |
147 } | 146 } |
148 | 147 |
149 int max_frames_pending = | 148 int max_frames_pending = |
150 display_output_surface->capabilities().max_frames_pending; | 149 display_output_surface->capabilities().max_frames_pending; |
151 DCHECK_GT(max_frames_pending, 0); | 150 DCHECK_GT(max_frames_pending, 0); |
152 | 151 |
153 std::unique_ptr<cc::DisplayScheduler> scheduler( | 152 std::unique_ptr<cc::DisplayScheduler> scheduler( |
154 new cc::DisplayScheduler(task_runner_.get(), max_frames_pending)); | 153 new cc::DisplayScheduler(task_runner_.get(), max_frames_pending)); |
155 | 154 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 196 } |
198 | 197 |
199 void DisplayCompositor::OnPrivateConnectionLost( | 198 void DisplayCompositor::OnPrivateConnectionLost( |
200 const cc::FrameSinkId& frame_sink_id, | 199 const cc::FrameSinkId& frame_sink_id, |
201 bool destroy_compositor_frame_sink) { | 200 bool destroy_compositor_frame_sink) { |
202 DCHECK(thread_checker_.CalledOnValidThread()); | 201 DCHECK(thread_checker_.CalledOnValidThread()); |
203 if (destroy_compositor_frame_sink) | 202 if (destroy_compositor_frame_sink) |
204 DestroyCompositorFrameSink(frame_sink_id); | 203 DestroyCompositorFrameSink(frame_sink_id); |
205 } | 204 } |
206 | 205 |
207 } // namespace ui | 206 } // namespace frame_sinks |
OLD | NEW |