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

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

Issue 2445093002: cc/blimp: Add synchronization for scroll/scale state. (Closed)
Patch Set: move application of deltas to push time. 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 // right after the update is processed by the bridge. 408 // right after the update is processed by the bridge.
408 // TODO(khushalsagar): We can not really know what these callbacks end up 409 // TODO(khushalsagar): We can not really know what these callbacks end up
409 // being used for. Consider migrating clients to understand/cope with the fact 410 // being used for. Consider migrating clients to understand/cope with the fact
410 // that there is no actual compositing happening here. 411 // that there is no actual compositing happening here.
411 task_runner_provider_->MainThreadTaskRunner()->PostTask( 412 task_runner_provider_->MainThreadTaskRunner()->PostTask(
412 FROM_HERE, 413 FROM_HERE,
413 base::Bind(&LayerTreeHostRemote::DispatchDrawAndSubmitCallbacks, 414 base::Bind(&LayerTreeHostRemote::DispatchDrawAndSubmitCallbacks,
414 weak_factory_.GetWeakPtr())); 415 weak_factory_.GetWeakPtr()));
415 } 416 }
416 417
417 bool LayerTreeHostRemote::ApplyScrollAndScaleUpdateFromClient( 418 void LayerTreeHostRemote::ApplyStateUpdateFromClient(
418 const ScrollOffsetMap& client_scroll_map, 419 const proto::ClientStateUpdate& client_state_update) {
419 float client_page_scale) {
420 DCHECK(!synchronizing_client_updates_); 420 DCHECK(!synchronizing_client_updates_);
421
422 base::AutoReset<bool> synchronizing_updates(&synchronizing_client_updates_, 421 base::AutoReset<bool> synchronizing_updates(&synchronizing_client_updates_,
423 true); 422 true);
424 bool layer_sync_successful = true;
425 423
426 gfx::Vector2dF inner_viewport_scroll_delta; 424 gfx::Vector2d inner_viewport_delta;
aelias_OOO_until_Jul13 2016/10/28 03:40:20 gfx::Vector2dF
Khushal 2016/10/31 21:02:01 Done.
427 Layer* inner_viewport_scroll_layer = 425 for (int i = 0; i < client_state_update.scroll_updates_size(); ++i) {
428 layer_tree_->inner_viewport_scroll_layer(); 426 const proto::ScrollUpdate& scroll_update =
429 for (const auto& client_scroll : client_scroll_map) { 427 client_state_update.scroll_updates(i);
430 Layer* layer = layer_tree_->LayerById(client_scroll.first); 428 int layer_id = scroll_update.layer_id();
431 const gfx::ScrollOffset& scroll_offset = client_scroll.second; 429 Layer* layer = layer_tree_->LayerById(layer_id);
430 gfx::Vector2d scroll_delta = ProtoToVector2d(scroll_update.scroll_delta());
aelias_OOO_until_Jul13 2016/10/28 03:40:20 gfx::Vector2dF
Khushal 2016/10/31 21:02:01 Done.
432 431
433 // Note the inner viewport scroll delta to report separately. 432 if (!layer)
434 if (layer == inner_viewport_scroll_layer) { 433 continue;
435 inner_viewport_scroll_delta = 434
436 scroll_offset.DeltaFrom(layer->scroll_offset()); 435 if (layer == layer_tree_->inner_viewport_scroll_layer()) {
436 inner_viewport_delta = scroll_delta;
437 } else {
438 layer->SetScrollOffsetFromImplSide(
439 gfx::ScrollOffsetWithDelta(layer->scroll_offset(), scroll_delta));
440 SetNeedsUpdateLayers();
437 } 441 }
442 }
438 443
439 if (layer) 444 if (!inner_viewport_delta.IsZero()) {
440 layer->SetScrollOffsetFromImplSide(scroll_offset); 445 layer_tree_->inner_viewport_scroll_layer()->SetScrollOffsetFromImplSide(
441 else 446 gfx::ScrollOffsetWithDelta(
442 layer_sync_successful = false; 447 layer_tree_->inner_viewport_scroll_layer()->scroll_offset(),
448 inner_viewport_delta));
443 } 449 }
444 450
445 float page_scale_delta = 1.0f; 451 float page_scale_delta = 1.0f;
446 if (client_page_scale != layer_tree_->page_scale_factor()) { 452 if (client_state_update.has_page_scale_delta()) {
447 page_scale_delta = client_page_scale / layer_tree_->page_scale_factor(); 453 page_scale_delta = client_state_update.page_scale_delta();
448 layer_tree_->SetPageScaleFromImplSide(client_page_scale); 454 layer_tree_->SetPageScaleFromImplSide(layer_tree_->page_scale_factor() *
455 page_scale_delta);
449 } 456 }
450 457
451 if (!inner_viewport_scroll_delta.IsZero() || page_scale_delta != 1.0f) { 458 if (!inner_viewport_delta.IsZero() || page_scale_delta != 1.0f) {
452 client_->ApplyViewportDeltas(inner_viewport_scroll_delta, gfx::Vector2dF(), 459 client_->ApplyViewportDeltas(inner_viewport_delta, gfx::Vector2dF(),
453 gfx::Vector2dF(), page_scale_delta, 1.0f); 460 gfx::Vector2dF(), page_scale_delta, 0.0f);
461 SetNeedsUpdateLayers();
454 } 462 }
455
456 return layer_sync_successful;
457 } 463 }
458 464
459 void LayerTreeHostRemote::MainFrameComplete() { 465 void LayerTreeHostRemote::MainFrameComplete() {
460 DCHECK_EQ(current_pipeline_stage_, FramePipelineStage::COMMIT); 466 DCHECK_EQ(current_pipeline_stage_, FramePipelineStage::COMMIT);
461 467
462 current_pipeline_stage_ = FramePipelineStage::NONE; 468 current_pipeline_stage_ = FramePipelineStage::NONE;
463 max_pipeline_stage_for_current_frame_ = FramePipelineStage::NONE; 469 max_pipeline_stage_for_current_frame_ = FramePipelineStage::NONE;
464 source_frame_number_++; 470 source_frame_number_++;
465 471
466 client_->DidCommit(); 472 client_->DidCommit();
(...skipping 25 matching lines...) Expand all
492 layer_tree_host_proto->mutable_layer_updates(), inputs_only); 498 layer_tree_host_proto->mutable_layer_updates(), inputs_only);
493 layer_tree_->LayersThatShouldPushProperties().clear(); 499 layer_tree_->LayersThatShouldPushProperties().clear();
494 500
495 std::vector<PictureData> pictures = 501 std::vector<PictureData> pictures =
496 engine_picture_cache_->CalculateCacheUpdateAndFlush(); 502 engine_picture_cache_->CalculateCacheUpdateAndFlush();
497 proto::PictureDataVectorToSkPicturesProto( 503 proto::PictureDataVectorToSkPicturesProto(
498 pictures, layer_tree_host_proto->mutable_pictures()); 504 pictures, layer_tree_host_proto->mutable_pictures());
499 } 505 }
500 506
501 } // namespace cc 507 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698