| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/gpu_root_compositor_frame_sink.h" | 5 #include "components/viz/frame_sinks/gpu_root_compositor_frame_sink.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" |
| 7 #include "cc/surfaces/compositor_frame_sink_support.h" | 8 #include "cc/surfaces/compositor_frame_sink_support.h" |
| 8 #include "cc/surfaces/display.h" | 9 #include "cc/surfaces/display.h" |
| 10 #include "components/viz/base/switches.h" |
| 11 #include "components/viz/hit_test/display_hit_test_data_factory_local.h" |
| 9 | 12 |
| 10 namespace viz { | 13 namespace viz { |
| 11 | 14 |
| 12 GpuRootCompositorFrameSink::GpuRootCompositorFrameSink( | 15 GpuRootCompositorFrameSink::GpuRootCompositorFrameSink( |
| 13 GpuCompositorFrameSinkDelegate* delegate, | 16 GpuCompositorFrameSinkDelegate* delegate, |
| 14 cc::SurfaceManager* surface_manager, | 17 cc::SurfaceManager* surface_manager, |
| 15 const cc::FrameSinkId& frame_sink_id, | 18 const cc::FrameSinkId& frame_sink_id, |
| 16 std::unique_ptr<cc::Display> display, | 19 std::unique_ptr<cc::Display> display, |
| 17 std::unique_ptr<cc::BeginFrameSource> begin_frame_source, | 20 std::unique_ptr<cc::BeginFrameSource> begin_frame_source, |
| 18 cc::mojom::MojoCompositorFrameSinkAssociatedRequest request, | 21 cc::mojom::MojoCompositorFrameSinkAssociatedRequest request, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 37 std::move(compositor_frame_sink_private_request)), | 40 std::move(compositor_frame_sink_private_request)), |
| 38 display_private_binding_(this, std::move(display_private_request)) { | 41 display_private_binding_(this, std::move(display_private_request)) { |
| 39 compositor_frame_sink_binding_.set_connection_error_handler( | 42 compositor_frame_sink_binding_.set_connection_error_handler( |
| 40 base::Bind(&GpuRootCompositorFrameSink::OnClientConnectionLost, | 43 base::Bind(&GpuRootCompositorFrameSink::OnClientConnectionLost, |
| 41 base::Unretained(this))); | 44 base::Unretained(this))); |
| 42 compositor_frame_sink_private_binding_.set_connection_error_handler( | 45 compositor_frame_sink_private_binding_.set_connection_error_handler( |
| 43 base::Bind(&GpuRootCompositorFrameSink::OnPrivateConnectionLost, | 46 base::Bind(&GpuRootCompositorFrameSink::OnPrivateConnectionLost, |
| 44 base::Unretained(this))); | 47 base::Unretained(this))); |
| 45 display_->Initialize(this, surface_manager); | 48 display_->Initialize(this, surface_manager); |
| 46 display_->SetVisible(true); | 49 display_->SetVisible(true); |
| 50 |
| 51 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 52 viz::switches::kUseVizHitTest)) { |
| 53 auto display_hit_test_data_factory = |
| 54 base::MakeUnique<viz::hit_test::DisplayHitTestDataFactoryLocal>(); |
| 55 hit_test_aggregator_ = base::MakeUnique<hit_test::HitTestAggregator>( |
| 56 std::move(display_hit_test_data_factory)); |
| 57 } |
| 47 } | 58 } |
| 48 | 59 |
| 49 GpuRootCompositorFrameSink::~GpuRootCompositorFrameSink() = default; | 60 GpuRootCompositorFrameSink::~GpuRootCompositorFrameSink() = default; |
| 50 | 61 |
| 51 void GpuRootCompositorFrameSink::SetDisplayVisible(bool visible) { | 62 void GpuRootCompositorFrameSink::SetDisplayVisible(bool visible) { |
| 52 DCHECK(display_); | 63 DCHECK(display_); |
| 53 display_->SetVisible(visible); | 64 display_->SetVisible(visible); |
| 54 } | 65 } |
| 55 | 66 |
| 56 void GpuRootCompositorFrameSink::ResizeDisplay(const gfx::Size& size) { | 67 void GpuRootCompositorFrameSink::ResizeDisplay(const gfx::Size& size) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 support_->RequestCopyOfSurface(std::move(request)); | 118 support_->RequestCopyOfSurface(std::move(request)); |
| 108 } | 119 } |
| 109 | 120 |
| 110 void GpuRootCompositorFrameSink::DisplayOutputSurfaceLost() { | 121 void GpuRootCompositorFrameSink::DisplayOutputSurfaceLost() { |
| 111 // TODO(staraz): Implement this. Client should hear about context/output | 122 // TODO(staraz): Implement this. Client should hear about context/output |
| 112 // surface lost. | 123 // surface lost. |
| 113 } | 124 } |
| 114 | 125 |
| 115 void GpuRootCompositorFrameSink::DisplayWillDrawAndSwap( | 126 void GpuRootCompositorFrameSink::DisplayWillDrawAndSwap( |
| 116 bool will_draw_and_swap, | 127 bool will_draw_and_swap, |
| 117 const cc::RenderPassList& render_pass) {} | 128 const cc::RenderPassList& render_pass) { |
| 129 if (hit_test_aggregator_) |
| 130 hit_test_aggregator_->PostTaskAggregate(display_->CurrentSurfaceId()); |
| 131 } |
| 118 | 132 |
| 119 void GpuRootCompositorFrameSink::DisplayDidDrawAndSwap() {} | 133 void GpuRootCompositorFrameSink::DisplayDidDrawAndSwap() {} |
| 120 | 134 |
| 121 void GpuRootCompositorFrameSink::DidReceiveCompositorFrameAck( | 135 void GpuRootCompositorFrameSink::DidReceiveCompositorFrameAck( |
| 122 const cc::ReturnedResourceArray& resources) { | 136 const cc::ReturnedResourceArray& resources) { |
| 123 if (client_) | 137 if (client_) |
| 124 client_->DidReceiveCompositorFrameAck(resources); | 138 client_->DidReceiveCompositorFrameAck(resources); |
| 125 } | 139 } |
| 126 | 140 |
| 127 void GpuRootCompositorFrameSink::OnBeginFrame(const cc::BeginFrameArgs& args) { | 141 void GpuRootCompositorFrameSink::OnBeginFrame(const cc::BeginFrameArgs& args) { |
| 142 if (hit_test_aggregator_) |
| 143 hit_test_aggregator_->Swap(); |
| 128 if (client_) | 144 if (client_) |
| 129 client_->OnBeginFrame(args); | 145 client_->OnBeginFrame(args); |
| 130 } | 146 } |
| 131 | 147 |
| 132 void GpuRootCompositorFrameSink::ReclaimResources( | 148 void GpuRootCompositorFrameSink::ReclaimResources( |
| 133 const cc::ReturnedResourceArray& resources) { | 149 const cc::ReturnedResourceArray& resources) { |
| 134 if (client_) | 150 if (client_) |
| 135 client_->ReclaimResources(resources); | 151 client_->ReclaimResources(resources); |
| 136 } | 152 } |
| 137 | 153 |
| 138 void GpuRootCompositorFrameSink::WillDrawSurface( | 154 void GpuRootCompositorFrameSink::WillDrawSurface( |
| 139 const cc::LocalSurfaceId& local_surface_id, | 155 const cc::LocalSurfaceId& local_surface_id, |
| 140 const gfx::Rect& damage_rect) {} | 156 const gfx::Rect& damage_rect) {} |
| 141 | 157 |
| 142 void GpuRootCompositorFrameSink::OnClientConnectionLost() { | 158 void GpuRootCompositorFrameSink::OnClientConnectionLost() { |
| 143 client_connection_lost_ = true; | 159 client_connection_lost_ = true; |
| 144 // Request destruction of |this| only if both connections are lost. | 160 // Request destruction of |this| only if both connections are lost. |
| 145 delegate_->OnClientConnectionLost(support_->frame_sink_id(), | 161 delegate_->OnClientConnectionLost(support_->frame_sink_id(), |
| 146 private_connection_lost_); | 162 private_connection_lost_); |
| 147 } | 163 } |
| 148 | 164 |
| 149 void GpuRootCompositorFrameSink::OnPrivateConnectionLost() { | 165 void GpuRootCompositorFrameSink::OnPrivateConnectionLost() { |
| 150 private_connection_lost_ = true; | 166 private_connection_lost_ = true; |
| 151 // Request destruction of |this| only if both connections are lost. | 167 // Request destruction of |this| only if both connections are lost. |
| 152 delegate_->OnPrivateConnectionLost(support_->frame_sink_id(), | 168 delegate_->OnPrivateConnectionLost(support_->frame_sink_id(), |
| 153 client_connection_lost_); | 169 client_connection_lost_); |
| 154 } | 170 } |
| 155 | 171 |
| 156 } // namespace viz | 172 } // namespace viz |
| OLD | NEW |