Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: cc/test/layer_tree_host_remote_for_testing.cc

Issue 2445093002: cc/blimp: Add synchronization for scroll/scale state. (Closed)
Patch Set: test compile Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/test/layer_tree_host_remote_for_testing.h ('k') | cc/trees/layer_tree.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "cc/test/layer_tree_host_remote_for_testing.h" 5 #include "cc/test/layer_tree_host_remote_for_testing.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "cc/animation/animation_host.h" 8 #include "cc/animation/animation_host.h"
9 #include "cc/blimp/compositor_proto_state.h" 9 #include "cc/blimp/compositor_proto_state.h"
10 #include "cc/blimp/compositor_state_deserializer.h" 10 #include "cc/blimp/compositor_state_deserializer.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 : public LayerTreeHostClient { 55 : public LayerTreeHostClient {
56 public: 56 public:
57 LayerTreeHostInProcessClient( 57 LayerTreeHostInProcessClient(
58 LayerTreeHostRemoteForTesting* layer_tree_host_remote) 58 LayerTreeHostRemoteForTesting* layer_tree_host_remote)
59 : layer_tree_host_remote_(layer_tree_host_remote) {} 59 : layer_tree_host_remote_(layer_tree_host_remote) {}
60 60
61 ~LayerTreeHostInProcessClient() override = default; 61 ~LayerTreeHostInProcessClient() override = default;
62 62
63 void WillBeginMainFrame() override {} 63 void WillBeginMainFrame() override {}
64 void BeginMainFrame(const BeginFrameArgs& args) override { 64 void BeginMainFrame(const BeginFrameArgs& args) override {
65 // Send any scroll/scale updates first. 65 layer_tree_host_remote_->BeginRemoteMainFrame();
66 layer_tree_host_remote_->ApplyUpdatesFromInProcessHost();
67 layer_tree_host_remote_->BeginMainFrame();
68 } 66 }
69 void BeginMainFrameNotExpectedSoon() override {} 67 void BeginMainFrameNotExpectedSoon() override {}
70 void DidBeginMainFrame() override {} 68 void DidBeginMainFrame() override {}
71 void UpdateLayerTreeHost() override {} 69 void UpdateLayerTreeHost() override {}
72 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, 70 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
73 const gfx::Vector2dF& outer_delta, 71 const gfx::Vector2dF& outer_delta,
74 const gfx::Vector2dF& elastic_overscroll_delta, 72 const gfx::Vector2dF& elastic_overscroll_delta,
75 float page_scale, 73 float page_scale,
76 float top_controls_delta) override {} 74 float top_controls_delta) override {}
77 void RequestNewCompositorFrameSink() override { 75 void RequestNewCompositorFrameSink() override {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 static_cast<RemoteCompositorBridgeImpl*>(remote_compositor_bridge()); 199 static_cast<RemoteCompositorBridgeImpl*>(remote_compositor_bridge());
202 remote_compositor_bridge_impl->SetRemoteHost(this); 200 remote_compositor_bridge_impl->SetRemoteHost(this);
203 201
204 layer_tree_host_in_process_ = CreateLayerTreeHostInProcess( 202 layer_tree_host_in_process_ = CreateLayerTreeHostInProcess(
205 layer_tree_host_in_process_client_.get(), task_graph_runner, 203 layer_tree_host_in_process_client_.get(), task_graph_runner,
206 GetSettings(), main_task_runner, impl_task_runner); 204 GetSettings(), main_task_runner, impl_task_runner);
207 205
208 compositor_state_deserializer_ = 206 compositor_state_deserializer_ =
209 base::MakeUnique<CompositorStateDeserializer>( 207 base::MakeUnique<CompositorStateDeserializer>(
210 layer_tree_host_in_process_.get(), 208 layer_tree_host_in_process_.get(),
211 image_serialization_processor_->CreateClientPictureCache(), 209 image_serialization_processor_->CreateClientPictureCache(), this);
212 base::Bind(&LayerTreeHostRemoteForTesting::LayerDidScroll,
213 base::Unretained(this)),
214 this);
215 210
216 // Override the LayerFactory since a lot of tests rely on the fact that Layers 211 // Override the LayerFactory since a lot of tests rely on the fact that Layers
217 // and LayerImpls have matching ids. 212 // and LayerImpls have matching ids.
218 compositor_state_deserializer_->SetLayerFactoryForTesting( 213 compositor_state_deserializer_->SetLayerFactoryForTesting(
219 base::MakeUnique<RemoteClientLayerFactory>()); 214 base::MakeUnique<RemoteClientLayerFactory>());
220 215
221 // Override the TaskRunnerProvider since tests may rely on accessing the impl 216 // Override the TaskRunnerProvider since tests may rely on accessing the impl
222 // task runner using it. 217 // task runner using it.
223 SetTaskRunnerProviderForTesting( 218 SetTaskRunnerProviderForTesting(
224 TaskRunnerProvider::Create(main_task_runner, impl_task_runner)); 219 TaskRunnerProvider::Create(main_task_runner, impl_task_runner));
(...skipping 10 matching lines...) Expand all
235 230
236 params.client = client; 231 params.client = client;
237 params.task_graph_runner = task_graph_runner; 232 params.task_graph_runner = task_graph_runner;
238 params.settings = &settings; 233 params.settings = &settings;
239 params.main_task_runner = main_task_runner; 234 params.main_task_runner = main_task_runner;
240 params.animation_host = AnimationHost::CreateMainInstance(); 235 params.animation_host = AnimationHost::CreateMainInstance();
241 236
242 return LayerTreeHostInProcess::CreateThreaded(impl_task_runner, &params); 237 return LayerTreeHostInProcess::CreateThreaded(impl_task_runner, &params);
243 } 238 }
244 239
240 void LayerTreeHostRemoteForTesting::DidUpdateLocalState() {
241 client_state_dirty_ = true;
242 }
243
245 void LayerTreeHostRemoteForTesting::DispatchDrawAndSubmitCallbacks() { 244 void LayerTreeHostRemoteForTesting::DispatchDrawAndSubmitCallbacks() {
246 // Don't dispatch callbacks right after the commit on the remote host. Since 245 // Don't dispatch callbacks right after the commit on the remote host. Since
247 // tests rely on CompositorFrames being swapped on the CompositorFrameSink, 246 // tests rely on CompositorFrames being swapped on the CompositorFrameSink,
248 // we wait for these callbacks from the LayerTreeHostInProcess. 247 // we wait for these callbacks from the LayerTreeHostInProcess.
249 } 248 }
250 249
251 bool LayerTreeHostRemoteForTesting::ShouldRetainClientScroll( 250 void LayerTreeHostRemoteForTesting::RemoteHostNeedsMainFrame() {
252 int engine_layer_id, 251 layer_tree_host_in_process_->SetNeedsAnimate();
253 const gfx::ScrollOffset& new_offset) {
254 return false;
255 } 252 }
256 253
257 bool LayerTreeHostRemoteForTesting::ShouldRetainClientPageScale( 254 void LayerTreeHostRemoteForTesting::BeginRemoteMainFrame() {
258 float new_page_scale) { 255 // Send scroll/scale updates first if modified on the impl thread.
259 return false; 256 if (client_state_dirty_) {
260 } 257 client_state_dirty_ = false;
258 proto::ClientStateUpdate client_state_update;
259 compositor_state_deserializer_->PullClientStateUpdate(&client_state_update);
260 ApplyStateUpdateFromClient(client_state_update);
261 261
262 void LayerTreeHostRemoteForTesting::LayerDidScroll(int engine_layer_id) { 262 // Tell the host on the client that the updates were applied to the state
263 layers_scrolled_[engine_layer_id] = 263 // on the remote host, in case the main frame on the remote host is aborted.
264 compositor_state_deserializer_->GetLayerForEngineId(engine_layer_id) 264 compositor_state_deserializer_->DidApplyStateUpdatesOnEngine();
265 ->scroll_offset(); 265 }
266 }
267 266
268 void LayerTreeHostRemoteForTesting::ApplyUpdatesFromInProcessHost() { 267 BeginMainFrame();
269 ApplyScrollAndScaleUpdateFromClient(
270 layers_scrolled_,
271 layer_tree_host_in_process_->GetLayerTree()->page_scale_factor());
272 layers_scrolled_.clear();
273 }
274
275 void LayerTreeHostRemoteForTesting::RemoteHostNeedsMainFrame() {
276 layer_tree_host_in_process_->SetNeedsAnimate();
277 } 268 }
278 269
279 void LayerTreeHostRemoteForTesting::ProcessRemoteCompositorUpdate( 270 void LayerTreeHostRemoteForTesting::ProcessRemoteCompositorUpdate(
280 std::unique_ptr<CompositorProtoState> compositor_proto_state) { 271 std::unique_ptr<CompositorProtoState> compositor_proto_state) {
281 DCHECK(layer_tree_host_in_process_->CommitRequested()); 272 DCHECK(layer_tree_host_in_process_->CommitRequested());
273
282 // Deserialize the update from the remote host into client side LTH in 274 // Deserialize the update from the remote host into client side LTH in
283 // process. This bypasses the network layer. 275 // process. This bypasses the network layer.
284 const proto::LayerTreeHost& layer_tree_host_proto = 276 const proto::LayerTreeHost& layer_tree_host_proto =
285 compositor_proto_state->compositor_message->layer_tree_host(); 277 compositor_proto_state->compositor_message->layer_tree_host();
286 compositor_state_deserializer_->DeserializeCompositorUpdate( 278 compositor_state_deserializer_->DeserializeCompositorUpdate(
287 layer_tree_host_proto); 279 layer_tree_host_proto);
288 280
289 const proto::LayerUpdate& layer_updates = 281 const proto::LayerUpdate& layer_updates =
290 compositor_proto_state->compositor_message->layer_tree_host() 282 compositor_proto_state->compositor_message->layer_tree_host()
291 .layer_updates(); 283 .layer_updates();
(...skipping 11 matching lines...) Expand all
303 } 295 }
304 296
305 // The only case where the remote host would give a compositor update is if 297 // The only case where the remote host would give a compositor update is if
306 // they wanted the main frame to go till the commit pipeline stage. So 298 // they wanted the main frame to go till the commit pipeline stage. So
307 // request one to make sure that the in process main frame also goes till 299 // request one to make sure that the in process main frame also goes till
308 // the commit step. 300 // the commit step.
309 layer_tree_host_in_process_->SetNeedsCommit(); 301 layer_tree_host_in_process_->SetNeedsCommit();
310 } 302 }
311 303
312 } // namespace cc 304 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_host_remote_for_testing.h ('k') | cc/trees/layer_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698