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 rendering_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 rendering_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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 510 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
510 layer->SetContentsOpaque(contents_opaque_); | 511 layer->SetContentsOpaque(contents_opaque_); |
511 layer->SetOpacity(opacity_); | 512 layer->SetOpacity(opacity_); |
512 layer->SetBlendMode(blend_mode_); | 513 layer->SetBlendMode(blend_mode_); |
513 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); | 514 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); |
514 layer->SetPosition(position_); | 515 layer->SetPosition(position_); |
515 layer->SetIsContainerForFixedPositionLayers( | 516 layer->SetIsContainerForFixedPositionLayers( |
516 is_container_for_fixed_position_layers_); | 517 is_container_for_fixed_position_layers_); |
517 layer->SetPositionConstraint(position_constraint_); | 518 layer->SetPositionConstraint(position_constraint_); |
518 layer->SetShouldFlattenTransform(should_flatten_transform_); | 519 layer->SetShouldFlattenTransform(should_flatten_transform_); |
519 layer->SetIs3dSorted(is_3d_sorted_); | |
520 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 520 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); |
521 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); | 521 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); |
522 | 522 |
523 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() | 523 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() |
524 : Layer::INVALID_ID); | 524 : Layer::INVALID_ID); |
525 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); | 525 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); |
526 layer->set_user_scrollable_vertical(user_scrollable_vertical_); | 526 layer->set_user_scrollable_vertical(user_scrollable_vertical_); |
527 layer->SetScrollOffsetAndDelta( | 527 layer->SetScrollOffsetAndDelta( |
528 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); | 528 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); |
529 layer->SetSentScrollDelta(gfx::Vector2d()); | 529 layer->SetSentScrollDelta(gfx::Vector2d()); |
| 530 layer->SetRenderingContextId(rendering_context_id_); |
530 | 531 |
531 LayerImpl* scroll_parent = NULL; | 532 LayerImpl* scroll_parent = NULL; |
532 if (scroll_parent_) { | 533 if (scroll_parent_) { |
533 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); | 534 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); |
534 DCHECK(scroll_parent); | 535 DCHECK(scroll_parent); |
535 } | 536 } |
536 | 537 |
537 layer->SetScrollParent(scroll_parent); | 538 layer->SetScrollParent(scroll_parent); |
538 if (scroll_children_) { | 539 if (scroll_children_) { |
539 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; | 540 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 | 629 |
629 const gfx::Transform& gfx_transform = draw_properties_.target_space_transform; | 630 const gfx::Transform& gfx_transform = draw_properties_.target_space_transform; |
630 double transform[16]; | 631 double transform[16]; |
631 gfx_transform.matrix().asColMajord(transform); | 632 gfx_transform.matrix().asColMajord(transform); |
632 list = new base::ListValue; | 633 list = new base::ListValue; |
633 for (int i = 0; i < 16; ++i) | 634 for (int i = 0; i < 16; ++i) |
634 list->AppendDouble(transform[i]); | 635 list->AppendDouble(transform[i]); |
635 result->Set("DrawTransform", list); | 636 result->Set("DrawTransform", list); |
636 | 637 |
637 result->SetBoolean("DrawsContent", draws_content_); | 638 result->SetBoolean("DrawsContent", draws_content_); |
638 result->SetBoolean("Is3DSorted", is_3d_sorted_); | 639 result->SetBoolean("Is3dSorted", Is3dSorted()); |
639 result->SetDouble("Opacity", opacity()); | 640 result->SetDouble("Opacity", opacity()); |
640 result->SetBoolean("ContentsOpaque", contents_opaque_); | 641 result->SetBoolean("ContentsOpaque", contents_opaque_); |
641 | 642 |
642 if (scrollable()) | 643 if (scrollable()) |
643 result->SetBoolean("Scrollable", true); | 644 result->SetBoolean("Scrollable", true); |
644 | 645 |
645 if (have_wheel_event_handlers_) | 646 if (have_wheel_event_handlers_) |
646 result->SetBoolean("WheelHandler", have_wheel_event_handlers_); | 647 result->SetBoolean("WheelHandler", have_wheel_event_handlers_); |
647 if (have_scroll_event_handlers_) | 648 if (have_scroll_event_handlers_) |
648 result->SetBoolean("ScrollHandler", have_scroll_event_handlers_); | 649 result->SetBoolean("ScrollHandler", have_scroll_event_handlers_); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 } | 972 } |
972 | 973 |
973 void LayerImpl::SetShouldFlattenTransform(bool flatten) { | 974 void LayerImpl::SetShouldFlattenTransform(bool flatten) { |
974 if (should_flatten_transform_ == flatten) | 975 if (should_flatten_transform_ == flatten) |
975 return; | 976 return; |
976 | 977 |
977 should_flatten_transform_ = flatten; | 978 should_flatten_transform_ = flatten; |
978 NoteLayerPropertyChangedForSubtree(); | 979 NoteLayerPropertyChangedForSubtree(); |
979 } | 980 } |
980 | 981 |
981 void LayerImpl::SetIs3dSorted(bool sorted) { | 982 void LayerImpl::SetRenderingContextId(int id) { |
982 if (is_3d_sorted_ == sorted) | 983 if (id == rendering_context_id_) |
983 return; | 984 return; |
984 | 985 rendering_context_id_ = id; |
985 is_3d_sorted_ = sorted; | |
986 NoteLayerPropertyChangedForSubtree(); | 986 NoteLayerPropertyChangedForSubtree(); |
987 } | 987 } |
988 | 988 |
989 void LayerImpl::SetTransform(const gfx::Transform& transform) { | 989 void LayerImpl::SetTransform(const gfx::Transform& transform) { |
990 if (transform_ == transform) | 990 if (transform_ == transform) |
991 return; | 991 return; |
992 | 992 |
993 transform_ = transform; | 993 transform_ = transform; |
994 transform_is_invertible_ = transform_.IsInvertible(); | 994 transform_is_invertible_ = transform_.IsInvertible(); |
995 NoteLayerPropertyChangedForSubtree(); | 995 NoteLayerPropertyChangedForSubtree(); |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 scoped_ptr<base::Value> LayerImpl::AsValue() const { | 1501 scoped_ptr<base::Value> LayerImpl::AsValue() const { |
1502 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 1502 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
1503 AsValueInto(state.get()); | 1503 AsValueInto(state.get()); |
1504 return state.PassAs<base::Value>(); | 1504 return state.PassAs<base::Value>(); |
1505 } | 1505 } |
1506 | 1506 |
1507 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { | 1507 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { |
1508 benchmark->RunOnLayer(this); | 1508 benchmark->RunOnLayer(this); |
1509 } | 1509 } |
1510 } // namespace cc | 1510 } // namespace cc |
OLD | NEW |