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_impl.h" | 5 #include "cc/trees/layer_tree_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 <set> | 12 #include <set> |
13 | 13 |
14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
15 #include "base/timer/elapsed_timer.h" | 15 #include "base/timer/elapsed_timer.h" |
16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
17 #include "base/trace_event/trace_event_argument.h" | 17 #include "base/trace_event/trace_event_argument.h" |
18 #include "cc/animation/animation_host.h" | 18 #include "cc/animation/animation_host.h" |
19 #include "cc/animation/keyframed_animation_curve.h" | 19 #include "cc/animation/keyframed_animation_curve.h" |
| 20 #include "cc/animation/mutable_properties.h" |
20 #include "cc/animation/scrollbar_animation_controller.h" | 21 #include "cc/animation/scrollbar_animation_controller.h" |
21 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" | 22 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" |
22 #include "cc/animation/scrollbar_animation_controller_thinning.h" | 23 #include "cc/animation/scrollbar_animation_controller_thinning.h" |
23 #include "cc/base/histograms.h" | 24 #include "cc/base/histograms.h" |
24 #include "cc/base/math_util.h" | 25 #include "cc/base/math_util.h" |
25 #include "cc/base/synced_property.h" | 26 #include "cc/base/synced_property.h" |
26 #include "cc/debug/devtools_instrumentation.h" | 27 #include "cc/debug/devtools_instrumentation.h" |
27 #include "cc/debug/traced_value.h" | 28 #include "cc/debug/traced_value.h" |
28 #include "cc/input/page_scale_animation.h" | 29 #include "cc/input/page_scale_animation.h" |
29 #include "cc/layers/heads_up_display_layer_impl.h" | 30 #include "cc/layers/heads_up_display_layer_impl.h" |
30 #include "cc/layers/layer.h" | 31 #include "cc/layers/layer.h" |
31 #include "cc/layers/layer_iterator.h" | 32 #include "cc/layers/layer_iterator.h" |
32 #include "cc/layers/render_surface_impl.h" | 33 #include "cc/layers/render_surface_impl.h" |
33 #include "cc/layers/scrollbar_layer_impl_base.h" | 34 #include "cc/layers/scrollbar_layer_impl_base.h" |
34 #include "cc/resources/ui_resource_request.h" | 35 #include "cc/resources/ui_resource_request.h" |
35 #include "cc/trees/draw_property_utils.h" | 36 #include "cc/trees/draw_property_utils.h" |
36 #include "cc/trees/layer_tree_host_common.h" | 37 #include "cc/trees/layer_tree_host_common.h" |
37 #include "cc/trees/layer_tree_host_impl.h" | 38 #include "cc/trees/layer_tree_host_impl.h" |
38 #include "cc/trees/occlusion_tracker.h" | 39 #include "cc/trees/occlusion_tracker.h" |
39 #include "cc/trees/property_tree.h" | 40 #include "cc/trees/property_tree.h" |
40 #include "cc/trees/property_tree_builder.h" | 41 #include "cc/trees/property_tree_builder.h" |
41 #include "ui/gfx/geometry/box_f.h" | 42 #include "ui/gfx/geometry/box_f.h" |
42 #include "ui/gfx/geometry/point_conversions.h" | 43 #include "ui/gfx/geometry/point_conversions.h" |
43 #include "ui/gfx/geometry/size_conversions.h" | 44 #include "ui/gfx/geometry/size_conversions.h" |
44 #include "ui/gfx/geometry/vector2d_conversions.h" | 45 #include "ui/gfx/geometry/vector2d_conversions.h" |
45 | 46 |
46 namespace cc { | 47 namespace cc { |
47 | 48 |
| 49 namespace { |
| 50 |
| 51 const uint32_t kMainLayerFlags = |
| 52 kMutablePropertyOpacity | kMutablePropertyTransform; |
| 53 const uint32_t kScrollLayerFlags = |
| 54 kMutablePropertyScrollLeft | kMutablePropertyScrollTop; |
| 55 |
| 56 } // namespace |
| 57 |
48 LayerTreeImpl::LayerTreeImpl( | 58 LayerTreeImpl::LayerTreeImpl( |
49 LayerTreeHostImpl* layer_tree_host_impl, | 59 LayerTreeHostImpl* layer_tree_host_impl, |
50 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, | 60 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, |
51 scoped_refptr<SyncedTopControls> top_controls_shown_ratio, | 61 scoped_refptr<SyncedTopControls> top_controls_shown_ratio, |
52 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) | 62 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) |
53 : layer_tree_host_impl_(layer_tree_host_impl), | 63 : layer_tree_host_impl_(layer_tree_host_impl), |
54 source_frame_number_(-1), | 64 source_frame_number_(-1), |
55 is_first_frame_after_commit_tracker_(-1), | 65 is_first_frame_after_commit_tracker_(-1), |
56 hud_layer_(0), | 66 hud_layer_(0), |
57 background_color_(0), | 67 background_color_(0), |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 361 |
352 if (hud_layer()) | 362 if (hud_layer()) |
353 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( | 363 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( |
354 LayerTreeHostCommon::FindLayerInSubtree( | 364 LayerTreeHostCommon::FindLayerInSubtree( |
355 target_tree->root_layer(), hud_layer()->id()))); | 365 target_tree->root_layer(), hud_layer()->id()))); |
356 else | 366 else |
357 target_tree->set_hud_layer(NULL); | 367 target_tree->set_hud_layer(NULL); |
358 | 368 |
359 target_tree->has_ever_been_drawn_ = false; | 369 target_tree->has_ever_been_drawn_ = false; |
360 } | 370 } |
| 371 void LayerTreeImpl::AddToElementMap(LayerImpl* layer) { |
| 372 if (!layer->element_id()) |
| 373 return; |
| 374 |
| 375 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 376 "LayerTreeImpl::AddToElementMap", "element_id", |
| 377 layer->element_id(), "layer_id", layer->id()); |
| 378 |
| 379 ElementLayers& layers = element_layers_map_[layer->element_id()]; |
| 380 if (layer->mutable_properties() & kMainLayerFlags) { |
| 381 if (!layers.main || layer->IsActive()) |
| 382 layers.main = layer; |
| 383 } |
| 384 if (layer->mutable_properties() & kScrollLayerFlags) { |
| 385 if (!layers.scroll || layer->IsActive()) { |
| 386 TRACE_EVENT2("compositor-worker", "LayerTreeImpl::AddToElementMap scroll", |
| 387 "element_id", layer->element_id(), "layer_id", layer->id()); |
| 388 layers.scroll = layer; |
| 389 } |
| 390 } |
| 391 } |
| 392 |
| 393 void LayerTreeImpl::RemoveFromElementMap(LayerImpl* layer) { |
| 394 if (!layer->element_id()) |
| 395 return; |
| 396 |
| 397 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 398 "LayerTreeImpl::RemoveFromElementMap", "element_id", |
| 399 layer->element_id(), "layer_id", layer->id()); |
| 400 |
| 401 ElementLayers& layers = element_layers_map_[layer->element_id()]; |
| 402 if (layer->mutable_properties() & kMainLayerFlags) |
| 403 layers.main = nullptr; |
| 404 if (layer->mutable_properties() & kScrollLayerFlags) |
| 405 layers.scroll = nullptr; |
| 406 |
| 407 if (!layers.main && !layers.scroll) |
| 408 element_layers_map_.erase(layer->element_id()); |
| 409 } |
| 410 |
| 411 LayerTreeImpl::ElementLayers LayerTreeImpl::GetMutableLayers( |
| 412 uint64_t element_id) { |
| 413 auto iter = element_layers_map_.find(element_id); |
| 414 if (iter == element_layers_map_.end()) |
| 415 return ElementLayers(); |
| 416 |
| 417 return iter->second; |
| 418 } |
361 | 419 |
362 LayerImpl* LayerTreeImpl::InnerViewportContainerLayer() const { | 420 LayerImpl* LayerTreeImpl::InnerViewportContainerLayer() const { |
363 return InnerViewportScrollLayer() | 421 return InnerViewportScrollLayer() |
364 ? InnerViewportScrollLayer()->scroll_clip_layer() | 422 ? InnerViewportScrollLayer()->scroll_clip_layer() |
365 : NULL; | 423 : NULL; |
366 } | 424 } |
367 | 425 |
368 LayerImpl* LayerTreeImpl::OuterViewportContainerLayer() const { | 426 LayerImpl* LayerTreeImpl::OuterViewportContainerLayer() const { |
369 return OuterViewportScrollLayer() | 427 return OuterViewportScrollLayer() |
370 ? OuterViewportScrollLayer()->scroll_clip_layer() | 428 ? OuterViewportScrollLayer()->scroll_clip_layer() |
(...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1945 const gfx::BoxF& box, | 2003 const gfx::BoxF& box, |
1946 gfx::BoxF* bounds) const { | 2004 gfx::BoxF* bounds) const { |
1947 *bounds = gfx::BoxF(); | 2005 *bounds = gfx::BoxF(); |
1948 return layer_tree_host_impl_->animation_host() | 2006 return layer_tree_host_impl_->animation_host() |
1949 ? layer_tree_host_impl_->animation_host() | 2007 ? layer_tree_host_impl_->animation_host() |
1950 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) | 2008 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) |
1951 : true; | 2009 : true; |
1952 } | 2010 } |
1953 | 2011 |
1954 } // namespace cc | 2012 } // namespace cc |
OLD | NEW |