| 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 "components/viz/frame_sinks/mojo_frame_sink_manager.h" | 5 #include "components/viz/frame_sinks/mojo_frame_sink_manager.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 "cc/base/switches.h" | 11 #include "cc/base/switches.h" |
| 12 #include "cc/scheduler/begin_frame_source.h" | 12 #include "cc/scheduler/begin_frame_source.h" |
| 13 #include "cc/surfaces/display.h" | 13 #include "cc/surfaces/display.h" |
| 14 #include "cc/surfaces/surface_dependency_tracker.h" | 14 #include "cc/surfaces/surface_dependency_tracker.h" |
| 15 #include "components/viz/frame_sinks/display_provider.h" | 15 #include "components/viz/frame_sinks/display_provider.h" |
| 16 #include "components/viz/frame_sinks/gpu_compositor_frame_sink.h" | 16 #include "components/viz/frame_sinks/gpu_compositor_frame_sink.h" |
| 17 #include "components/viz/frame_sinks/gpu_root_compositor_frame_sink.h" | 17 #include "components/viz/frame_sinks/gpu_root_compositor_frame_sink.h" |
| 18 | 18 |
| 19 namespace viz { | 19 namespace viz { |
| 20 | 20 |
| 21 MojoFrameSinkManager::MojoFrameSinkManager( | 21 MojoFrameSinkManager::MojoFrameSinkManager(bool use_surface_references, |
| 22 bool use_surface_references, | 22 DisplayProvider* display_provider) |
| 23 DisplayProvider* display_provider, | |
| 24 cc::mojom::FrameSinkManagerRequest request, | |
| 25 cc::mojom::FrameSinkManagerClientPtr client) | |
| 26 : manager_(use_surface_references | 23 : manager_(use_surface_references |
| 27 ? cc::SurfaceManager::LifetimeType::REFERENCES | 24 ? cc::SurfaceManager::LifetimeType::REFERENCES |
| 28 : cc::SurfaceManager::LifetimeType::SEQUENCES), | 25 : cc::SurfaceManager::LifetimeType::SEQUENCES), |
| 29 display_provider_(display_provider), | 26 display_provider_(display_provider), |
| 30 client_(std::move(client)), | 27 binding_(this) { |
| 31 binding_(this, std::move(request)) { | |
| 32 manager_.AddObserver(this); | 28 manager_.AddObserver(this); |
| 33 } | 29 } |
| 34 | 30 |
| 35 MojoFrameSinkManager::~MojoFrameSinkManager() { | 31 MojoFrameSinkManager::~MojoFrameSinkManager() { |
| 36 DCHECK(thread_checker_.CalledOnValidThread()); | 32 DCHECK(thread_checker_.CalledOnValidThread()); |
| 37 manager_.RemoveObserver(this); | 33 manager_.RemoveObserver(this); |
| 38 } | 34 } |
| 39 | 35 |
| 36 void MojoFrameSinkManager::Connect( |
| 37 cc::mojom::FrameSinkManagerRequest request, |
| 38 cc::mojom::FrameSinkManagerClientPtr client) { |
| 39 DCHECK(!binding_.is_bound()); |
| 40 binding_.Bind(std::move(request)); |
| 41 client_ = std::move(client); |
| 42 } |
| 43 |
| 40 void MojoFrameSinkManager::CreateRootCompositorFrameSink( | 44 void MojoFrameSinkManager::CreateRootCompositorFrameSink( |
| 41 const cc::FrameSinkId& frame_sink_id, | 45 const cc::FrameSinkId& frame_sink_id, |
| 42 gpu::SurfaceHandle surface_handle, | 46 gpu::SurfaceHandle surface_handle, |
| 43 cc::mojom::MojoCompositorFrameSinkAssociatedRequest request, | 47 cc::mojom::MojoCompositorFrameSinkAssociatedRequest request, |
| 44 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, | 48 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, |
| 45 cc::mojom::MojoCompositorFrameSinkClientPtr client, | 49 cc::mojom::MojoCompositorFrameSinkClientPtr client, |
| 46 cc::mojom::DisplayPrivateAssociatedRequest display_private_request) { | 50 cc::mojom::DisplayPrivateAssociatedRequest display_private_request) { |
| 47 DCHECK(thread_checker_.CalledOnValidThread()); | 51 DCHECK(thread_checker_.CalledOnValidThread()); |
| 48 DCHECK_NE(surface_handle, gpu::kNullSurfaceHandle); | 52 DCHECK_NE(surface_handle, gpu::kNullSurfaceHandle); |
| 49 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); | 53 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 142 |
| 139 void MojoFrameSinkManager::OnPrivateConnectionLost( | 143 void MojoFrameSinkManager::OnPrivateConnectionLost( |
| 140 const cc::FrameSinkId& frame_sink_id, | 144 const cc::FrameSinkId& frame_sink_id, |
| 141 bool destroy_compositor_frame_sink) { | 145 bool destroy_compositor_frame_sink) { |
| 142 DCHECK(thread_checker_.CalledOnValidThread()); | 146 DCHECK(thread_checker_.CalledOnValidThread()); |
| 143 if (destroy_compositor_frame_sink) | 147 if (destroy_compositor_frame_sink) |
| 144 DestroyCompositorFrameSink(frame_sink_id); | 148 DestroyCompositorFrameSink(frame_sink_id); |
| 145 } | 149 } |
| 146 | 150 |
| 147 } // namespace viz | 151 } // namespace viz |
| OLD | NEW |