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 | |
45 LayerTreeImpl::LayerTreeImpl( | 55 LayerTreeImpl::LayerTreeImpl( |
46 LayerTreeHostImpl* layer_tree_host_impl, | 56 LayerTreeHostImpl* layer_tree_host_impl, |
47 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, | 57 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, |
48 scoped_refptr<SyncedTopControls> top_controls_shown_ratio, | 58 scoped_refptr<SyncedTopControls> top_controls_shown_ratio, |
49 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) | 59 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) |
50 : layer_tree_host_impl_(layer_tree_host_impl), | 60 : layer_tree_host_impl_(layer_tree_host_impl), |
51 source_frame_number_(-1), | 61 source_frame_number_(-1), |
52 hud_layer_(0), | 62 hud_layer_(0), |
53 background_color_(0), | 63 background_color_(0), |
54 has_transparent_background_(false), | 64 has_transparent_background_(false), |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 | 356 |
347 if (hud_layer()) | 357 if (hud_layer()) |
348 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( | 358 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( |
349 LayerTreeHostCommon::FindLayerInSubtree( | 359 LayerTreeHostCommon::FindLayerInSubtree( |
350 target_tree->root_layer(), hud_layer()->id()))); | 360 target_tree->root_layer(), hud_layer()->id()))); |
351 else | 361 else |
352 target_tree->set_hud_layer(NULL); | 362 target_tree->set_hud_layer(NULL); |
353 | 363 |
354 target_tree->has_ever_been_drawn_ = false; | 364 target_tree->has_ever_been_drawn_ = false; |
355 } | 365 } |
366 void LayerTreeImpl::AddToElementMap(LayerImpl* layer) { | |
367 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | |
368 "LayerTreeImpl::AddToElementMap", "element_id", | |
369 layer->element_id(), "layer_id", layer->id()); | |
370 ElementLayers& layers = element_layers_map_[layer->element_id()]; | |
esprehn
2015/12/16 04:01:58
this puts a new hash lookup for every composited l
Ian Vollick
2015/12/23 17:34:40
A non-zero element id is actually pretty rare. Bef
| |
371 if (layer->mutable_properties() & kMainLayerFlags) { | |
372 if (!layers.main || layer->IsActive()) | |
373 layers.main = layer; | |
374 } | |
375 if (layer->mutable_properties() & kScrollLayerFlags) { | |
376 if (!layers.scroll || layer->IsActive()) { | |
377 TRACE_EVENT2("compositor-worker", "LayerTreeImpl::AddToElementMap scroll", | |
378 "element_id", layer->element_id(), "layer_id", layer->id()); | |
379 layers.scroll = layer; | |
380 } | |
381 } | |
382 } | |
383 | |
384 void LayerTreeImpl::RemoveFromElementMap(LayerImpl* layer) { | |
385 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | |
386 "LayerTreeImpl::RemoveFromElementMap", "element_id", | |
387 layer->element_id(), "layer_id", layer->id()); | |
388 ElementLayers& layers = element_layers_map_[layer->element_id()]; | |
esprehn
2015/12/16 04:01:58
and another map lookup for every layer removal
Ian Vollick
2015/12/23 17:34:40
Ditto.
| |
389 if (layer->mutable_properties() & kMainLayerFlags) | |
390 layers.main = nullptr; | |
391 if (layer->mutable_properties() & kScrollLayerFlags) | |
392 layers.scroll = nullptr; | |
393 | |
394 if (!layers.main && !layers.scroll) | |
395 element_layers_map_.erase(layer->element_id()); | |
396 } | |
397 | |
398 LayerTreeImpl::ElementLayers LayerTreeImpl::GetMutableLayers( | |
399 uint64_t element_id) { | |
400 auto iter = element_layers_map_.find(element_id); | |
401 if (iter == element_layers_map_.end()) | |
402 return ElementLayers(); | |
403 | |
404 return iter->second; | |
405 } | |
356 | 406 |
357 LayerImpl* LayerTreeImpl::InnerViewportContainerLayer() const { | 407 LayerImpl* LayerTreeImpl::InnerViewportContainerLayer() const { |
358 return InnerViewportScrollLayer() | 408 return InnerViewportScrollLayer() |
359 ? InnerViewportScrollLayer()->scroll_clip_layer() | 409 ? InnerViewportScrollLayer()->scroll_clip_layer() |
360 : NULL; | 410 : NULL; |
361 } | 411 } |
362 | 412 |
363 LayerImpl* LayerTreeImpl::OuterViewportContainerLayer() const { | 413 LayerImpl* LayerTreeImpl::OuterViewportContainerLayer() const { |
364 return OuterViewportScrollLayer() | 414 return OuterViewportScrollLayer() |
365 ? OuterViewportScrollLayer()->scroll_clip_layer() | 415 ? OuterViewportScrollLayer()->scroll_clip_layer() |
(...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1933 const gfx::BoxF& box, | 1983 const gfx::BoxF& box, |
1934 gfx::BoxF* bounds) const { | 1984 gfx::BoxF* bounds) const { |
1935 *bounds = gfx::BoxF(); | 1985 *bounds = gfx::BoxF(); |
1936 return layer_tree_host_impl_->animation_host() | 1986 return layer_tree_host_impl_->animation_host() |
1937 ? layer_tree_host_impl_->animation_host() | 1987 ? layer_tree_host_impl_->animation_host() |
1938 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) | 1988 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) |
1939 : true; | 1989 : true; |
1940 } | 1990 } |
1941 | 1991 |
1942 } // namespace cc | 1992 } // namespace cc |
OLD | NEW |