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