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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 client_(std::move(client)), | 43 client_(std::move(client)), |
44 binding_(this, std::move(request)) { | 44 binding_(this, std::move(request)) { |
45 manager_.AddObserver(this); | 45 manager_.AddObserver(this); |
46 } | 46 } |
47 | 47 |
48 DisplayCompositor::~DisplayCompositor() { | 48 DisplayCompositor::~DisplayCompositor() { |
49 DCHECK(thread_checker_.CalledOnValidThread()); | 49 DCHECK(thread_checker_.CalledOnValidThread()); |
50 manager_.RemoveObserver(this); | 50 manager_.RemoveObserver(this); |
51 } | 51 } |
52 | 52 |
53 void DisplayCompositor::OnClientConnectionLost( | |
54 const cc::FrameSinkId& frame_sink_id, | |
55 bool destroy_compositor_frame_sink) { | |
56 DCHECK(thread_checker_.CalledOnValidThread()); | |
57 if (destroy_compositor_frame_sink) | |
58 DestroyCompositorFrameSink(frame_sink_id); | |
59 // 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 | |
61 // client instance to create a new CompositorFrameSink. | |
62 } | |
63 | |
64 void DisplayCompositor::OnPrivateConnectionLost( | |
65 const cc::FrameSinkId& frame_sink_id, | |
66 bool destroy_compositor_frame_sink) { | |
67 DCHECK(thread_checker_.CalledOnValidThread()); | |
68 if (destroy_compositor_frame_sink) | |
69 DestroyCompositorFrameSink(frame_sink_id); | |
70 } | |
71 | |
72 void DisplayCompositor::CreateRootCompositorFrameSink( | 53 void DisplayCompositor::CreateRootCompositorFrameSink( |
73 const cc::FrameSinkId& frame_sink_id, | 54 const cc::FrameSinkId& frame_sink_id, |
74 gpu::SurfaceHandle surface_handle, | 55 gpu::SurfaceHandle surface_handle, |
75 cc::mojom::MojoCompositorFrameSinkAssociatedRequest request, | 56 cc::mojom::MojoCompositorFrameSinkAssociatedRequest request, |
76 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, | 57 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, |
77 cc::mojom::MojoCompositorFrameSinkClientPtr client, | 58 cc::mojom::MojoCompositorFrameSinkClientPtr client, |
78 cc::mojom::DisplayPrivateAssociatedRequest display_private_request) { | 59 cc::mojom::DisplayPrivateAssociatedRequest display_private_request) { |
79 DCHECK(thread_checker_.CalledOnValidThread()); | 60 DCHECK(thread_checker_.CalledOnValidThread()); |
80 DCHECK_NE(surface_handle, gpu::kNullSurfaceHandle); | 61 DCHECK_NE(surface_handle, gpu::kNullSurfaceHandle); |
81 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); | 62 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); |
(...skipping 19 matching lines...) Expand all Loading... |
101 cc::mojom::MojoCompositorFrameSinkClientPtr client) { | 82 cc::mojom::MojoCompositorFrameSinkClientPtr client) { |
102 DCHECK(thread_checker_.CalledOnValidThread()); | 83 DCHECK(thread_checker_.CalledOnValidThread()); |
103 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); | 84 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); |
104 | 85 |
105 compositor_frame_sinks_[frame_sink_id] = | 86 compositor_frame_sinks_[frame_sink_id] = |
106 base::MakeUnique<display_compositor::GpuCompositorFrameSink>( | 87 base::MakeUnique<display_compositor::GpuCompositorFrameSink>( |
107 this, &manager_, frame_sink_id, std::move(request), | 88 this, &manager_, frame_sink_id, std::move(request), |
108 std::move(private_request), std::move(client)); | 89 std::move(private_request), std::move(client)); |
109 } | 90 } |
110 | 91 |
| 92 void DisplayCompositor::RegisterFrameSinkHierarchy( |
| 93 const cc::FrameSinkId& parent_frame_sink_id, |
| 94 const cc::FrameSinkId& child_frame_sink_id) { |
| 95 manager_.RegisterFrameSinkHierarchy(parent_frame_sink_id, |
| 96 child_frame_sink_id); |
| 97 } |
| 98 |
| 99 void DisplayCompositor::UnregisterFrameSinkHierarchy( |
| 100 const cc::FrameSinkId& parent_frame_sink_id, |
| 101 const cc::FrameSinkId& child_frame_sink_id) { |
| 102 manager_.UnregisterFrameSinkHierarchy(parent_frame_sink_id, |
| 103 child_frame_sink_id); |
| 104 } |
| 105 |
111 std::unique_ptr<cc::Display> DisplayCompositor::CreateDisplay( | 106 std::unique_ptr<cc::Display> DisplayCompositor::CreateDisplay( |
112 const cc::FrameSinkId& frame_sink_id, | 107 const cc::FrameSinkId& frame_sink_id, |
113 gpu::SurfaceHandle surface_handle, | 108 gpu::SurfaceHandle surface_handle, |
114 cc::SyntheticBeginFrameSource* begin_frame_source) { | 109 cc::SyntheticBeginFrameSource* begin_frame_source) { |
115 scoped_refptr<cc::InProcessContextProvider> context_provider = | 110 scoped_refptr<cc::InProcessContextProvider> context_provider = |
116 new cc::InProcessContextProvider( | 111 new cc::InProcessContextProvider( |
117 gpu_service_, surface_handle, gpu_memory_buffer_manager_.get(), | 112 gpu_service_, surface_handle, gpu_memory_buffer_manager_.get(), |
118 image_factory_, gpu::SharedMemoryLimits(), | 113 image_factory_, gpu::SharedMemoryLimits(), |
119 nullptr /* shared_context */); | 114 nullptr /* shared_context */); |
120 | 115 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 DCHECK(thread_checker_.CalledOnValidThread()); | 158 DCHECK(thread_checker_.CalledOnValidThread()); |
164 DCHECK_GT(surface_info.device_scale_factor(), 0.0f); | 159 DCHECK_GT(surface_info.device_scale_factor(), 0.0f); |
165 | 160 |
166 if (client_) | 161 if (client_) |
167 client_->OnSurfaceCreated(surface_info); | 162 client_->OnSurfaceCreated(surface_info); |
168 } | 163 } |
169 | 164 |
170 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id, | 165 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id, |
171 bool* changed) {} | 166 bool* changed) {} |
172 | 167 |
| 168 void DisplayCompositor::OnClientConnectionLost( |
| 169 const cc::FrameSinkId& frame_sink_id, |
| 170 bool destroy_compositor_frame_sink) { |
| 171 DCHECK(thread_checker_.CalledOnValidThread()); |
| 172 if (destroy_compositor_frame_sink) |
| 173 DestroyCompositorFrameSink(frame_sink_id); |
| 174 // TODO(fsamuel): Tell the display compositor host that the client connection |
| 175 // has been lost so that it can drop its private connection and allow a new |
| 176 // client instance to create a new CompositorFrameSink. |
| 177 } |
| 178 |
| 179 void DisplayCompositor::OnPrivateConnectionLost( |
| 180 const cc::FrameSinkId& frame_sink_id, |
| 181 bool destroy_compositor_frame_sink) { |
| 182 DCHECK(thread_checker_.CalledOnValidThread()); |
| 183 if (destroy_compositor_frame_sink) |
| 184 DestroyCompositorFrameSink(frame_sink_id); |
| 185 } |
| 186 |
173 } // namespace ui | 187 } // namespace ui |
OLD | NEW |