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

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

Issue 2404953002: cc/blimp: Set up hooks for scroll/scale sync. (Closed)
Patch Set: Comments + Rebase Created 4 years, 2 months 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/blimp/layer_tree_host_remote.h ('k') | cc/blimp/layer_tree_host_remote_unittest.cc » ('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/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/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
9 #include "cc/animation/animation_host.h" 10 #include "cc/animation/animation_host.h"
10 #include "cc/blimp/compositor_proto_state.h" 11 #include "cc/blimp/compositor_proto_state.h"
11 #include "cc/blimp/engine_picture_cache.h" 12 #include "cc/blimp/engine_picture_cache.h"
12 #include "cc/blimp/picture_data_conversions.h" 13 #include "cc/blimp/picture_data_conversions.h"
13 #include "cc/blimp/remote_compositor_bridge.h" 14 #include "cc/blimp/remote_compositor_bridge.h"
14 #include "cc/output/begin_frame_args.h" 15 #include "cc/output/begin_frame_args.h"
15 #include "cc/output/compositor_frame_sink.h" 16 #include "cc/output/compositor_frame_sink.h"
16 #include "cc/proto/compositor_message.pb.h" 17 #include "cc/proto/compositor_message.pb.h"
17 #include "cc/proto/layer_tree_host.pb.h" 18 #include "cc/proto/layer_tree_host.pb.h"
18 #include "cc/trees/layer_tree.h" 19 #include "cc/trees/layer_tree.h"
19 #include "cc/trees/layer_tree_host_client.h" 20 #include "cc/trees/layer_tree_host_client.h"
20 #include "cc/trees/layer_tree_host_common.h" 21 #include "cc/trees/layer_tree_host_common.h"
21 #include "cc/trees/task_runner_provider.h" 22 #include "cc/trees/task_runner_provider.h"
23 #include "ui/gfx/geometry/scroll_offset.h"
22 24
23 namespace cc { 25 namespace cc {
24 namespace { 26 namespace {
25 // We use a 16ms default frame interval because the rate at which the engine 27 // We use a 16ms default frame interval because the rate at which the engine
26 // produces main frames doesn't matter. 28 // produces main frames doesn't matter.
27 base::TimeDelta kDefaultFrameInterval = base::TimeDelta::FromMilliseconds(16); 29 base::TimeDelta kDefaultFrameInterval = base::TimeDelta::FromMilliseconds(16);
28 30
29 static base::StaticAtomicSequenceNumber s_layer_tree_host_sequence_number; 31 static base::StaticAtomicSequenceNumber s_layer_tree_host_sequence_number;
30 } // namespace 32 } // namespace
31 33
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 void LayerTreeHostRemote::SetNeedsRecalculateRasterScales() { 156 void LayerTreeHostRemote::SetNeedsRecalculateRasterScales() {
155 // This is used by devtools to reraster content after changing device 157 // This is used by devtools to reraster content after changing device
156 // emulation modes, so doesn't need to be supported by Blimp. 158 // emulation modes, so doesn't need to be supported by Blimp.
157 } 159 }
158 160
159 bool LayerTreeHostRemote::BeginMainFrameRequested() const { 161 bool LayerTreeHostRemote::BeginMainFrameRequested() const {
160 return requested_pipeline_stage_for_next_frame_ != FramePipelineStage::NONE; 162 return requested_pipeline_stage_for_next_frame_ != FramePipelineStage::NONE;
161 } 163 }
162 164
163 bool LayerTreeHostRemote::CommitRequested() const { 165 bool LayerTreeHostRemote::CommitRequested() const {
164 return requested_pipeline_stage_for_next_frame_ == FramePipelineStage::COMMIT; 166 // We report that a commit is in progress when synchronizing scroll and scale
167 // updates because in threaded mode, scroll/scale synchronization from the
168 // impl thread happens only during the main frame.
169 return synchronizing_client_updates_ ||
170 requested_pipeline_stage_for_next_frame_ == FramePipelineStage::COMMIT;
165 } 171 }
166 172
167 void LayerTreeHostRemote::SetDeferCommits(bool defer_commits) { 173 void LayerTreeHostRemote::SetDeferCommits(bool defer_commits) {
168 defer_commits_ = defer_commits; 174 defer_commits_ = defer_commits;
169 ScheduleMainFrameIfNecessary(); 175 ScheduleMainFrameIfNecessary();
170 } 176 }
171 177
172 void LayerTreeHostRemote::LayoutAndUpdateLayers() { 178 void LayerTreeHostRemote::LayoutAndUpdateLayers() {
173 NOTREACHED() << "Only supported in single-threaded mode and this class" 179 NOTREACHED() << "Only supported in single-threaded mode and this class"
174 << " does not support single-thread since it is out of process"; 180 << " does not support single-thread since it is out of process";
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 // LayerTreeHostClient to throttle further frame updates, so dispatch them 411 // LayerTreeHostClient to throttle further frame updates, so dispatch them
406 // right after the update is processed by the bridge. 412 // right after the update is processed by the bridge.
407 // TODO(khushalsagar): We can not really know what these callbacks end up 413 // TODO(khushalsagar): We can not really know what these callbacks end up
408 // being used for. Consider migrating clients to understand/cope with the fact 414 // being used for. Consider migrating clients to understand/cope with the fact
409 // that there is no actual compositing happening here. 415 // that there is no actual compositing happening here.
410 task_runner_provider_->MainThreadTaskRunner()->PostTask( 416 task_runner_provider_->MainThreadTaskRunner()->PostTask(
411 FROM_HERE, base::Bind(&LayerTreeHostRemote::DispatchDrawAndSwapCallbacks, 417 FROM_HERE, base::Bind(&LayerTreeHostRemote::DispatchDrawAndSwapCallbacks,
412 weak_factory_.GetWeakPtr())); 418 weak_factory_.GetWeakPtr()));
413 } 419 }
414 420
421 bool LayerTreeHostRemote::ApplyScrollAndScaleUpdateFromClient(
422 const ScrollOffsetMap& client_scroll_map,
423 float client_page_scale) {
424 DCHECK(!synchronizing_client_updates_);
425
426 base::AutoReset<bool> synchronizing_updates(&synchronizing_client_updates_,
427 true);
428 bool layer_sync_successful = true;
429
430 gfx::Vector2dF inner_viewport_scroll_delta;
431 Layer* inner_viewport_scroll_layer =
432 layer_tree_->inner_viewport_scroll_layer();
433 for (const auto& client_scroll : client_scroll_map) {
434 Layer* layer = layer_tree_->LayerById(client_scroll.first);
435 const gfx::ScrollOffset& scroll_offset = client_scroll.second;
436
437 // Note the inner viewport scroll delta to report separately.
438 if (layer == inner_viewport_scroll_layer)
vmpstr 2016/10/13 19:20:55 It's a two line if statement, so braces aren't opt
Khushal 2016/10/13 19:59:02 Oh, so that's the rule. Done.
439 inner_viewport_scroll_delta =
440 scroll_offset.DeltaFrom(layer->scroll_offset());
441
442 if (layer)
443 layer->SetScrollOffsetFromImplSide(scroll_offset);
444 else
445 layer_sync_successful = false;
446 }
447
448 float page_scale_delta = 1.0f;
449 if (client_page_scale != layer_tree_->page_scale_factor()) {
450 page_scale_delta = client_page_scale / layer_tree_->page_scale_factor();
451 layer_tree_->SetPageScaleFromImplSide(client_page_scale);
452 }
453
454 if (!inner_viewport_scroll_delta.IsZero() || page_scale_delta != 1.0f) {
455 client_->ApplyViewportDeltas(inner_viewport_scroll_delta, gfx::Vector2dF(),
456 gfx::Vector2dF(), page_scale_delta, 1.0f);
457 }
458
459 return layer_sync_successful;
460 }
461
415 void LayerTreeHostRemote::MainFrameComplete() { 462 void LayerTreeHostRemote::MainFrameComplete() {
416 DCHECK_EQ(current_pipeline_stage_, FramePipelineStage::COMMIT); 463 DCHECK_EQ(current_pipeline_stage_, FramePipelineStage::COMMIT);
417 464
418 current_pipeline_stage_ = FramePipelineStage::NONE; 465 current_pipeline_stage_ = FramePipelineStage::NONE;
419 max_pipeline_stage_for_current_frame_ = FramePipelineStage::NONE; 466 max_pipeline_stage_for_current_frame_ = FramePipelineStage::NONE;
420 source_frame_number_++; 467 source_frame_number_++;
421 468
422 client_->DidCommit(); 469 client_->DidCommit();
423 client_->DidBeginMainFrame(); 470 client_->DidBeginMainFrame();
424 } 471 }
(...skipping 23 matching lines...) Expand all
448 layer_tree_host_proto->mutable_layer_updates(), inputs_only); 495 layer_tree_host_proto->mutable_layer_updates(), inputs_only);
449 layer_tree_->LayersThatShouldPushProperties().clear(); 496 layer_tree_->LayersThatShouldPushProperties().clear();
450 497
451 std::vector<PictureData> pictures = 498 std::vector<PictureData> pictures =
452 engine_picture_cache_->CalculateCacheUpdateAndFlush(); 499 engine_picture_cache_->CalculateCacheUpdateAndFlush();
453 proto::PictureDataVectorToSkPicturesProto( 500 proto::PictureDataVectorToSkPicturesProto(
454 pictures, layer_tree_host_proto->mutable_pictures()); 501 pictures, layer_tree_host_proto->mutable_pictures());
455 } 502 }
456 503
457 } // namespace cc 504 } // namespace cc
OLDNEW
« no previous file with comments | « cc/blimp/layer_tree_host_remote.h ('k') | cc/blimp/layer_tree_host_remote_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698