Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/timer/elapsed_timer.h" | 12 #include "base/timer/elapsed_timer.h" |
| 13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 14 #include "base/trace_event/trace_event_argument.h" | 14 #include "base/trace_event/trace_event_argument.h" |
| 15 #include "cc/animation/animation_host.h" | 15 #include "cc/animation/animation_host.h" |
| 16 #include "cc/animation/keyframed_animation_curve.h" | 16 #include "cc/animation/keyframed_animation_curve.h" |
| 17 #include "cc/animation/mutable_properties.h" | |
| 17 #include "cc/animation/scrollbar_animation_controller.h" | 18 #include "cc/animation/scrollbar_animation_controller.h" |
| 18 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" | 19 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" |
| 19 #include "cc/animation/scrollbar_animation_controller_thinning.h" | 20 #include "cc/animation/scrollbar_animation_controller_thinning.h" |
| 20 #include "cc/base/histograms.h" | 21 #include "cc/base/histograms.h" |
| 21 #include "cc/base/math_util.h" | 22 #include "cc/base/math_util.h" |
| 22 #include "cc/base/synced_property.h" | 23 #include "cc/base/synced_property.h" |
| 23 #include "cc/debug/devtools_instrumentation.h" | 24 #include "cc/debug/devtools_instrumentation.h" |
| 24 #include "cc/debug/traced_value.h" | 25 #include "cc/debug/traced_value.h" |
| 25 #include "cc/input/page_scale_animation.h" | 26 #include "cc/input/page_scale_animation.h" |
| 26 #include "cc/layers/heads_up_display_layer_impl.h" | 27 #include "cc/layers/heads_up_display_layer_impl.h" |
| 27 #include "cc/layers/layer.h" | 28 #include "cc/layers/layer.h" |
| 28 #include "cc/layers/layer_iterator.h" | 29 #include "cc/layers/layer_iterator.h" |
| 29 #include "cc/layers/render_surface_impl.h" | 30 #include "cc/layers/render_surface_impl.h" |
| 30 #include "cc/layers/scrollbar_layer_impl_base.h" | 31 #include "cc/layers/scrollbar_layer_impl_base.h" |
| 31 #include "cc/resources/ui_resource_request.h" | 32 #include "cc/resources/ui_resource_request.h" |
| 32 #include "cc/trees/draw_property_utils.h" | 33 #include "cc/trees/draw_property_utils.h" |
| 33 #include "cc/trees/layer_tree_host_common.h" | 34 #include "cc/trees/layer_tree_host_common.h" |
| 34 #include "cc/trees/layer_tree_host_impl.h" | 35 #include "cc/trees/layer_tree_host_impl.h" |
| 35 #include "cc/trees/occlusion_tracker.h" | 36 #include "cc/trees/occlusion_tracker.h" |
| 36 #include "cc/trees/property_tree.h" | 37 #include "cc/trees/property_tree.h" |
| 37 #include "cc/trees/property_tree_builder.h" | 38 #include "cc/trees/property_tree_builder.h" |
| 38 #include "ui/gfx/geometry/box_f.h" | 39 #include "ui/gfx/geometry/box_f.h" |
| 39 #include "ui/gfx/geometry/point_conversions.h" | 40 #include "ui/gfx/geometry/point_conversions.h" |
| 40 #include "ui/gfx/geometry/size_conversions.h" | 41 #include "ui/gfx/geometry/size_conversions.h" |
| 41 #include "ui/gfx/geometry/vector2d_conversions.h" | 42 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 42 | 43 |
| 43 namespace cc { | 44 namespace cc { |
| 44 | 45 |
| 46 namespace { | |
| 47 | |
| 48 const uint32_t kMainLayerFlags = | |
| 49 kMutablePropertyOpacity | kMutablePropertyTransform; | |
| 50 const uint32_t kScrollLayerFlags = | |
| 51 kMutablePropertyScrollLeft | kMutablePropertyScrollTop; | |
| 52 | |
| 53 } // namespace | |
| 54 | |
| 55 struct ElementLayers { | |
|
ajuma
2015/12/14 19:41:47
There's also an ElementLayers defined inside Layer
Ian Vollick
2015/12/14 20:22:06
No, not needed - forgot to remove this code when I
| |
| 56 // This is the layer to which properties in kMainLayerFlags apply. | |
| 57 LayerImpl* main; | |
| 58 | |
| 59 // This is the layer to which properties in the kScrollLayerFlags apply. | |
| 60 LayerImpl* scroll; | |
| 61 }; | |
| 62 | |
| 45 LayerTreeImpl::LayerTreeImpl( | 63 LayerTreeImpl::LayerTreeImpl( |
| 46 LayerTreeHostImpl* layer_tree_host_impl, | 64 LayerTreeHostImpl* layer_tree_host_impl, |
| 47 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, | 65 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, |
| 48 scoped_refptr<SyncedTopControls> top_controls_shown_ratio, | 66 scoped_refptr<SyncedTopControls> top_controls_shown_ratio, |
| 49 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) | 67 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) |
| 50 : layer_tree_host_impl_(layer_tree_host_impl), | 68 : layer_tree_host_impl_(layer_tree_host_impl), |
| 51 source_frame_number_(-1), | 69 source_frame_number_(-1), |
| 52 hud_layer_(0), | 70 hud_layer_(0), |
| 53 background_color_(0), | 71 background_color_(0), |
| 54 has_transparent_background_(false), | 72 has_transparent_background_(false), |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 | 364 |
| 347 if (hud_layer()) | 365 if (hud_layer()) |
| 348 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( | 366 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( |
| 349 LayerTreeHostCommon::FindLayerInSubtree( | 367 LayerTreeHostCommon::FindLayerInSubtree( |
| 350 target_tree->root_layer(), hud_layer()->id()))); | 368 target_tree->root_layer(), hud_layer()->id()))); |
| 351 else | 369 else |
| 352 target_tree->set_hud_layer(NULL); | 370 target_tree->set_hud_layer(NULL); |
| 353 | 371 |
| 354 target_tree->has_ever_been_drawn_ = false; | 372 target_tree->has_ever_been_drawn_ = false; |
| 355 } | 373 } |
| 374 void LayerTreeImpl::AddToElementMap(LayerImpl* layer) { | |
| 375 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | |
| 376 "LayerTreeImpl::AddToElementMap", "element_id", | |
| 377 layer->element_id(), "layer_id", layer->id()); | |
| 378 ElementLayers& layers = element_layers_map_[layer->element_id()]; | |
| 379 if (layer->mutable_properties() & kMainLayerFlags) { | |
| 380 if (!layers.main || layer->IsActive()) | |
| 381 layers.main = layer; | |
| 382 } | |
| 383 if (layer->mutable_properties() & kScrollLayerFlags) { | |
| 384 if (!layers.scroll || layer->IsActive()) { | |
| 385 TRACE_EVENT2("compositor-worker", "LayerTreeImpl::AddToElementMap scroll", | |
| 386 "element_id", layer->element_id(), "layer_id", layer->id()); | |
| 387 layers.scroll = layer; | |
| 388 } | |
| 389 } | |
| 390 } | |
| 391 | |
| 392 void LayerTreeImpl::RemoveFromElementMap(LayerImpl* layer) { | |
| 393 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | |
| 394 "LayerTreeImpl::RemoveFromElementMap", "element_id", | |
| 395 layer->element_id(), "layer_id", layer->id()); | |
| 396 ElementLayers& layers = element_layers_map_[layer->element_id()]; | |
| 397 if (layer->mutable_properties() & kMainLayerFlags) | |
| 398 layers.main = nullptr; | |
| 399 if (layer->mutable_properties() & kScrollLayerFlags) | |
| 400 layers.scroll = nullptr; | |
| 401 | |
| 402 if (!layers.main && !layers.scroll) | |
| 403 element_layers_map_.erase(layer->element_id()); | |
| 404 } | |
| 405 | |
| 406 LayerTreeImpl::ElementLayers LayerTreeImpl::GetMutableLayers( | |
| 407 uint64_t element_id) { | |
| 408 auto iter = element_layers_map_.find(element_id); | |
| 409 if (iter == element_layers_map_.end()) | |
| 410 return ElementLayers(); | |
| 411 | |
| 412 return iter->second; | |
| 413 } | |
| 356 | 414 |
| 357 LayerImpl* LayerTreeImpl::InnerViewportContainerLayer() const { | 415 LayerImpl* LayerTreeImpl::InnerViewportContainerLayer() const { |
| 358 return InnerViewportScrollLayer() | 416 return InnerViewportScrollLayer() |
| 359 ? InnerViewportScrollLayer()->scroll_clip_layer() | 417 ? InnerViewportScrollLayer()->scroll_clip_layer() |
| 360 : NULL; | 418 : NULL; |
| 361 } | 419 } |
| 362 | 420 |
| 363 LayerImpl* LayerTreeImpl::OuterViewportContainerLayer() const { | 421 LayerImpl* LayerTreeImpl::OuterViewportContainerLayer() const { |
| 364 return OuterViewportScrollLayer() | 422 return OuterViewportScrollLayer() |
| 365 ? OuterViewportScrollLayer()->scroll_clip_layer() | 423 ? OuterViewportScrollLayer()->scroll_clip_layer() |
| (...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1933 const gfx::BoxF& box, | 1991 const gfx::BoxF& box, |
| 1934 gfx::BoxF* bounds) const { | 1992 gfx::BoxF* bounds) const { |
| 1935 *bounds = gfx::BoxF(); | 1993 *bounds = gfx::BoxF(); |
| 1936 return layer_tree_host_impl_->animation_host() | 1994 return layer_tree_host_impl_->animation_host() |
| 1937 ? layer_tree_host_impl_->animation_host() | 1995 ? layer_tree_host_impl_->animation_host() |
| 1938 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) | 1996 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) |
| 1939 : true; | 1997 : true; |
| 1940 } | 1998 } |
| 1941 | 1999 |
| 1942 } // namespace cc | 2000 } // namespace cc |
| OLD | NEW |