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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 masks_to_bounds_(false), | 54 masks_to_bounds_(false), |
55 contents_opaque_(false), | 55 contents_opaque_(false), |
56 is_root_for_isolated_group_(false), | 56 is_root_for_isolated_group_(false), |
57 use_parent_backface_visibility_(false), | 57 use_parent_backface_visibility_(false), |
58 draw_checkerboard_for_missing_tiles_(false), | 58 draw_checkerboard_for_missing_tiles_(false), |
59 draws_content_(false), | 59 draws_content_(false), |
60 hide_layer_and_subtree_(false), | 60 hide_layer_and_subtree_(false), |
61 force_render_surface_(false), | 61 force_render_surface_(false), |
62 transform_is_invertible_(true), | 62 transform_is_invertible_(true), |
63 is_container_for_fixed_position_layers_(false), | 63 is_container_for_fixed_position_layers_(false), |
64 is_3d_sorted_(false), | |
65 background_color_(0), | 64 background_color_(0), |
66 opacity_(1.0), | 65 opacity_(1.0), |
67 blend_mode_(SkXfermode::kSrcOver_Mode), | 66 blend_mode_(SkXfermode::kSrcOver_Mode), |
68 draw_depth_(0.f), | 67 draw_depth_(0.f), |
69 needs_push_properties_(false), | 68 needs_push_properties_(false), |
70 num_dependents_need_push_properties_(0), | 69 num_dependents_need_push_properties_(0), |
| 70 sorting_context_id_(0), |
71 current_draw_mode_(DRAW_MODE_NONE) { | 71 current_draw_mode_(DRAW_MODE_NONE) { |
72 DCHECK_GT(layer_id_, 0); | 72 DCHECK_GT(layer_id_, 0); |
73 DCHECK(layer_tree_impl_); | 73 DCHECK(layer_tree_impl_); |
74 layer_tree_impl_->RegisterLayer(this); | 74 layer_tree_impl_->RegisterLayer(this); |
75 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar(); | 75 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar(); |
76 layer_animation_controller_ = | 76 layer_animation_controller_ = |
77 registrar->GetAnimationControllerForId(layer_id_); | 77 registrar->GetAnimationControllerForId(layer_id_); |
78 layer_animation_controller_->AddValueObserver(this); | 78 layer_animation_controller_->AddValueObserver(this); |
79 if (IsActive()) | 79 if (IsActive()) |
80 layer_animation_controller_->set_value_provider(this); | 80 layer_animation_controller_->set_value_provider(this); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 draw_properties_.render_surface->layer_list().clear(); | 241 draw_properties_.render_surface->layer_list().clear(); |
242 } | 242 } |
243 | 243 |
244 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { | 244 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { |
245 state->SetAll(draw_properties_.target_space_transform, | 245 state->SetAll(draw_properties_.target_space_transform, |
246 draw_properties_.content_bounds, | 246 draw_properties_.content_bounds, |
247 draw_properties_.visible_content_rect, | 247 draw_properties_.visible_content_rect, |
248 draw_properties_.clip_rect, | 248 draw_properties_.clip_rect, |
249 draw_properties_.is_clipped, | 249 draw_properties_.is_clipped, |
250 draw_properties_.opacity, | 250 draw_properties_.opacity, |
251 blend_mode_); | 251 blend_mode_, |
| 252 sorting_context_id_); |
252 } | 253 } |
253 | 254 |
254 bool LayerImpl::WillDraw(DrawMode draw_mode, | 255 bool LayerImpl::WillDraw(DrawMode draw_mode, |
255 ResourceProvider* resource_provider) { | 256 ResourceProvider* resource_provider) { |
256 // WillDraw/DidDraw must be matched. | 257 // WillDraw/DidDraw must be matched. |
257 DCHECK_NE(DRAW_MODE_NONE, draw_mode); | 258 DCHECK_NE(DRAW_MODE_NONE, draw_mode); |
258 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); | 259 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); |
259 current_draw_mode_ = draw_mode; | 260 current_draw_mode_ = draw_mode; |
260 return true; | 261 return true; |
261 } | 262 } |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 506 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
506 layer->SetContentsOpaque(contents_opaque_); | 507 layer->SetContentsOpaque(contents_opaque_); |
507 layer->SetOpacity(opacity_); | 508 layer->SetOpacity(opacity_); |
508 layer->SetBlendMode(blend_mode_); | 509 layer->SetBlendMode(blend_mode_); |
509 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); | 510 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); |
510 layer->SetPosition(position_); | 511 layer->SetPosition(position_); |
511 layer->SetIsContainerForFixedPositionLayers( | 512 layer->SetIsContainerForFixedPositionLayers( |
512 is_container_for_fixed_position_layers_); | 513 is_container_for_fixed_position_layers_); |
513 layer->SetPositionConstraint(position_constraint_); | 514 layer->SetPositionConstraint(position_constraint_); |
514 layer->SetShouldFlattenTransform(should_flatten_transform_); | 515 layer->SetShouldFlattenTransform(should_flatten_transform_); |
515 layer->SetIs3dSorted(is_3d_sorted_); | |
516 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 516 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); |
517 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); | 517 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); |
518 | 518 |
519 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() | 519 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() |
520 : Layer::INVALID_ID); | 520 : Layer::INVALID_ID); |
521 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); | 521 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); |
522 layer->set_user_scrollable_vertical(user_scrollable_vertical_); | 522 layer->set_user_scrollable_vertical(user_scrollable_vertical_); |
523 layer->SetScrollOffsetAndDelta( | 523 layer->SetScrollOffsetAndDelta( |
524 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); | 524 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); |
525 layer->SetSentScrollDelta(gfx::Vector2d()); | 525 layer->SetSentScrollDelta(gfx::Vector2d()); |
| 526 layer->Set3dSortingContextId(sorting_context_id_); |
526 | 527 |
527 LayerImpl* scroll_parent = NULL; | 528 LayerImpl* scroll_parent = NULL; |
528 if (scroll_parent_) { | 529 if (scroll_parent_) { |
529 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); | 530 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); |
530 DCHECK(scroll_parent); | 531 DCHECK(scroll_parent); |
531 } | 532 } |
532 | 533 |
533 layer->SetScrollParent(scroll_parent); | 534 layer->SetScrollParent(scroll_parent); |
534 if (scroll_children_) { | 535 if (scroll_children_) { |
535 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; | 536 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 | 625 |
625 const gfx::Transform& gfx_transform = draw_properties_.target_space_transform; | 626 const gfx::Transform& gfx_transform = draw_properties_.target_space_transform; |
626 double transform[16]; | 627 double transform[16]; |
627 gfx_transform.matrix().asColMajord(transform); | 628 gfx_transform.matrix().asColMajord(transform); |
628 list = new base::ListValue; | 629 list = new base::ListValue; |
629 for (int i = 0; i < 16; ++i) | 630 for (int i = 0; i < 16; ++i) |
630 list->AppendDouble(transform[i]); | 631 list->AppendDouble(transform[i]); |
631 result->Set("DrawTransform", list); | 632 result->Set("DrawTransform", list); |
632 | 633 |
633 result->SetBoolean("DrawsContent", draws_content_); | 634 result->SetBoolean("DrawsContent", draws_content_); |
634 result->SetBoolean("Is3DSorted", is_3d_sorted_); | 635 result->SetBoolean("Is3dSorted", Is3dSorted()); |
635 result->SetDouble("Opacity", opacity()); | 636 result->SetDouble("Opacity", opacity()); |
636 result->SetBoolean("ContentsOpaque", contents_opaque_); | 637 result->SetBoolean("ContentsOpaque", contents_opaque_); |
637 | 638 |
638 if (scrollable()) | 639 if (scrollable()) |
639 result->SetBoolean("Scrollable", true); | 640 result->SetBoolean("Scrollable", true); |
640 | 641 |
641 if (have_wheel_event_handlers_) | 642 if (have_wheel_event_handlers_) |
642 result->SetBoolean("WheelHandler", have_wheel_event_handlers_); | 643 result->SetBoolean("WheelHandler", have_wheel_event_handlers_); |
643 if (have_scroll_event_handlers_) | 644 if (have_scroll_event_handlers_) |
644 result->SetBoolean("ScrollHandler", have_scroll_event_handlers_); | 645 result->SetBoolean("ScrollHandler", have_scroll_event_handlers_); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 } | 968 } |
968 | 969 |
969 void LayerImpl::SetShouldFlattenTransform(bool flatten) { | 970 void LayerImpl::SetShouldFlattenTransform(bool flatten) { |
970 if (should_flatten_transform_ == flatten) | 971 if (should_flatten_transform_ == flatten) |
971 return; | 972 return; |
972 | 973 |
973 should_flatten_transform_ = flatten; | 974 should_flatten_transform_ = flatten; |
974 NoteLayerPropertyChangedForSubtree(); | 975 NoteLayerPropertyChangedForSubtree(); |
975 } | 976 } |
976 | 977 |
977 void LayerImpl::SetIs3dSorted(bool sorted) { | 978 void LayerImpl::Set3dSortingContextId(int id) { |
978 if (is_3d_sorted_ == sorted) | 979 if (id == sorting_context_id_) |
979 return; | 980 return; |
980 | 981 sorting_context_id_ = id; |
981 is_3d_sorted_ = sorted; | |
982 NoteLayerPropertyChangedForSubtree(); | 982 NoteLayerPropertyChangedForSubtree(); |
983 } | 983 } |
984 | 984 |
985 void LayerImpl::SetTransform(const gfx::Transform& transform) { | 985 void LayerImpl::SetTransform(const gfx::Transform& transform) { |
986 if (transform_ == transform) | 986 if (transform_ == transform) |
987 return; | 987 return; |
988 | 988 |
989 transform_ = transform; | 989 transform_ = transform; |
990 transform_is_invertible_ = transform_.IsInvertible(); | 990 transform_is_invertible_ = transform_.IsInvertible(); |
991 NoteLayerPropertyChangedForSubtree(); | 991 NoteLayerPropertyChangedForSubtree(); |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 scoped_ptr<base::Value> LayerImpl::AsValue() const { | 1481 scoped_ptr<base::Value> LayerImpl::AsValue() const { |
1482 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 1482 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
1483 AsValueInto(state.get()); | 1483 AsValueInto(state.get()); |
1484 return state.PassAs<base::Value>(); | 1484 return state.PassAs<base::Value>(); |
1485 } | 1485 } |
1486 | 1486 |
1487 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { | 1487 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { |
1488 benchmark->RunOnLayer(this); | 1488 benchmark->RunOnLayer(this); |
1489 } | 1489 } |
1490 } // namespace cc | 1490 } // namespace cc |
OLD | NEW |