| OLD | NEW |
| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 // Send any scroll/scale updates first. |
| 66 layer_tree_host_remote_->ApplyUpdatesFromInProcessHost(); | 66 layer_tree_host_remote_->ApplyUpdatesFromInProcessHost(); |
| 67 layer_tree_host_remote_->BeginMainFrame(); | 67 layer_tree_host_remote_->BeginMainFrame(); |
| 68 } | 68 } |
| 69 void BeginMainFrameNotExpectedSoon() override {} | 69 void BeginMainFrameNotExpectedSoon() override {} |
| 70 void DidBeginMainFrame() override {} | 70 void DidBeginMainFrame() override {} |
| 71 void UpdateLayerTreeHost() override { | 71 void UpdateLayerTreeHost() override {} |
| 72 layer_tree_host_remote_->UpdateStateOnInProcessHost(); | |
| 73 } | |
| 74 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, | 72 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, |
| 75 const gfx::Vector2dF& outer_delta, | 73 const gfx::Vector2dF& outer_delta, |
| 76 const gfx::Vector2dF& elastic_overscroll_delta, | 74 const gfx::Vector2dF& elastic_overscroll_delta, |
| 77 float page_scale, | 75 float page_scale, |
| 78 float top_controls_delta) override {} | 76 float top_controls_delta) override {} |
| 79 void RequestNewCompositorFrameSink() override { | 77 void RequestNewCompositorFrameSink() override { |
| 80 layer_tree_host_remote_->client()->RequestNewCompositorFrameSink(); | 78 layer_tree_host_remote_->client()->RequestNewCompositorFrameSink(); |
| 81 } | 79 } |
| 82 void DidInitializeCompositorFrameSink() override { | 80 void DidInitializeCompositorFrameSink() override { |
| 83 layer_tree_host_remote_->client()->DidInitializeCompositorFrameSink(); | 81 layer_tree_host_remote_->client()->DidInitializeCompositorFrameSink(); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 layer_tree_host_in_process_->GetLayerTree()->page_scale_factor()); | 281 layer_tree_host_in_process_->GetLayerTree()->page_scale_factor()); |
| 284 layers_scrolled_.clear(); | 282 layers_scrolled_.clear(); |
| 285 } | 283 } |
| 286 | 284 |
| 287 void LayerTreeHostRemoteForTesting::RemoteHostNeedsMainFrame() { | 285 void LayerTreeHostRemoteForTesting::RemoteHostNeedsMainFrame() { |
| 288 layer_tree_host_in_process_->SetNeedsAnimate(); | 286 layer_tree_host_in_process_->SetNeedsAnimate(); |
| 289 } | 287 } |
| 290 | 288 |
| 291 void LayerTreeHostRemoteForTesting::ProcessRemoteCompositorUpdate( | 289 void LayerTreeHostRemoteForTesting::ProcessRemoteCompositorUpdate( |
| 292 std::unique_ptr<CompositorProtoState> compositor_proto_state) { | 290 std::unique_ptr<CompositorProtoState> compositor_proto_state) { |
| 293 pending_compositor_proto_state_ = std::move(compositor_proto_state); | 291 DCHECK(layer_tree_host_in_process_->CommitRequested()); |
| 294 } | 292 // Deserialize the update from the remote host into client side LTH in |
| 293 // process. This bypasses the network layer. |
| 294 const proto::LayerTreeHost& layer_tree_host_proto = |
| 295 compositor_proto_state->compositor_message->layer_tree_host(); |
| 296 compositor_state_deserializer_->DeserializeCompositorUpdate( |
| 297 layer_tree_host_proto); |
| 295 | 298 |
| 296 void LayerTreeHostRemoteForTesting::UpdateStateOnInProcessHost() { | 299 const proto::LayerUpdate& layer_updates = |
| 297 // When the InProcess host asks us to update, we de-serialize the update from | 300 compositor_proto_state->compositor_message->layer_tree_host() |
| 298 // the remote host. | 301 .layer_updates(); |
| 299 if (pending_compositor_proto_state_) { | 302 for (int i = 0; i < layer_updates.layers_size(); ++i) { |
| 300 const proto::LayerTreeHost& layer_tree_host_proto = | 303 int engine_layer_id = layer_updates.layers(i).id(); |
| 301 pending_compositor_proto_state_->compositor_message->layer_tree_host(); | 304 Layer* engine_layer = GetLayerTree()->LayerById(engine_layer_id); |
| 302 compositor_state_deserializer_->DeserializeCompositorUpdate( | 305 Layer* client_layer = |
| 303 layer_tree_host_proto); | 306 compositor_state_deserializer_->GetLayerForEngineId(engine_layer_id); |
| 304 | 307 |
| 305 pending_compositor_proto_state_ = nullptr; | 308 // Copy test only layer data that are not serialized into network messages. |
| 309 // So in test cases, layers on the client have the same states as their |
| 310 // corresponding layers on the engine. |
| 311 client_layer->SetForceRenderSurfaceForTesting( |
| 312 engine_layer->force_render_surface_for_testing()); |
| 313 } |
| 306 | 314 |
| 307 // The only case where the remote host would give a compositor update is if | 315 // The only case where the remote host would give a compositor update is if |
| 308 // they wanted the main frame to go till the commit pipeline stage. So | 316 // they wanted the main frame to go till the commit pipeline stage. So |
| 309 // request one to make sure that the in process main frame also goes till | 317 // request one to make sure that the in process main frame also goes till |
| 310 // the commit step. | 318 // the commit step. |
| 311 layer_tree_host_in_process_->SetNeedsCommit(); | 319 layer_tree_host_in_process_->SetNeedsCommit(); |
| 312 } | |
| 313 } | 320 } |
| 314 | 321 |
| 315 } // namespace cc | 322 } // namespace cc |
| OLD | NEW |