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/rect_conversions.h" | 44 #include "ui/gfx/geometry/rect_conversions.h" |
44 #include "ui/gfx/geometry/size_conversions.h" | 45 #include "ui/gfx/geometry/size_conversions.h" |
45 #include "ui/gfx/geometry/vector2d_conversions.h" | 46 #include "ui/gfx/geometry/vector2d_conversions.h" |
46 | 47 |
47 namespace cc { | 48 namespace cc { |
48 | 49 |
| 50 namespace { |
| 51 |
| 52 const uint32_t kMainLayerFlags = |
| 53 kMutablePropertyOpacity | kMutablePropertyTransform; |
| 54 const uint32_t kScrollLayerFlags = |
| 55 kMutablePropertyScrollLeft | kMutablePropertyScrollTop; |
| 56 |
| 57 } // namespace |
| 58 |
49 LayerTreeImpl::LayerTreeImpl( | 59 LayerTreeImpl::LayerTreeImpl( |
50 LayerTreeHostImpl* layer_tree_host_impl, | 60 LayerTreeHostImpl* layer_tree_host_impl, |
51 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, | 61 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, |
52 scoped_refptr<SyncedTopControls> top_controls_shown_ratio, | 62 scoped_refptr<SyncedTopControls> top_controls_shown_ratio, |
53 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) | 63 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) |
54 : layer_tree_host_impl_(layer_tree_host_impl), | 64 : layer_tree_host_impl_(layer_tree_host_impl), |
55 source_frame_number_(-1), | 65 source_frame_number_(-1), |
56 is_first_frame_after_commit_tracker_(-1), | 66 is_first_frame_after_commit_tracker_(-1), |
57 hud_layer_(0), | 67 hud_layer_(0), |
58 background_color_(0), | 68 background_color_(0), |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 | 362 |
353 if (hud_layer()) | 363 if (hud_layer()) |
354 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( | 364 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( |
355 LayerTreeHostCommon::FindLayerInSubtree( | 365 LayerTreeHostCommon::FindLayerInSubtree( |
356 target_tree->root_layer(), hud_layer()->id()))); | 366 target_tree->root_layer(), hud_layer()->id()))); |
357 else | 367 else |
358 target_tree->set_hud_layer(NULL); | 368 target_tree->set_hud_layer(NULL); |
359 | 369 |
360 target_tree->has_ever_been_drawn_ = false; | 370 target_tree->has_ever_been_drawn_ = false; |
361 } | 371 } |
| 372 void LayerTreeImpl::AddToElementMap(LayerImpl* layer) { |
| 373 if (!layer->element_id()) |
| 374 return; |
| 375 |
| 376 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 377 "LayerTreeImpl::AddToElementMap", "element_id", |
| 378 layer->element_id(), "layer_id", layer->id()); |
| 379 |
| 380 ElementLayers& layers = element_layers_map_[layer->element_id()]; |
| 381 if (layer->mutable_properties() & kMainLayerFlags) { |
| 382 if (!layers.main || layer->IsActive()) |
| 383 layers.main = layer; |
| 384 } |
| 385 if (layer->mutable_properties() & kScrollLayerFlags) { |
| 386 if (!layers.scroll || layer->IsActive()) { |
| 387 TRACE_EVENT2("compositor-worker", "LayerTreeImpl::AddToElementMap scroll", |
| 388 "element_id", layer->element_id(), "layer_id", layer->id()); |
| 389 layers.scroll = layer; |
| 390 } |
| 391 } |
| 392 } |
| 393 |
| 394 void LayerTreeImpl::RemoveFromElementMap(LayerImpl* layer) { |
| 395 if (!layer->element_id()) |
| 396 return; |
| 397 |
| 398 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 399 "LayerTreeImpl::RemoveFromElementMap", "element_id", |
| 400 layer->element_id(), "layer_id", layer->id()); |
| 401 |
| 402 ElementLayers& layers = element_layers_map_[layer->element_id()]; |
| 403 if (layer->mutable_properties() & kMainLayerFlags) |
| 404 layers.main = nullptr; |
| 405 if (layer->mutable_properties() & kScrollLayerFlags) |
| 406 layers.scroll = nullptr; |
| 407 |
| 408 if (!layers.main && !layers.scroll) |
| 409 element_layers_map_.erase(layer->element_id()); |
| 410 } |
| 411 |
| 412 LayerTreeImpl::ElementLayers LayerTreeImpl::GetMutableLayers( |
| 413 uint64_t element_id) { |
| 414 auto iter = element_layers_map_.find(element_id); |
| 415 if (iter == element_layers_map_.end()) |
| 416 return ElementLayers(); |
| 417 |
| 418 return iter->second; |
| 419 } |
362 | 420 |
363 LayerImpl* LayerTreeImpl::InnerViewportContainerLayer() const { | 421 LayerImpl* LayerTreeImpl::InnerViewportContainerLayer() const { |
364 return InnerViewportScrollLayer() | 422 return InnerViewportScrollLayer() |
365 ? InnerViewportScrollLayer()->scroll_clip_layer() | 423 ? InnerViewportScrollLayer()->scroll_clip_layer() |
366 : NULL; | 424 : NULL; |
367 } | 425 } |
368 | 426 |
369 LayerImpl* LayerTreeImpl::OuterViewportContainerLayer() const { | 427 LayerImpl* LayerTreeImpl::OuterViewportContainerLayer() const { |
370 return OuterViewportScrollLayer() | 428 return OuterViewportScrollLayer() |
371 ? OuterViewportScrollLayer()->scroll_clip_layer() | 429 ? OuterViewportScrollLayer()->scroll_clip_layer() |
(...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2007 const gfx::BoxF& box, | 2065 const gfx::BoxF& box, |
2008 gfx::BoxF* bounds) const { | 2066 gfx::BoxF* bounds) const { |
2009 *bounds = gfx::BoxF(); | 2067 *bounds = gfx::BoxF(); |
2010 return layer_tree_host_impl_->animation_host() | 2068 return layer_tree_host_impl_->animation_host() |
2011 ? layer_tree_host_impl_->animation_host() | 2069 ? layer_tree_host_impl_->animation_host() |
2012 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) | 2070 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) |
2013 : true; | 2071 : true; |
2014 } | 2072 } |
2015 | 2073 |
2016 } // namespace cc | 2074 } // namespace cc |
OLD | NEW |