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" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 namespace ui { | 30 namespace ui { |
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 framesink_manager_(), |
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 } |
47 | 48 |
48 DisplayCompositor::~DisplayCompositor() { | 49 DisplayCompositor::~DisplayCompositor() { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); | 82 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); |
82 | 83 |
83 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source( | 84 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source( |
84 new cc::DelayBasedBeginFrameSource( | 85 new cc::DelayBasedBeginFrameSource( |
85 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner_.get()))); | 86 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner_.get()))); |
86 std::unique_ptr<cc::Display> display = | 87 std::unique_ptr<cc::Display> display = |
87 CreateDisplay(frame_sink_id, surface_handle, begin_frame_source.get()); | 88 CreateDisplay(frame_sink_id, surface_handle, begin_frame_source.get()); |
88 | 89 |
89 compositor_frame_sinks_[frame_sink_id] = | 90 compositor_frame_sinks_[frame_sink_id] = |
90 base::MakeUnique<display_compositor::GpuDisplayCompositorFrameSink>( | 91 base::MakeUnique<display_compositor::GpuDisplayCompositorFrameSink>( |
91 this, &manager_, frame_sink_id, std::move(display), | 92 this, &manager_,&framesink_manager_, frame_sink_id, |
92 std::move(begin_frame_source), std::move(request), | 93 std::move(display), std::move(begin_frame_source), std::move(request), |
93 std::move(private_request), std::move(client), | 94 std::move(private_request), std::move(client), |
94 std::move(display_private_request)); | 95 std::move(display_private_request)); |
95 } | 96 } |
96 | 97 |
97 void DisplayCompositor::CreateOffscreenCompositorFrameSink( | 98 void DisplayCompositor::CreateOffscreenCompositorFrameSink( |
98 const cc::FrameSinkId& frame_sink_id, | 99 const cc::FrameSinkId& frame_sink_id, |
99 cc::mojom::MojoCompositorFrameSinkRequest request, | 100 cc::mojom::MojoCompositorFrameSinkRequest request, |
100 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, | 101 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, |
101 cc::mojom::MojoCompositorFrameSinkClientPtr client) { | 102 cc::mojom::MojoCompositorFrameSinkClientPtr client) { |
102 DCHECK(thread_checker_.CalledOnValidThread()); | 103 DCHECK(thread_checker_.CalledOnValidThread()); |
103 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); | 104 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); |
104 | 105 |
105 compositor_frame_sinks_[frame_sink_id] = | 106 compositor_frame_sinks_[frame_sink_id] = |
106 base::MakeUnique<display_compositor::GpuOffscreenCompositorFrameSink>( | 107 base::MakeUnique<display_compositor::GpuOffscreenCompositorFrameSink>( |
107 this, &manager_, frame_sink_id, std::move(request), | 108 this, &manager_,&framesink_manager_, frame_sink_id, |
108 std::move(private_request), std::move(client)); | 109 std::move(request), std::move(private_request), std::move(client)); |
109 } | 110 } |
110 | 111 |
111 std::unique_ptr<cc::Display> DisplayCompositor::CreateDisplay( | 112 std::unique_ptr<cc::Display> DisplayCompositor::CreateDisplay( |
112 const cc::FrameSinkId& frame_sink_id, | 113 const cc::FrameSinkId& frame_sink_id, |
113 gpu::SurfaceHandle surface_handle, | 114 gpu::SurfaceHandle surface_handle, |
114 cc::SyntheticBeginFrameSource* begin_frame_source) { | 115 cc::SyntheticBeginFrameSource* begin_frame_source) { |
115 scoped_refptr<cc::InProcessContextProvider> context_provider = | 116 scoped_refptr<cc::InProcessContextProvider> context_provider = |
116 new cc::InProcessContextProvider( | 117 new cc::InProcessContextProvider( |
117 gpu_service_, surface_handle, gpu_memory_buffer_manager_.get(), | 118 gpu_service_, surface_handle, gpu_memory_buffer_manager_.get(), |
118 image_factory_, gpu::SharedMemoryLimits(), | 119 image_factory_, gpu::SharedMemoryLimits(), |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 DCHECK_GT(surface_info.device_scale_factor(), 0.0f); | 161 DCHECK_GT(surface_info.device_scale_factor(), 0.0f); |
161 | 162 |
162 if (client_) | 163 if (client_) |
163 client_->OnSurfaceCreated(surface_info); | 164 client_->OnSurfaceCreated(surface_info); |
164 } | 165 } |
165 | 166 |
166 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id, | 167 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id, |
167 bool* changed) {} | 168 bool* changed) {} |
168 | 169 |
169 } // namespace ui | 170 } // namespace ui |
OLD | NEW |