| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "cc/animation/animation_registrar.h" | 10 #include "cc/animation/animation_registrar.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 should_flatten_transform_(true), | 56 should_flatten_transform_(true), |
| 57 layer_property_changed_(false), | 57 layer_property_changed_(false), |
| 58 masks_to_bounds_(false), | 58 masks_to_bounds_(false), |
| 59 contents_opaque_(false), | 59 contents_opaque_(false), |
| 60 is_root_for_isolated_group_(false), | 60 is_root_for_isolated_group_(false), |
| 61 use_parent_backface_visibility_(false), | 61 use_parent_backface_visibility_(false), |
| 62 draw_checkerboard_for_missing_tiles_(false), | 62 draw_checkerboard_for_missing_tiles_(false), |
| 63 draws_content_(false), | 63 draws_content_(false), |
| 64 hide_layer_and_subtree_(false), | 64 hide_layer_and_subtree_(false), |
| 65 force_render_surface_(false), | 65 force_render_surface_(false), |
| 66 transform_is_invertible_(true), |
| 66 is_container_for_fixed_position_layers_(false), | 67 is_container_for_fixed_position_layers_(false), |
| 67 is_3d_sorted_(false), | 68 is_3d_sorted_(false), |
| 68 background_color_(0), | 69 background_color_(0), |
| 69 opacity_(1.0), | 70 opacity_(1.0), |
| 70 blend_mode_(SkXfermode::kSrcOver_Mode), | 71 blend_mode_(SkXfermode::kSrcOver_Mode), |
| 71 draw_depth_(0.f), | 72 draw_depth_(0.f), |
| 72 needs_push_properties_(false), | 73 needs_push_properties_(false), |
| 73 num_dependents_need_push_properties_(0), | 74 num_dependents_need_push_properties_(0), |
| 74 current_draw_mode_(DRAW_MODE_NONE) { | 75 current_draw_mode_(DRAW_MODE_NONE) { |
| 75 DCHECK_GT(layer_id_, 0); | 76 DCHECK_GT(layer_id_, 0); |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 layer->SetOpacity(opacity_); | 513 layer->SetOpacity(opacity_); |
| 513 layer->SetBlendMode(blend_mode_); | 514 layer->SetBlendMode(blend_mode_); |
| 514 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); | 515 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); |
| 515 layer->SetPosition(position_); | 516 layer->SetPosition(position_); |
| 516 layer->SetIsContainerForFixedPositionLayers( | 517 layer->SetIsContainerForFixedPositionLayers( |
| 517 is_container_for_fixed_position_layers_); | 518 is_container_for_fixed_position_layers_); |
| 518 layer->SetPositionConstraint(position_constraint_); | 519 layer->SetPositionConstraint(position_constraint_); |
| 519 layer->SetShouldFlattenTransform(should_flatten_transform_); | 520 layer->SetShouldFlattenTransform(should_flatten_transform_); |
| 520 layer->SetIs3dSorted(is_3d_sorted_); | 521 layer->SetIs3dSorted(is_3d_sorted_); |
| 521 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 522 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); |
| 522 layer->SetTransform(transform_); | 523 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); |
| 523 | 524 |
| 524 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() | 525 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() |
| 525 : Layer::INVALID_ID); | 526 : Layer::INVALID_ID); |
| 526 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); | 527 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); |
| 527 layer->set_user_scrollable_vertical(user_scrollable_vertical_); | 528 layer->set_user_scrollable_vertical(user_scrollable_vertical_); |
| 528 layer->SetScrollOffsetAndDelta( | 529 layer->SetScrollOffsetAndDelta( |
| 529 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); | 530 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); |
| 530 layer->SetSentScrollDelta(gfx::Vector2d()); | 531 layer->SetSentScrollDelta(gfx::Vector2d()); |
| 531 | 532 |
| 532 LayerImpl* scroll_parent = NULL; | 533 LayerImpl* scroll_parent = NULL; |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 | 993 |
| 993 is_3d_sorted_ = sorted; | 994 is_3d_sorted_ = sorted; |
| 994 NoteLayerPropertyChangedForSubtree(); | 995 NoteLayerPropertyChangedForSubtree(); |
| 995 } | 996 } |
| 996 | 997 |
| 997 void LayerImpl::SetTransform(const gfx::Transform& transform) { | 998 void LayerImpl::SetTransform(const gfx::Transform& transform) { |
| 998 if (transform_ == transform) | 999 if (transform_ == transform) |
| 999 return; | 1000 return; |
| 1000 | 1001 |
| 1001 transform_ = transform; | 1002 transform_ = transform; |
| 1003 transform_is_invertible_ = transform_.IsInvertible(); |
| 1002 NoteLayerPropertyChangedForSubtree(); | 1004 NoteLayerPropertyChangedForSubtree(); |
| 1003 } | 1005 } |
| 1004 | 1006 |
| 1007 void LayerImpl::SetTransformAndInvertibility(const gfx::Transform& transform, |
| 1008 bool transform_is_invertible) { |
| 1009 if (transform_ == transform) { |
| 1010 DCHECK(transform_is_invertible_ == transform_is_invertible) |
| 1011 << "Can't change invertibility if transform is unchanged"; |
| 1012 return; |
| 1013 } |
| 1014 transform_ = transform; |
| 1015 transform_is_invertible_ = transform_is_invertible; |
| 1016 NoteLayerPropertyChangedForSubtree(); |
| 1017 } |
| 1018 |
| 1005 bool LayerImpl::TransformIsAnimating() const { | 1019 bool LayerImpl::TransformIsAnimating() const { |
| 1006 return layer_animation_controller_->IsAnimatingProperty(Animation::Transform); | 1020 return layer_animation_controller_->IsAnimatingProperty(Animation::Transform); |
| 1007 } | 1021 } |
| 1008 | 1022 |
| 1009 bool LayerImpl::TransformIsAnimatingOnImplOnly() const { | 1023 bool LayerImpl::TransformIsAnimatingOnImplOnly() const { |
| 1010 Animation* transform_animation = | 1024 Animation* transform_animation = |
| 1011 layer_animation_controller_->GetAnimation(Animation::Transform); | 1025 layer_animation_controller_->GetAnimation(Animation::Transform); |
| 1012 return transform_animation && transform_animation->is_impl_only(); | 1026 return transform_animation && transform_animation->is_impl_only(); |
| 1013 } | 1027 } |
| 1014 | 1028 |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 scoped_ptr<base::Value> LayerImpl::AsValue() const { | 1514 scoped_ptr<base::Value> LayerImpl::AsValue() const { |
| 1501 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 1515 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 1502 AsValueInto(state.get()); | 1516 AsValueInto(state.get()); |
| 1503 return state.PassAs<base::Value>(); | 1517 return state.PassAs<base::Value>(); |
| 1504 } | 1518 } |
| 1505 | 1519 |
| 1506 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { | 1520 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { |
| 1507 benchmark->RunOnLayer(this); | 1521 benchmark->RunOnLayer(this); |
| 1508 } | 1522 } |
| 1509 } // namespace cc | 1523 } // namespace cc |
| OLD | NEW |