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/layers/layer_impl.h" | 5 #include "cc/layers/layer_impl.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "cc/animation/animation_registrar.h" | 10 #include "cc/animation/animation_registrar.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 draws_content_(false), | 50 draws_content_(false), |
51 force_render_surface_(false), | 51 force_render_surface_(false), |
52 is_container_for_fixed_position_layers_(false), | 52 is_container_for_fixed_position_layers_(false), |
53 fixed_to_container_layer_(false), | 53 fixed_to_container_layer_(false), |
54 draw_depth_(0.f), | 54 draw_depth_(0.f), |
55 #ifndef NDEBUG | 55 #ifndef NDEBUG |
56 between_will_draw_and_did_draw_(false), | 56 between_will_draw_and_did_draw_(false), |
57 #endif | 57 #endif |
58 horizontal_scrollbar_layer_(NULL), | 58 horizontal_scrollbar_layer_(NULL), |
59 vertical_scrollbar_layer_(NULL) { | 59 vertical_scrollbar_layer_(NULL) { |
60 DCHECK(layer_id_ > 0); | 60 DCHECK_GT(layer_id_, 0); |
61 DCHECK(layer_tree_impl_); | 61 DCHECK(layer_tree_impl_); |
62 layer_tree_impl_->RegisterLayer(this); | 62 layer_tree_impl_->RegisterLayer(this); |
63 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar(); | 63 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar(); |
64 layer_animation_controller_ = | 64 layer_animation_controller_ = |
65 registrar->GetAnimationControllerForId(layer_id_); | 65 registrar->GetAnimationControllerForId(layer_id_); |
66 layer_animation_controller_->AddObserver(this); | 66 layer_animation_controller_->AddObserver(this); |
67 } | 67 } |
68 | 68 |
69 LayerImpl::~LayerImpl() { | 69 LayerImpl::~LayerImpl() { |
70 #ifndef NDEBUG | 70 #ifndef NDEBUG |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 bool need_scrollbar_animation_controller = horizontal_scrollbar_layer_ || | 928 bool need_scrollbar_animation_controller = horizontal_scrollbar_layer_ || |
929 vertical_scrollbar_layer_; | 929 vertical_scrollbar_layer_; |
930 if (need_scrollbar_animation_controller) { | 930 if (need_scrollbar_animation_controller) { |
931 if (!scrollbar_animation_controller_) { | 931 if (!scrollbar_animation_controller_) { |
932 scrollbar_animation_controller_ = | 932 scrollbar_animation_controller_ = |
933 CreateScrollbarAnimationControllerWithFade(this); | 933 CreateScrollbarAnimationControllerWithFade(this); |
934 } | 934 } |
935 } else { | 935 } else { |
936 scrollbar_animation_controller_.reset(); | 936 scrollbar_animation_controller_.reset(); |
937 } | 937 } |
938 | |
939 } | 938 } |
940 void LayerImpl::SetHorizontalScrollbarLayer( | 939 void LayerImpl::SetHorizontalScrollbarLayer( |
941 ScrollbarLayerImpl* scrollbar_layer) { | 940 ScrollbarLayerImpl* scrollbar_layer) { |
942 horizontal_scrollbar_layer_ = scrollbar_layer; | 941 horizontal_scrollbar_layer_ = scrollbar_layer; |
943 if (horizontal_scrollbar_layer_) | 942 if (horizontal_scrollbar_layer_) |
944 horizontal_scrollbar_layer_->set_scroll_layer_id(id()); | 943 horizontal_scrollbar_layer_->set_scroll_layer_id(id()); |
945 } | 944 } |
946 | 945 |
947 void LayerImpl::SetVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbar_layer) { | 946 void LayerImpl::SetVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbar_layer) { |
948 vertical_scrollbar_layer_ = scrollbar_layer; | 947 vertical_scrollbar_layer_ = scrollbar_layer; |
949 if (vertical_scrollbar_layer_) | 948 if (vertical_scrollbar_layer_) |
950 vertical_scrollbar_layer_->set_scroll_layer_id(id()); | 949 vertical_scrollbar_layer_->set_scroll_layer_id(id()); |
951 } | 950 } |
952 | 951 |
953 void LayerImpl::AsValueInto(base::DictionaryValue* dict) const { | 952 void LayerImpl::AsValueInto(base::DictionaryValue* dict) const { |
954 dict->SetInteger("id", id()); | 953 dict->SetInteger("id", id()); |
955 dict->Set("bounds", MathUtil::AsValue(bounds()).release()); | 954 dict->Set("bounds", MathUtil::AsValue(bounds()).release()); |
956 dict->SetInteger("draws_content", DrawsContent()); | 955 dict->SetInteger("draws_content", DrawsContent()); |
957 | 956 |
958 bool clipped; | 957 bool clipped; |
959 gfx::QuadF layer_quad = MathUtil::MapQuad( | 958 gfx::QuadF layer_quad = MathUtil::MapQuad( |
960 screen_space_transform(), | 959 screen_space_transform(), |
961 gfx::QuadF(gfx::Rect(content_bounds())), | 960 gfx::QuadF(gfx::Rect(content_bounds())), |
962 &clipped); | 961 &clipped); |
963 dict->Set("layer_quad", MathUtil::AsValue(layer_quad).release()); | 962 dict->Set("layer_quad", MathUtil::AsValue(layer_quad).release()); |
964 | |
965 } | 963 } |
966 | 964 |
967 scoped_ptr<base::Value> LayerImpl::AsValue() const { | 965 scoped_ptr<base::Value> LayerImpl::AsValue() const { |
968 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 966 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
969 AsValueInto(state.get()); | 967 AsValueInto(state.get()); |
970 return state.PassAs<base::Value>(); | 968 return state.PassAs<base::Value>(); |
971 } | 969 } |
972 | 970 |
973 } // namespace cc | 971 } // namespace cc |
OLD | NEW |