| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 #include "cc/trees/transform_node.h" | 56 #include "cc/trees/transform_node.h" |
| 57 #include "cc/trees/tree_synchronizer.h" | 57 #include "cc/trees/tree_synchronizer.h" |
| 58 #include "ui/gfx/geometry/size_conversions.h" | 58 #include "ui/gfx/geometry/size_conversions.h" |
| 59 #include "ui/gfx/geometry/vector2d_conversions.h" | 59 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 60 | 60 |
| 61 namespace { | 61 namespace { |
| 62 static base::StaticAtomicSequenceNumber s_layer_tree_host_sequence_number; | 62 static base::StaticAtomicSequenceNumber s_layer_tree_host_sequence_number; |
| 63 } | 63 } |
| 64 | 64 |
| 65 namespace cc { | 65 namespace cc { |
| 66 namespace { |
| 67 |
| 68 void EnsureValidIndicesOnLayer(Layer* layer, PropertyTrees* property_trees) { |
| 69 CHECK_EQ(property_trees->sequence_number, |
| 70 layer->property_tree_sequence_number()); |
| 71 CHECK(property_trees->transform_tree.Node(layer->transform_tree_index())); |
| 72 CHECK(property_trees->clip_tree.Node(layer->clip_tree_index())); |
| 73 CHECK(property_trees->effect_tree.Node(layer->effect_tree_index())); |
| 74 CHECK(property_trees->scroll_tree.Node(layer->scroll_tree_index())); |
| 75 } |
| 76 |
| 77 void EnsureValidPropertyTreeState(LayerTreeHost* host) { |
| 78 // Temporary check to debug crbug.com/726423. The property tree indices on |
| 79 // the LayerTreeImpl should be valid after all state synchronization has |
| 80 // finished. |
| 81 for (auto* layer : *host) |
| 82 EnsureValidIndicesOnLayer(layer, host->property_trees()); |
| 83 |
| 84 for (auto id : host->property_trees()->effect_tree.mask_layer_ids()) |
| 85 EnsureValidIndicesOnLayer(host->LayerById(id), host->property_trees()); |
| 86 } |
| 87 |
| 88 } // namespace |
| 66 | 89 |
| 67 LayerTreeHost::InitParams::InitParams() {} | 90 LayerTreeHost::InitParams::InitParams() {} |
| 68 | 91 |
| 69 LayerTreeHost::InitParams::~InitParams() {} | 92 LayerTreeHost::InitParams::~InitParams() {} |
| 70 | 93 |
| 71 std::unique_ptr<LayerTreeHost> LayerTreeHost::CreateThreaded( | 94 std::unique_ptr<LayerTreeHost> LayerTreeHost::CreateThreaded( |
| 72 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 95 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 73 InitParams* params) { | 96 InitParams* params) { |
| 74 DCHECK(params->main_task_runner.get()); | 97 DCHECK(params->main_task_runner.get()); |
| 75 DCHECK(impl_task_runner.get()); | 98 DCHECK(impl_task_runner.get()); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 sync_tree->ForceRedrawNextActivation(); | 320 sync_tree->ForceRedrawNextActivation(); |
| 298 next_commit_forces_redraw_ = false; | 321 next_commit_forces_redraw_ = false; |
| 299 } | 322 } |
| 300 if (next_commit_forces_recalculate_raster_scales_) { | 323 if (next_commit_forces_recalculate_raster_scales_) { |
| 301 sync_tree->ForceRecalculateRasterScales(); | 324 sync_tree->ForceRecalculateRasterScales(); |
| 302 next_commit_forces_recalculate_raster_scales_ = false; | 325 next_commit_forces_recalculate_raster_scales_ = false; |
| 303 } | 326 } |
| 304 | 327 |
| 305 sync_tree->set_source_frame_number(SourceFrameNumber()); | 328 sync_tree->set_source_frame_number(SourceFrameNumber()); |
| 306 | 329 |
| 330 EnsureValidPropertyTreeState(this); |
| 331 |
| 307 if (needs_full_tree_sync_) | 332 if (needs_full_tree_sync_) |
| 308 TreeSynchronizer::SynchronizeTrees(root_layer(), sync_tree); | 333 TreeSynchronizer::SynchronizeTrees(root_layer(), sync_tree); |
| 309 | 334 |
| 310 // Track the navigation state before pushing properties since it overwrites | 335 // Track the navigation state before pushing properties since it overwrites |
| 311 // the |content_source_id_| on the sync tree. | 336 // the |content_source_id_| on the sync tree. |
| 312 bool did_navigate = content_source_id_ != sync_tree->content_source_id(); | 337 bool did_navigate = content_source_id_ != sync_tree->content_source_id(); |
| 313 if (did_navigate) | 338 if (did_navigate) |
| 314 host_impl->ClearImageCacheOnNavigation(); | 339 host_impl->ClearImageCacheOnNavigation(); |
| 315 | 340 |
| 316 { | 341 { |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 "cc", "LayerTreeHostInProcess::UpdateLayers_BuiltPropertyTrees", | 763 "cc", "LayerTreeHostInProcess::UpdateLayers_BuiltPropertyTrees", |
| 739 TRACE_EVENT_SCOPE_THREAD, "property_trees", | 764 TRACE_EVENT_SCOPE_THREAD, "property_trees", |
| 740 property_trees->AsTracedValue()); | 765 property_trees->AsTracedValue()); |
| 741 } else { | 766 } else { |
| 742 TRACE_EVENT_INSTANT1( | 767 TRACE_EVENT_INSTANT1( |
| 743 "cc", "LayerTreeHostInProcess::UpdateLayers_ReceivedPropertyTrees", | 768 "cc", "LayerTreeHostInProcess::UpdateLayers_ReceivedPropertyTrees", |
| 744 TRACE_EVENT_SCOPE_THREAD, "property_trees", | 769 TRACE_EVENT_SCOPE_THREAD, "property_trees", |
| 745 property_trees->AsTracedValue()); | 770 property_trees->AsTracedValue()); |
| 746 } | 771 } |
| 747 | 772 |
| 748 // Temporary check to debug crbug.com/726423. The property tree indices on | |
| 749 // the LayerTreeImpl should be valid after all state synchronization has | |
| 750 // finished. | |
| 751 for (auto* layer : *this) { | |
| 752 CHECK(property_trees_.transform_tree.Node(layer->transform_tree_index())); | |
| 753 CHECK(property_trees_.clip_tree.Node(layer->clip_tree_index())); | |
| 754 CHECK(property_trees_.effect_tree.Node(layer->effect_tree_index())); | |
| 755 CHECK(property_trees_.scroll_tree.Node(layer->scroll_tree_index())); | |
| 756 } | |
| 757 | |
| 758 draw_property_utils::UpdatePropertyTrees(this, property_trees); | 773 draw_property_utils::UpdatePropertyTrees(this, property_trees); |
| 759 draw_property_utils::FindLayersThatNeedUpdates(this, property_trees, | 774 draw_property_utils::FindLayersThatNeedUpdates(this, property_trees, |
| 760 &update_layer_list); | 775 &update_layer_list); |
| 761 } | 776 } |
| 762 | 777 |
| 778 EnsureValidPropertyTreeState(this); |
| 779 |
| 763 bool content_is_suitable_for_gpu = true; | 780 bool content_is_suitable_for_gpu = true; |
| 764 bool did_paint_content = | 781 bool did_paint_content = |
| 765 PaintContent(update_layer_list, &content_is_suitable_for_gpu); | 782 PaintContent(update_layer_list, &content_is_suitable_for_gpu); |
| 766 | 783 |
| 767 if (content_is_suitable_for_gpu) { | 784 if (content_is_suitable_for_gpu) { |
| 768 ++num_consecutive_frames_suitable_for_gpu_; | 785 ++num_consecutive_frames_suitable_for_gpu_; |
| 769 if (num_consecutive_frames_suitable_for_gpu_ >= | 786 if (num_consecutive_frames_suitable_for_gpu_ >= |
| 770 kNumFramesToConsiderBeforeGpuRasterization) { | 787 kNumFramesToConsiderBeforeGpuRasterization) { |
| 771 content_is_suitable_for_gpu_rasterization_ = true; | 788 content_is_suitable_for_gpu_rasterization_ = true; |
| 772 } | 789 } |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1486 | 1503 |
| 1487 void LayerTreeHost::SetHasCopyRequest(bool has_copy_request) { | 1504 void LayerTreeHost::SetHasCopyRequest(bool has_copy_request) { |
| 1488 has_copy_request_ = has_copy_request; | 1505 has_copy_request_ = has_copy_request; |
| 1489 } | 1506 } |
| 1490 | 1507 |
| 1491 void LayerTreeHost::RequestBeginMainFrameNotExpected(bool new_state) { | 1508 void LayerTreeHost::RequestBeginMainFrameNotExpected(bool new_state) { |
| 1492 proxy_->RequestBeginMainFrameNotExpected(new_state); | 1509 proxy_->RequestBeginMainFrameNotExpected(new_state); |
| 1493 } | 1510 } |
| 1494 | 1511 |
| 1495 } // namespace cc | 1512 } // namespace cc |
| OLD | NEW |