| 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_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.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> |
| 11 #include <limits> | 11 #include <limits> |
| 12 #include <map> | 12 #include <map> |
| 13 #include <set> | 13 #include <set> |
| 14 #include <unordered_map> |
| 15 #include <utility> |
| 14 | 16 |
| 15 #include "base/auto_reset.h" | 17 #include "base/auto_reset.h" |
| 16 #include "base/containers/hash_tables.h" | |
| 17 #include "base/containers/small_map.h" | 18 #include "base/containers/small_map.h" |
| 18 #include "base/json/json_writer.h" | 19 #include "base/json/json_writer.h" |
| 19 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
| 20 #include "base/numerics/safe_conversions.h" | 21 #include "base/numerics/safe_conversions.h" |
| 21 #include "base/stl_util.h" | 22 #include "base/stl_util.h" |
| 22 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 23 #include "base/trace_event/trace_event_argument.h" | 24 #include "base/trace_event/trace_event_argument.h" |
| 24 #include "cc/animation/animation_events.h" | 25 #include "cc/animation/animation_events.h" |
| 25 #include "cc/animation/animation_host.h" | 26 #include "cc/animation/animation_host.h" |
| 26 #include "cc/animation/animation_id_provider.h" | 27 #include "cc/animation/animation_id_provider.h" |
| (...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 } | 1183 } |
| 1183 | 1184 |
| 1184 void LayerTreeHostImpl::RemoveRenderPasses(FrameData* frame) { | 1185 void LayerTreeHostImpl::RemoveRenderPasses(FrameData* frame) { |
| 1185 // There is always at least a root RenderPass. | 1186 // There is always at least a root RenderPass. |
| 1186 DCHECK_GE(frame->render_passes.size(), 1u); | 1187 DCHECK_GE(frame->render_passes.size(), 1u); |
| 1187 | 1188 |
| 1188 // A set of RenderPasses that we have seen. | 1189 // A set of RenderPasses that we have seen. |
| 1189 std::set<RenderPassId> pass_exists; | 1190 std::set<RenderPassId> pass_exists; |
| 1190 // A set of RenderPassDrawQuads that we have seen (stored by the RenderPasses | 1191 // A set of RenderPassDrawQuads that we have seen (stored by the RenderPasses |
| 1191 // they refer to). | 1192 // they refer to). |
| 1192 base::SmallMap<base::hash_map<RenderPassId, int>> pass_references; | 1193 base::SmallMap<std::unordered_map<RenderPassId, int, RenderPassIdHash>> |
| 1194 pass_references; |
| 1193 | 1195 |
| 1194 // Iterate RenderPasses in draw order, removing empty render passes (except | 1196 // Iterate RenderPasses in draw order, removing empty render passes (except |
| 1195 // the root RenderPass). | 1197 // the root RenderPass). |
| 1196 for (size_t i = 0; i < frame->render_passes.size(); ++i) { | 1198 for (size_t i = 0; i < frame->render_passes.size(); ++i) { |
| 1197 RenderPass* pass = frame->render_passes[i].get(); | 1199 RenderPass* pass = frame->render_passes[i].get(); |
| 1198 | 1200 |
| 1199 // Remove orphan RenderPassDrawQuads. | 1201 // Remove orphan RenderPassDrawQuads. |
| 1200 for (auto it = pass->quad_list.begin(); it != pass->quad_list.end();) { | 1202 for (auto it = pass->quad_list.begin(); it != pass->quad_list.end();) { |
| 1201 if (it->material != DrawQuad::RENDER_PASS) { | 1203 if (it->material != DrawQuad::RENDER_PASS) { |
| 1202 ++it; | 1204 ++it; |
| (...skipping 2194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3397 } | 3399 } |
| 3398 return str; | 3400 return str; |
| 3399 } | 3401 } |
| 3400 | 3402 |
| 3401 void LayerTreeHostImpl::RegisterScrollbarAnimationController( | 3403 void LayerTreeHostImpl::RegisterScrollbarAnimationController( |
| 3402 int scroll_layer_id) { | 3404 int scroll_layer_id) { |
| 3403 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR) | 3405 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR) |
| 3404 return; | 3406 return; |
| 3405 if (ScrollbarAnimationControllerForId(scroll_layer_id)) | 3407 if (ScrollbarAnimationControllerForId(scroll_layer_id)) |
| 3406 return; | 3408 return; |
| 3407 scrollbar_animation_controllers_.add( | 3409 scrollbar_animation_controllers_[scroll_layer_id] = |
| 3408 scroll_layer_id, | 3410 active_tree_->CreateScrollbarAnimationController(scroll_layer_id); |
| 3409 active_tree_->CreateScrollbarAnimationController(scroll_layer_id)); | |
| 3410 } | 3411 } |
| 3411 | 3412 |
| 3412 void LayerTreeHostImpl::UnregisterScrollbarAnimationController( | 3413 void LayerTreeHostImpl::UnregisterScrollbarAnimationController( |
| 3413 int scroll_layer_id) { | 3414 int scroll_layer_id) { |
| 3414 scrollbar_animation_controllers_.erase(scroll_layer_id); | 3415 scrollbar_animation_controllers_.erase(scroll_layer_id); |
| 3415 } | 3416 } |
| 3416 | 3417 |
| 3417 ScrollbarAnimationController* | 3418 ScrollbarAnimationController* |
| 3418 LayerTreeHostImpl::ScrollbarAnimationControllerForId( | 3419 LayerTreeHostImpl::ScrollbarAnimationControllerForId( |
| 3419 int scroll_layer_id) const { | 3420 int scroll_layer_id) const { |
| 3420 if (InnerViewportScrollLayer() && OuterViewportScrollLayer() && | 3421 if (InnerViewportScrollLayer() && OuterViewportScrollLayer() && |
| 3421 scroll_layer_id == InnerViewportScrollLayer()->id()) | 3422 scroll_layer_id == InnerViewportScrollLayer()->id()) |
| 3422 scroll_layer_id = OuterViewportScrollLayer()->id(); | 3423 scroll_layer_id = OuterViewportScrollLayer()->id(); |
| 3423 auto i = scrollbar_animation_controllers_.find(scroll_layer_id); | 3424 auto i = scrollbar_animation_controllers_.find(scroll_layer_id); |
| 3424 if (i == scrollbar_animation_controllers_.end()) | 3425 if (i == scrollbar_animation_controllers_.end()) |
| 3425 return nullptr; | 3426 return nullptr; |
| 3426 return i->second; | 3427 return i->second.get(); |
| 3427 } | 3428 } |
| 3428 | 3429 |
| 3429 void LayerTreeHostImpl::PostDelayedScrollbarAnimationTask( | 3430 void LayerTreeHostImpl::PostDelayedScrollbarAnimationTask( |
| 3430 const base::Closure& task, | 3431 const base::Closure& task, |
| 3431 base::TimeDelta delay) { | 3432 base::TimeDelta delay) { |
| 3432 client_->PostDelayedAnimationTaskOnImplThread(task, delay); | 3433 client_->PostDelayedAnimationTaskOnImplThread(task, delay); |
| 3433 } | 3434 } |
| 3434 | 3435 |
| 3435 // TODO(danakj): Make this a return value from the Animate() call instead of an | 3436 // TODO(danakj): Make this a return value from the Animate() call instead of an |
| 3436 // interface on LTHI. (Also, crbug.com/551138.) | 3437 // interface on LTHI. (Also, crbug.com/551138.) |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3919 return task_runner_provider_->HasImplThread(); | 3920 return task_runner_provider_->HasImplThread(); |
| 3920 } | 3921 } |
| 3921 | 3922 |
| 3922 bool LayerTreeHostImpl::CommitToActiveTree() const { | 3923 bool LayerTreeHostImpl::CommitToActiveTree() const { |
| 3923 // In single threaded mode we skip the pending tree and commit directly to the | 3924 // In single threaded mode we skip the pending tree and commit directly to the |
| 3924 // active tree. | 3925 // active tree. |
| 3925 return !task_runner_provider_->HasImplThread(); | 3926 return !task_runner_provider_->HasImplThread(); |
| 3926 } | 3927 } |
| 3927 | 3928 |
| 3928 } // namespace cc | 3929 } // namespace cc |
| OLD | NEW |