Chromium Code Reviews| 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 "cc/output/in_process_context_provider.h" | 9 #include "cc/output/in_process_context_provider.h" |
| 10 #include "cc/output/texture_mailbox_deleter.h" | 10 #include "cc/output/texture_mailbox_deleter.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 } | 85 } |
| 86 | 86 |
| 87 void DisplayCompositor::OnCompositorFrameSinkPrivateConnectionLost( | 87 void DisplayCompositor::OnCompositorFrameSinkPrivateConnectionLost( |
| 88 const cc::FrameSinkId& frame_sink_id, | 88 const cc::FrameSinkId& frame_sink_id, |
| 89 bool destroy_compositor_frame_sink) { | 89 bool destroy_compositor_frame_sink) { |
| 90 DCHECK(thread_checker_.CalledOnValidThread()); | 90 DCHECK(thread_checker_.CalledOnValidThread()); |
| 91 if (destroy_compositor_frame_sink) | 91 if (destroy_compositor_frame_sink) |
| 92 compositor_frame_sinks_.erase(frame_sink_id); | 92 compositor_frame_sinks_.erase(frame_sink_id); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void DisplayCompositor::CreateCompositorFrameSink( | 95 void DisplayCompositor::CreateDisplayCompositorFrameSink( |
| 96 const cc::FrameSinkId& frame_sink_id, | 96 const cc::FrameSinkId& frame_sink_id, |
| 97 gpu::SurfaceHandle surface_handle, | 97 gpu::SurfaceHandle surface_handle, |
| 98 cc::mojom::MojoCompositorFrameSinkRequest request, | 98 cc::mojom::MojoCompositorFrameSinkRequest request, |
| 99 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, | 99 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, |
| 100 cc::mojom::MojoCompositorFrameSinkClientPtr client) { | 100 cc::mojom::MojoCompositorFrameSinkClientPtr client) { |
| 101 DCHECK(thread_checker_.CalledOnValidThread()); | 101 DCHECK_NE(surface_handle, gpu::kNullSurfaceHandle); |
|
Fady Samuel
2016/12/14 17:19:01
I would leave this here too because we're doing wo
Alex Z.
2016/12/14 18:44:12
Done.
| |
| 102 // We cannot create more than one CompositorFrameSink with a given | 102 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source( |
| 103 // |frame_sink_id|. | 103 new cc::DelayBasedBeginFrameSource( |
| 104 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); | 104 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner_.get()))); |
| 105 CreateCompositorFrameSinkInternal( | |
| 106 frame_sink_id, surface_handle, | |
| 107 CreateDisplay(frame_sink_id, surface_handle, begin_frame_source.get()), | |
| 108 std::move(begin_frame_source), std::move(request), | |
| 109 std::move(private_request), std::move(client)); | |
| 110 } | |
| 105 | 111 |
| 106 std::unique_ptr<cc::Display> display; | 112 void DisplayCompositor::CreateOffscreenCompositorFrameSink( |
| 107 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source; | 113 const cc::FrameSinkId& frame_sink_id, |
| 108 if (surface_handle != gpu::kNullSurfaceHandle) { | 114 cc::mojom::MojoCompositorFrameSinkRequest request, |
| 109 begin_frame_source.reset(new cc::DelayBasedBeginFrameSource( | 115 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, |
| 110 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner_.get()))); | 116 cc::mojom::MojoCompositorFrameSinkClientPtr client) { |
| 111 display = | 117 CreateCompositorFrameSinkInternal( |
| 112 CreateDisplay(frame_sink_id, surface_handle, begin_frame_source.get()); | 118 frame_sink_id, gpu::kNullSurfaceHandle, nullptr, nullptr, |
| 113 } | 119 std::move(request), std::move(private_request), std::move(client)); |
| 114 | |
| 115 compositor_frame_sinks_[frame_sink_id] = | |
| 116 base::MakeUnique<GpuCompositorFrameSink>( | |
| 117 this, frame_sink_id, std::move(display), | |
| 118 std::move(begin_frame_source), std::move(request), | |
| 119 std::move(private_request), std::move(client)); | |
| 120 } | 120 } |
| 121 | 121 |
| 122 void DisplayCompositor::AddSurfaceReference(const cc::SurfaceReference& ref) { | 122 void DisplayCompositor::AddSurfaceReference(const cc::SurfaceReference& ref) { |
| 123 const cc::SurfaceId& parent_id = ref.parent_id(); | 123 const cc::SurfaceId& parent_id = ref.parent_id(); |
| 124 const cc::SurfaceId& child_id = ref.child_id(); | 124 const cc::SurfaceId& child_id = ref.child_id(); |
| 125 | 125 |
| 126 auto vector_iter = temp_references_.find(child_id.frame_sink_id()); | 126 auto vector_iter = temp_references_.find(child_id.frame_sink_id()); |
| 127 | 127 |
| 128 // If there are no temporary references for the FrameSinkId then we can just | 128 // If there are no temporary references for the FrameSinkId then we can just |
| 129 // add reference and return. | 129 // add reference and return. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 std::unique_ptr<cc::DisplayScheduler> scheduler( | 211 std::unique_ptr<cc::DisplayScheduler> scheduler( |
| 212 new cc::DisplayScheduler(task_runner_.get(), max_frames_pending)); | 212 new cc::DisplayScheduler(task_runner_.get(), max_frames_pending)); |
| 213 | 213 |
| 214 return base::MakeUnique<cc::Display>( | 214 return base::MakeUnique<cc::Display>( |
| 215 nullptr /* bitmap_manager */, gpu_memory_buffer_manager_.get(), | 215 nullptr /* bitmap_manager */, gpu_memory_buffer_manager_.get(), |
| 216 cc::RendererSettings(), frame_sink_id, begin_frame_source, | 216 cc::RendererSettings(), frame_sink_id, begin_frame_source, |
| 217 std::move(display_output_surface), std::move(scheduler), | 217 std::move(display_output_surface), std::move(scheduler), |
| 218 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get())); | 218 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get())); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void DisplayCompositor::CreateCompositorFrameSinkInternal( | |
| 222 const cc::FrameSinkId& frame_sink_id, | |
| 223 gpu::SurfaceHandle surface_handle, | |
| 224 std::unique_ptr<cc::Display> display, | |
| 225 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source, | |
| 226 cc::mojom::MojoCompositorFrameSinkRequest request, | |
| 227 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, | |
| 228 cc::mojom::MojoCompositorFrameSinkClientPtr client) { | |
| 229 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 230 // We cannot create more than one CompositorFrameSink with a given | |
| 231 // |frame_sink_id|. | |
| 232 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); | |
| 233 | |
| 234 compositor_frame_sinks_[frame_sink_id] = | |
| 235 base::MakeUnique<GpuCompositorFrameSink>( | |
| 236 this, frame_sink_id, std::move(display), | |
| 237 std::move(begin_frame_source), std::move(request), | |
| 238 std::move(private_request), std::move(client)); | |
| 239 } | |
| 240 | |
| 221 const cc::SurfaceId& DisplayCompositor::GetRootSurfaceId() const { | 241 const cc::SurfaceId& DisplayCompositor::GetRootSurfaceId() const { |
| 222 return reference_manager_->GetRootSurfaceId(); | 242 return reference_manager_->GetRootSurfaceId(); |
| 223 } | 243 } |
| 224 | 244 |
| 225 void DisplayCompositor::OnSurfaceCreated(const cc::SurfaceId& surface_id, | 245 void DisplayCompositor::OnSurfaceCreated(const cc::SurfaceId& surface_id, |
| 226 const gfx::Size& frame_size, | 246 const gfx::Size& frame_size, |
| 227 float device_scale_factor) { | 247 float device_scale_factor) { |
| 228 DCHECK(thread_checker_.CalledOnValidThread()); | 248 DCHECK(thread_checker_.CalledOnValidThread()); |
| 229 // We can get into a situation where multiple CompositorFrames arrive for a | 249 // We can get into a situation where multiple CompositorFrames arrive for a |
| 230 // CompositorFrameSink before the DisplayCompositorClient can add any | 250 // CompositorFrameSink before the DisplayCompositorClient can add any |
| 231 // references for the frame. When the second frame with a new size arrives, | 251 // references for the frame. When the second frame with a new size arrives, |
| 232 // the first will be destroyed and then if there are no references it will be | 252 // the first will be destroyed and then if there are no references it will be |
| 233 // deleted during surface GC. A temporary reference, removed when a real | 253 // deleted during surface GC. A temporary reference, removed when a real |
| 234 // reference is received, is added to prevent this from happening. | 254 // reference is received, is added to prevent this from happening. |
| 235 reference_manager_->AddSurfaceReference(GetRootSurfaceId(), surface_id); | 255 reference_manager_->AddSurfaceReference(GetRootSurfaceId(), surface_id); |
| 236 temp_references_[surface_id.frame_sink_id()].push_back( | 256 temp_references_[surface_id.frame_sink_id()].push_back( |
| 237 surface_id.local_frame_id()); | 257 surface_id.local_frame_id()); |
| 238 | 258 |
| 239 if (client_) | 259 if (client_) |
| 240 client_->OnSurfaceCreated(surface_id, frame_size, device_scale_factor); | 260 client_->OnSurfaceCreated(surface_id, frame_size, device_scale_factor); |
| 241 } | 261 } |
| 242 | 262 |
| 243 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id, | 263 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id, |
| 244 bool* changed) {} | 264 bool* changed) {} |
| 245 | 265 |
| 246 } // namespace ui | 266 } // namespace ui |
| OLD | NEW |