Chromium Code Reviews| 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/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 Loading... | |
| 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 { |
| 166 if (synchronizing_client_updates_) | |
| 167 return true; | |
| 164 return requested_pipeline_stage_for_next_frame_ == FramePipelineStage::COMMIT; | 168 return requested_pipeline_stage_for_next_frame_ == FramePipelineStage::COMMIT; |
|
vmpstr
2016/10/13 18:32:31
return synchronizing_client_updates_ || requested_
Khushal
2016/10/13 18:55:13
Done.
| |
| 165 } | 169 } |
| 166 | 170 |
| 167 void LayerTreeHostRemote::SetDeferCommits(bool defer_commits) { | 171 void LayerTreeHostRemote::SetDeferCommits(bool defer_commits) { |
| 168 defer_commits_ = defer_commits; | 172 defer_commits_ = defer_commits; |
| 169 ScheduleMainFrameIfNecessary(); | 173 ScheduleMainFrameIfNecessary(); |
| 170 } | 174 } |
| 171 | 175 |
| 172 void LayerTreeHostRemote::LayoutAndUpdateLayers() { | 176 void LayerTreeHostRemote::LayoutAndUpdateLayers() { |
| 173 NOTREACHED() << "Only supported in single-threaded mode and this class" | 177 NOTREACHED() << "Only supported in single-threaded mode and this class" |
| 174 << " does not support single-thread since it is out of process"; | 178 << " does not support single-thread since it is out of process"; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 // LayerTreeHostClient to throttle further frame updates, so dispatch them | 409 // LayerTreeHostClient to throttle further frame updates, so dispatch them |
| 406 // right after the update is processed by the bridge. | 410 // right after the update is processed by the bridge. |
| 407 // TODO(khushalsagar): We can not really know what these callbacks end up | 411 // 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 | 412 // being used for. Consider migrating clients to understand/cope with the fact |
| 409 // that there is no actual compositing happening here. | 413 // that there is no actual compositing happening here. |
| 410 task_runner_provider_->MainThreadTaskRunner()->PostTask( | 414 task_runner_provider_->MainThreadTaskRunner()->PostTask( |
| 411 FROM_HERE, base::Bind(&LayerTreeHostRemote::DispatchDrawAndSwapCallbacks, | 415 FROM_HERE, base::Bind(&LayerTreeHostRemote::DispatchDrawAndSwapCallbacks, |
| 412 weak_factory_.GetWeakPtr())); | 416 weak_factory_.GetWeakPtr())); |
| 413 } | 417 } |
| 414 | 418 |
| 419 bool LayerTreeHostRemote::ApplyScrollAndScaleUpdateFromClient( | |
| 420 const ScrollOffsetMap& client_scroll_map, | |
| 421 float client_page_scale) { | |
| 422 DCHECK(!synchronizing_client_updates_); | |
| 423 | |
| 424 base::AutoReset<bool> synchronizing_updates(&synchronizing_client_updates_, | |
| 425 true); | |
| 426 bool layer_sync_successful = true; | |
| 427 | |
| 428 gfx::Vector2dF inner_viewport_scroll_delta; | |
| 429 Layer* inner_viewport_scroll_layer = | |
| 430 layer_tree_->inner_viewport_scroll_layer(); | |
| 431 for (const auto& client_scroll : client_scroll_map) { | |
| 432 Layer* layer = layer_tree_->LayerById(client_scroll.first); | |
| 433 const gfx::ScrollOffset& scroll_offset = client_scroll.second; | |
| 434 | |
| 435 // Note the inner viewport scroll delta to report separately. | |
| 436 if (layer == inner_viewport_scroll_layer) | |
|
vmpstr
2016/10/13 18:32:31
nit: braces
Khushal
2016/10/13 18:55:13
I don't have them anywhere in this file, so consis
| |
| 437 inner_viewport_scroll_delta = | |
| 438 scroll_offset.DeltaFrom(layer->scroll_offset()); | |
| 439 | |
| 440 if (layer) | |
| 441 layer->SetScrollOffsetFromImplSide(scroll_offset); | |
| 442 else | |
| 443 layer_sync_successful = false; | |
| 444 } | |
| 445 | |
| 446 float page_scale_delta = 1.0f; | |
| 447 if (client_page_scale != layer_tree_->page_scale_factor()) { | |
| 448 page_scale_delta = client_page_scale / layer_tree_->page_scale_factor(); | |
| 449 layer_tree_->SetPageScaleFromImplSide(client_page_scale); | |
| 450 } | |
| 451 | |
| 452 if (!inner_viewport_scroll_delta.IsZero() || page_scale_delta != 1.0f) { | |
| 453 client_->ApplyViewportDeltas(inner_viewport_scroll_delta, gfx::Vector2dF(), | |
| 454 gfx::Vector2dF(), page_scale_delta, 1.0f); | |
| 455 } | |
| 456 | |
| 457 return layer_sync_successful; | |
| 458 } | |
| 459 | |
| 415 void LayerTreeHostRemote::MainFrameComplete() { | 460 void LayerTreeHostRemote::MainFrameComplete() { |
| 416 DCHECK_EQ(current_pipeline_stage_, FramePipelineStage::COMMIT); | 461 DCHECK_EQ(current_pipeline_stage_, FramePipelineStage::COMMIT); |
| 417 | 462 |
| 418 current_pipeline_stage_ = FramePipelineStage::NONE; | 463 current_pipeline_stage_ = FramePipelineStage::NONE; |
| 419 max_pipeline_stage_for_current_frame_ = FramePipelineStage::NONE; | 464 max_pipeline_stage_for_current_frame_ = FramePipelineStage::NONE; |
| 420 source_frame_number_++; | 465 source_frame_number_++; |
| 421 | 466 |
| 422 client_->DidCommit(); | 467 client_->DidCommit(); |
| 423 client_->DidBeginMainFrame(); | 468 client_->DidBeginMainFrame(); |
| 424 } | 469 } |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 448 layer_tree_host_proto->mutable_layer_updates(), inputs_only); | 493 layer_tree_host_proto->mutable_layer_updates(), inputs_only); |
| 449 layer_tree_->LayersThatShouldPushProperties().clear(); | 494 layer_tree_->LayersThatShouldPushProperties().clear(); |
| 450 | 495 |
| 451 std::vector<PictureData> pictures = | 496 std::vector<PictureData> pictures = |
| 452 engine_picture_cache_->CalculateCacheUpdateAndFlush(); | 497 engine_picture_cache_->CalculateCacheUpdateAndFlush(); |
| 453 proto::PictureDataVectorToSkPicturesProto( | 498 proto::PictureDataVectorToSkPicturesProto( |
| 454 pictures, layer_tree_host_proto->mutable_pictures()); | 499 pictures, layer_tree_host_proto->mutable_pictures()); |
| 455 } | 500 } |
| 456 | 501 |
| 457 } // namespace cc | 502 } // namespace cc |
| OLD | NEW |