Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 39 DCHECK(display_begin_frame_source_); | 42 DCHECK(display_begin_frame_source_); |
| 40 compositor_frame_sink_binding_.set_connection_error_handler( | 43 compositor_frame_sink_binding_.set_connection_error_handler( |
| 41 base::Bind(&GpuRootCompositorFrameSink::OnClientConnectionLost, | 44 base::Bind(&GpuRootCompositorFrameSink::OnClientConnectionLost, |
| 42 base::Unretained(this))); | 45 base::Unretained(this))); |
| 43 compositor_frame_sink_private_binding_.set_connection_error_handler( | 46 compositor_frame_sink_private_binding_.set_connection_error_handler( |
| 44 base::Bind(&GpuRootCompositorFrameSink::OnPrivateConnectionLost, | 47 base::Bind(&GpuRootCompositorFrameSink::OnPrivateConnectionLost, |
| 45 base::Unretained(this))); | 48 base::Unretained(this))); |
| 46 surface_manager->RegisterBeginFrameSource(display_begin_frame_source_.get(), | 49 surface_manager->RegisterBeginFrameSource(display_begin_frame_source_.get(), |
| 47 frame_sink_id); | 50 frame_sink_id); |
| 48 display_->Initialize(this, surface_manager); | 51 display_->Initialize(this, surface_manager); |
| 52 | |
| 53 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
|
Fady Samuel
2017/06/15 15:02:40
We are about to introduce a bunch of flags. I sug
gklassen
2017/06/15 19:40:17
Ok. Can you send me a pointer to a pattern to fol
| |
| 54 switches::kUseVizHitTest)) { | |
| 55 auto display_hit_test_data_factory = | |
| 56 base::MakeUnique<hit_test::DisplayHitTestDataFactoryLocal>(); | |
| 57 hit_test_aggregator_ = base::MakeUnique<hit_test::HitTestAggregator>( | |
| 58 std::move(display_hit_test_data_factory)); | |
| 59 } | |
| 49 } | 60 } |
| 50 | 61 |
| 51 GpuRootCompositorFrameSink::~GpuRootCompositorFrameSink() { | 62 GpuRootCompositorFrameSink::~GpuRootCompositorFrameSink() { |
| 52 support_->surface_manager()->UnregisterBeginFrameSource( | 63 support_->surface_manager()->UnregisterBeginFrameSource( |
| 53 display_begin_frame_source_.get()); | 64 display_begin_frame_source_.get()); |
| 54 } | 65 } |
| 55 | 66 |
| 56 void GpuRootCompositorFrameSink::SetDisplayVisible(bool visible) { | 67 void GpuRootCompositorFrameSink::SetDisplayVisible(bool visible) { |
| 57 DCHECK(display_); | 68 DCHECK(display_); |
| 58 display_->SetVisible(visible); | 69 display_->SetVisible(visible); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 support_->RequestCopyOfSurface(std::move(request)); | 119 support_->RequestCopyOfSurface(std::move(request)); |
| 109 } | 120 } |
| 110 | 121 |
| 111 void GpuRootCompositorFrameSink::DisplayOutputSurfaceLost() { | 122 void GpuRootCompositorFrameSink::DisplayOutputSurfaceLost() { |
| 112 // TODO(staraz): Implement this. Client should hear about context/output | 123 // TODO(staraz): Implement this. Client should hear about context/output |
| 113 // surface lost. | 124 // surface lost. |
| 114 } | 125 } |
| 115 | 126 |
| 116 void GpuRootCompositorFrameSink::DisplayWillDrawAndSwap( | 127 void GpuRootCompositorFrameSink::DisplayWillDrawAndSwap( |
| 117 bool will_draw_and_swap, | 128 bool will_draw_and_swap, |
| 118 const cc::RenderPassList& render_pass) {} | 129 const cc::RenderPassList& render_pass) { |
| 130 if (hit_test_aggregator_) | |
| 131 hit_test_aggregator_->PostTaskAggregate(display_->CurrentSurfaceId()); | |
| 132 } | |
| 119 | 133 |
| 120 void GpuRootCompositorFrameSink::DisplayDidDrawAndSwap() {} | 134 void GpuRootCompositorFrameSink::DisplayDidDrawAndSwap() {} |
| 121 | 135 |
| 122 void GpuRootCompositorFrameSink::DidReceiveCompositorFrameAck( | 136 void GpuRootCompositorFrameSink::DidReceiveCompositorFrameAck( |
| 123 const cc::ReturnedResourceArray& resources) { | 137 const cc::ReturnedResourceArray& resources) { |
| 124 if (client_) | 138 if (client_) |
| 125 client_->DidReceiveCompositorFrameAck(resources); | 139 client_->DidReceiveCompositorFrameAck(resources); |
| 126 } | 140 } |
| 127 | 141 |
| 128 void GpuRootCompositorFrameSink::OnBeginFrame(const cc::BeginFrameArgs& args) { | 142 void GpuRootCompositorFrameSink::OnBeginFrame(const cc::BeginFrameArgs& args) { |
| 143 if (hit_test_aggregator_) | |
| 144 hit_test_aggregator_->Swap(); | |
| 129 if (client_) | 145 if (client_) |
| 130 client_->OnBeginFrame(args); | 146 client_->OnBeginFrame(args); |
| 131 } | 147 } |
| 132 | 148 |
| 133 void GpuRootCompositorFrameSink::ReclaimResources( | 149 void GpuRootCompositorFrameSink::ReclaimResources( |
| 134 const cc::ReturnedResourceArray& resources) { | 150 const cc::ReturnedResourceArray& resources) { |
| 135 if (client_) | 151 if (client_) |
| 136 client_->ReclaimResources(resources); | 152 client_->ReclaimResources(resources); |
| 137 } | 153 } |
| 138 | 154 |
| 139 void GpuRootCompositorFrameSink::WillDrawSurface( | 155 void GpuRootCompositorFrameSink::WillDrawSurface( |
| 140 const cc::LocalSurfaceId& local_surface_id, | 156 const cc::LocalSurfaceId& local_surface_id, |
| 141 const gfx::Rect& damage_rect) {} | 157 const gfx::Rect& damage_rect) {} |
| 142 | 158 |
| 143 void GpuRootCompositorFrameSink::OnClientConnectionLost() { | 159 void GpuRootCompositorFrameSink::OnClientConnectionLost() { |
| 144 client_connection_lost_ = true; | 160 client_connection_lost_ = true; |
| 145 // Request destruction of |this| only if both connections are lost. | 161 // Request destruction of |this| only if both connections are lost. |
| 146 delegate_->OnClientConnectionLost(support_->frame_sink_id(), | 162 delegate_->OnClientConnectionLost(support_->frame_sink_id(), |
| 147 private_connection_lost_); | 163 private_connection_lost_); |
| 148 } | 164 } |
| 149 | 165 |
| 150 void GpuRootCompositorFrameSink::OnPrivateConnectionLost() { | 166 void GpuRootCompositorFrameSink::OnPrivateConnectionLost() { |
| 151 private_connection_lost_ = true; | 167 private_connection_lost_ = true; |
| 152 // Request destruction of |this| only if both connections are lost. | 168 // Request destruction of |this| only if both connections are lost. |
| 153 delegate_->OnPrivateConnectionLost(support_->frame_sink_id(), | 169 delegate_->OnPrivateConnectionLost(support_->frame_sink_id(), |
| 154 client_connection_lost_); | 170 client_connection_lost_); |
| 155 } | 171 } |
| 156 | 172 |
| 157 } // namespace viz | 173 } // namespace viz |
| OLD | NEW |