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

Side by Side Diff: cc/blimp/layer_tree_host_remote.cc

Issue 2445093002: cc/blimp: Add synchronization for scroll/scale state. (Closed)
Patch Set: fix rebase upload 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
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/blimp/layer_tree_host_remote.h" 5 #include "cc/blimp/layer_tree_host_remote.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/auto_reset.h" 8 #include "base/auto_reset.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "cc/animation/animation_host.h" 10 #include "cc/animation/animation_host.h"
11 #include "cc/blimp/compositor_proto_state.h" 11 #include "cc/blimp/compositor_proto_state.h"
12 #include "cc/blimp/engine_picture_cache.h" 12 #include "cc/blimp/engine_picture_cache.h"
13 #include "cc/blimp/picture_data_conversions.h" 13 #include "cc/blimp/picture_data_conversions.h"
14 #include "cc/blimp/remote_compositor_bridge.h" 14 #include "cc/blimp/remote_compositor_bridge.h"
15 #include "cc/output/begin_frame_args.h" 15 #include "cc/output/begin_frame_args.h"
16 #include "cc/output/compositor_frame_sink.h" 16 #include "cc/output/compositor_frame_sink.h"
17 #include "cc/proto/compositor_message.pb.h" 17 #include "cc/proto/compositor_message.pb.h"
18 #include "cc/proto/gfx_conversions.h"
18 #include "cc/proto/layer_tree_host.pb.h" 19 #include "cc/proto/layer_tree_host.pb.h"
19 #include "cc/trees/layer_tree.h" 20 #include "cc/trees/layer_tree.h"
20 #include "cc/trees/layer_tree_host_client.h" 21 #include "cc/trees/layer_tree_host_client.h"
21 #include "cc/trees/layer_tree_host_common.h" 22 #include "cc/trees/layer_tree_host_common.h"
22 #include "cc/trees/task_runner_provider.h" 23 #include "cc/trees/task_runner_provider.h"
23 #include "ui/gfx/geometry/scroll_offset.h" 24 #include "ui/gfx/geometry/scroll_offset.h"
24 25
25 namespace cc { 26 namespace cc {
26 namespace { 27 namespace {
27 // We use a 16ms default frame interval because the rate at which the engine 28 // We use a 16ms default frame interval because the rate at which the engine
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // used here. 191 // used here.
191 // TODO(khushalsagar): The caller could be waiting for an Ack for this redraw. 192 // TODO(khushalsagar): The caller could be waiting for an Ack for this redraw.
192 // We need a better solution for this. See crbug.com/651141. 193 // We need a better solution for this. See crbug.com/651141.
193 NOTIMPLEMENTED(); 194 NOTIMPLEMENTED();
194 } 195 }
195 196
196 void LayerTreeHostRemote::SetNextCommitForcesRedraw() { 197 void LayerTreeHostRemote::SetNextCommitForcesRedraw() {
197 // Ideally the engine shouldn't need to care about draw requests at all. The 198 // Ideally the engine shouldn't need to care about draw requests at all. The
198 // compositor that produces CompositorFrames is on the client and draw 199 // compositor that produces CompositorFrames is on the client and draw
199 // requests should be made directly to it on the client itself. 200 // requests should be made directly to it on the client itself.
200 NOTREACHED(); 201 NOTIMPLEMENTED();
201 } 202 }
202 203
203 void LayerTreeHostRemote::NotifyInputThrottledUntilCommit() { 204 void LayerTreeHostRemote::NotifyInputThrottledUntilCommit() {
204 // This notification is used in the case where the renderer handles an input 205 // This notification is used in the case where the renderer handles an input
205 // event, and needs to send an Ack to the browser when the resulting main 206 // event, and needs to send an Ack to the browser when the resulting main
206 // frame is committed. If the compositor is taking too long on the pending 207 // frame is committed. If the compositor is taking too long on the pending
207 // tree, the commit processing will be delayed blocking all input as a result. 208 // tree, the commit processing will be delayed blocking all input as a result.
208 // So this is used to have the compositor activate the pending tree faster, so 209 // So this is used to have the compositor activate the pending tree faster, so
209 // the pending commit can be processed. 210 // the pending commit can be processed.
210 // In remote mode, we don't send such notifications to the client because the 211 // In remote mode, we don't send such notifications to the client because the
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 // right after the update is processed by the bridge. 409 // right after the update is processed by the bridge.
409 // TODO(khushalsagar): We can not really know what these callbacks end up 410 // TODO(khushalsagar): We can not really know what these callbacks end up
410 // being used for. Consider migrating clients to understand/cope with the fact 411 // being used for. Consider migrating clients to understand/cope with the fact
411 // that there is no actual compositing happening here. 412 // that there is no actual compositing happening here.
412 task_runner_provider_->MainThreadTaskRunner()->PostTask( 413 task_runner_provider_->MainThreadTaskRunner()->PostTask(
413 FROM_HERE, 414 FROM_HERE,
414 base::Bind(&LayerTreeHostRemote::DispatchDrawAndSubmitCallbacks, 415 base::Bind(&LayerTreeHostRemote::DispatchDrawAndSubmitCallbacks,
415 weak_factory_.GetWeakPtr())); 416 weak_factory_.GetWeakPtr()));
416 } 417 }
417 418
418 bool LayerTreeHostRemote::ApplyScrollAndScaleUpdateFromClient( 419 void LayerTreeHostRemote::ApplyStateUpdateFromClient(
419 const ScrollOffsetMap& client_scroll_map, 420 const proto::ClientStateUpdate& client_state_update) {
420 float client_page_scale) {
421 DCHECK(!synchronizing_client_updates_); 421 DCHECK(!synchronizing_client_updates_);
422
423 base::AutoReset<bool> synchronizing_updates(&synchronizing_client_updates_, 422 base::AutoReset<bool> synchronizing_updates(&synchronizing_client_updates_,
424 true); 423 true);
425 bool layer_sync_successful = true;
426 424
427 gfx::Vector2dF inner_viewport_scroll_delta; 425 gfx::Vector2dF inner_viewport_delta;
428 Layer* inner_viewport_scroll_layer = 426 for (int i = 0; i < client_state_update.scroll_updates_size(); ++i) {
429 layer_tree_->inner_viewport_scroll_layer(); 427 const proto::ScrollUpdate& scroll_update =
430 for (const auto& client_scroll : client_scroll_map) { 428 client_state_update.scroll_updates(i);
431 Layer* layer = layer_tree_->LayerById(client_scroll.first); 429 int layer_id = scroll_update.layer_id();
432 const gfx::ScrollOffset& scroll_offset = client_scroll.second; 430 Layer* layer = layer_tree_->LayerById(layer_id);
431 gfx::Vector2dF scroll_delta =
432 ProtoToVector2dF(scroll_update.scroll_delta());
433 433
434 // Note the inner viewport scroll delta to report separately. 434 if (!layer)
435 if (layer == inner_viewport_scroll_layer) { 435 continue;
436 inner_viewport_scroll_delta = 436
437 scroll_offset.DeltaFrom(layer->scroll_offset()); 437 if (layer == layer_tree_->inner_viewport_scroll_layer()) {
438 inner_viewport_delta = scroll_delta;
439 } else {
440 layer->SetScrollOffsetFromImplSide(
441 gfx::ScrollOffsetWithDelta(layer->scroll_offset(), scroll_delta));
442 SetNeedsUpdateLayers();
438 } 443 }
444 }
439 445
440 if (layer) 446 if (!inner_viewport_delta.IsZero()) {
441 layer->SetScrollOffsetFromImplSide(scroll_offset); 447 layer_tree_->inner_viewport_scroll_layer()->SetScrollOffsetFromImplSide(
442 else 448 gfx::ScrollOffsetWithDelta(
443 layer_sync_successful = false; 449 layer_tree_->inner_viewport_scroll_layer()->scroll_offset(),
450 inner_viewport_delta));
444 } 451 }
445 452
446 float page_scale_delta = 1.0f; 453 float page_scale_delta = 1.0f;
447 if (client_page_scale != layer_tree_->page_scale_factor()) { 454 if (client_state_update.has_page_scale_delta()) {
448 page_scale_delta = client_page_scale / layer_tree_->page_scale_factor(); 455 page_scale_delta = client_state_update.page_scale_delta();
449 layer_tree_->SetPageScaleFromImplSide(client_page_scale); 456 layer_tree_->SetPageScaleFromImplSide(layer_tree_->page_scale_factor() *
457 page_scale_delta);
450 } 458 }
451 459
452 if (!inner_viewport_scroll_delta.IsZero() || page_scale_delta != 1.0f) { 460 if (!inner_viewport_delta.IsZero() || page_scale_delta != 1.0f) {
453 client_->ApplyViewportDeltas(inner_viewport_scroll_delta, gfx::Vector2dF(), 461 client_->ApplyViewportDeltas(inner_viewport_delta, gfx::Vector2dF(),
454 gfx::Vector2dF(), page_scale_delta, 1.0f); 462 gfx::Vector2dF(), page_scale_delta, 0.0f);
463 SetNeedsUpdateLayers();
455 } 464 }
456
457 return layer_sync_successful;
458 } 465 }
459 466
460 void LayerTreeHostRemote::MainFrameComplete() { 467 void LayerTreeHostRemote::MainFrameComplete() {
461 DCHECK_EQ(current_pipeline_stage_, FramePipelineStage::COMMIT); 468 DCHECK_EQ(current_pipeline_stage_, FramePipelineStage::COMMIT);
462 469
463 current_pipeline_stage_ = FramePipelineStage::NONE; 470 current_pipeline_stage_ = FramePipelineStage::NONE;
464 max_pipeline_stage_for_current_frame_ = FramePipelineStage::NONE; 471 max_pipeline_stage_for_current_frame_ = FramePipelineStage::NONE;
465 source_frame_number_++; 472 source_frame_number_++;
466 473
467 client_->DidCommit(); 474 client_->DidCommit();
(...skipping 25 matching lines...) Expand all
493 layer_tree_host_proto->mutable_layer_updates(), inputs_only); 500 layer_tree_host_proto->mutable_layer_updates(), inputs_only);
494 layer_tree_->LayersThatShouldPushProperties().clear(); 501 layer_tree_->LayersThatShouldPushProperties().clear();
495 502
496 std::vector<PictureData> pictures = 503 std::vector<PictureData> pictures =
497 engine_picture_cache_->CalculateCacheUpdateAndFlush(); 504 engine_picture_cache_->CalculateCacheUpdateAndFlush();
498 proto::PictureDataVectorToSkPicturesProto( 505 proto::PictureDataVectorToSkPicturesProto(
499 pictures, layer_tree_host_proto->mutable_pictures()); 506 pictures, layer_tree_host_proto->mutable_pictures());
500 } 507 }
501 508
502 } // namespace cc 509 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698