OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/layers/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 return make_scoped_refptr(new Layer()); | 35 return make_scoped_refptr(new Layer()); |
36 } | 36 } |
37 | 37 |
38 Layer::Layer() | 38 Layer::Layer() |
39 : needs_push_properties_(false), | 39 : needs_push_properties_(false), |
40 num_dependents_need_push_properties_(false), | 40 num_dependents_need_push_properties_(false), |
41 stacking_order_changed_(false), | 41 stacking_order_changed_(false), |
42 // Layer IDs start from 1. | 42 // Layer IDs start from 1. |
43 layer_id_(g_next_layer_id.GetNext() + 1), | 43 layer_id_(g_next_layer_id.GetNext() + 1), |
44 ignore_set_needs_commit_(false), | 44 ignore_set_needs_commit_(false), |
| 45 sorting_context_id_(0), |
45 parent_(NULL), | 46 parent_(NULL), |
46 layer_tree_host_(NULL), | 47 layer_tree_host_(NULL), |
47 scroll_clip_layer_id_(INVALID_ID), | 48 scroll_clip_layer_id_(INVALID_ID), |
48 should_scroll_on_main_thread_(false), | 49 should_scroll_on_main_thread_(false), |
49 have_wheel_event_handlers_(false), | 50 have_wheel_event_handlers_(false), |
50 have_scroll_event_handlers_(false), | 51 have_scroll_event_handlers_(false), |
51 user_scrollable_horizontal_(true), | 52 user_scrollable_horizontal_(true), |
52 user_scrollable_vertical_(true), | 53 user_scrollable_vertical_(true), |
53 is_root_for_isolated_group_(false), | 54 is_root_for_isolated_group_(false), |
54 is_container_for_fixed_position_layers_(false), | 55 is_container_for_fixed_position_layers_(false), |
55 is_drawable_(false), | 56 is_drawable_(false), |
56 hide_layer_and_subtree_(false), | 57 hide_layer_and_subtree_(false), |
57 masks_to_bounds_(false), | 58 masks_to_bounds_(false), |
58 contents_opaque_(false), | 59 contents_opaque_(false), |
59 double_sided_(true), | 60 double_sided_(true), |
60 should_flatten_transform_(true), | 61 should_flatten_transform_(true), |
61 use_parent_backface_visibility_(false), | 62 use_parent_backface_visibility_(false), |
62 draw_checkerboard_for_missing_tiles_(false), | 63 draw_checkerboard_for_missing_tiles_(false), |
63 force_render_surface_(false), | 64 force_render_surface_(false), |
64 is_3d_sorted_(false), | |
65 transform_is_invertible_(true), | 65 transform_is_invertible_(true), |
66 background_color_(0), | 66 background_color_(0), |
67 opacity_(1.f), | 67 opacity_(1.f), |
68 blend_mode_(SkXfermode::kSrcOver_Mode), | 68 blend_mode_(SkXfermode::kSrcOver_Mode), |
69 scroll_parent_(NULL), | 69 scroll_parent_(NULL), |
70 clip_parent_(NULL), | 70 clip_parent_(NULL), |
71 replica_layer_(NULL), | 71 replica_layer_(NULL), |
72 raster_scale_(0.f), | 72 raster_scale_(0.f), |
73 client_(NULL) { | 73 client_(NULL) { |
74 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); | 74 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 } | 749 } |
750 | 750 |
751 void Layer::SetDoubleSided(bool double_sided) { | 751 void Layer::SetDoubleSided(bool double_sided) { |
752 DCHECK(IsPropertyChangeAllowed()); | 752 DCHECK(IsPropertyChangeAllowed()); |
753 if (double_sided_ == double_sided) | 753 if (double_sided_ == double_sided) |
754 return; | 754 return; |
755 double_sided_ = double_sided; | 755 double_sided_ = double_sided; |
756 SetNeedsCommit(); | 756 SetNeedsCommit(); |
757 } | 757 } |
758 | 758 |
759 void Layer::SetIs3dSorted(bool sorted) { | 759 void Layer::Set3dSortingContextId(int id) { |
760 DCHECK(IsPropertyChangeAllowed()); | 760 DCHECK(IsPropertyChangeAllowed()); |
761 if (is_3d_sorted_ == sorted) | 761 if (id == sorting_context_id_) |
762 return; | 762 return; |
763 is_3d_sorted_ = sorted; | 763 sorting_context_id_ = id; |
764 SetNeedsCommit(); | 764 SetNeedsCommit(); |
765 } | 765 } |
766 | 766 |
767 void Layer::SetShouldFlattenTransform(bool should_flatten) { | 767 void Layer::SetShouldFlattenTransform(bool should_flatten) { |
768 DCHECK(IsPropertyChangeAllowed()); | 768 DCHECK(IsPropertyChangeAllowed()); |
769 if (should_flatten_transform_ == should_flatten) | 769 if (should_flatten_transform_ == should_flatten) |
770 return; | 770 return; |
771 should_flatten_transform_ = should_flatten; | 771 should_flatten_transform_ = should_flatten; |
772 SetNeedsCommit(); | 772 SetNeedsCommit(); |
773 } | 773 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) | 887 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) |
888 layer->SetOpacity(opacity_); | 888 layer->SetOpacity(opacity_); |
889 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); | 889 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); |
890 layer->SetBlendMode(blend_mode_); | 890 layer->SetBlendMode(blend_mode_); |
891 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); | 891 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); |
892 layer->SetPosition(position_); | 892 layer->SetPosition(position_); |
893 layer->SetIsContainerForFixedPositionLayers( | 893 layer->SetIsContainerForFixedPositionLayers( |
894 IsContainerForFixedPositionLayers()); | 894 IsContainerForFixedPositionLayers()); |
895 layer->SetPositionConstraint(position_constraint_); | 895 layer->SetPositionConstraint(position_constraint_); |
896 layer->SetShouldFlattenTransform(should_flatten_transform_); | 896 layer->SetShouldFlattenTransform(should_flatten_transform_); |
897 layer->SetIs3dSorted(is_3d_sorted_); | |
898 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 897 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); |
899 if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating()) | 898 if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating()) |
900 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); | 899 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); |
901 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); | 900 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); |
| 901 layer->Set3dSortingContextId(sorting_context_id_); |
902 | 902 |
903 layer->SetScrollClipLayer(scroll_clip_layer_id_); | 903 layer->SetScrollClipLayer(scroll_clip_layer_id_); |
904 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); | 904 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); |
905 layer->set_user_scrollable_vertical(user_scrollable_vertical_); | 905 layer->set_user_scrollable_vertical(user_scrollable_vertical_); |
906 | 906 |
907 LayerImpl* scroll_parent = NULL; | 907 LayerImpl* scroll_parent = NULL; |
908 if (scroll_parent_) { | 908 if (scroll_parent_) { |
909 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); | 909 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); |
910 DCHECK(scroll_parent); | 910 DCHECK(scroll_parent); |
911 } | 911 } |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 if (clip_parent_) | 1180 if (clip_parent_) |
1181 clip_parent_->RemoveClipChild(this); | 1181 clip_parent_->RemoveClipChild(this); |
1182 | 1182 |
1183 clip_parent_ = NULL; | 1183 clip_parent_ = NULL; |
1184 } | 1184 } |
1185 | 1185 |
1186 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 1186 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
1187 benchmark->RunOnLayer(this); | 1187 benchmark->RunOnLayer(this); |
1188 } | 1188 } |
1189 } // namespace cc | 1189 } // namespace cc |
OLD | NEW |