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), |
71 current_draw_mode_(DRAW_MODE_NONE) { | 70 current_draw_mode_(DRAW_MODE_NONE) { |
72 DCHECK_GT(layer_id_, 0); | 71 DCHECK_GT(layer_id_, 0); |
73 DCHECK(layer_tree_impl_); | 72 DCHECK(layer_tree_impl_); |
74 layer_tree_impl_->RegisterLayer(this); | 73 layer_tree_impl_->RegisterLayer(this); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 draw_properties_.render_surface->layer_list().clear(); | 240 draw_properties_.render_surface->layer_list().clear(); |
242 } | 241 } |
243 | 242 |
244 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { | 243 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { |
245 state->SetAll(draw_properties_.target_space_transform, | 244 state->SetAll(draw_properties_.target_space_transform, |
246 draw_properties_.content_bounds, | 245 draw_properties_.content_bounds, |
247 draw_properties_.visible_content_rect, | 246 draw_properties_.visible_content_rect, |
248 draw_properties_.clip_rect, | 247 draw_properties_.clip_rect, |
249 draw_properties_.is_clipped, | 248 draw_properties_.is_clipped, |
250 draw_properties_.opacity, | 249 draw_properties_.opacity, |
251 blend_mode_); | 250 blend_mode_, |
| 251 draw_properties_.context_id); |
252 } | 252 } |
253 | 253 |
254 bool LayerImpl::WillDraw(DrawMode draw_mode, | 254 bool LayerImpl::WillDraw(DrawMode draw_mode, |
255 ResourceProvider* resource_provider) { | 255 ResourceProvider* resource_provider) { |
256 // WillDraw/DidDraw must be matched. | 256 // WillDraw/DidDraw must be matched. |
257 DCHECK_NE(DRAW_MODE_NONE, draw_mode); | 257 DCHECK_NE(DRAW_MODE_NONE, draw_mode); |
258 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); | 258 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); |
259 current_draw_mode_ = draw_mode; | 259 current_draw_mode_ = draw_mode; |
260 return true; | 260 return true; |
261 } | 261 } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 509 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
510 layer->SetContentsOpaque(contents_opaque_); | 510 layer->SetContentsOpaque(contents_opaque_); |
511 layer->SetOpacity(opacity_); | 511 layer->SetOpacity(opacity_); |
512 layer->SetBlendMode(blend_mode_); | 512 layer->SetBlendMode(blend_mode_); |
513 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); | 513 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); |
514 layer->SetPosition(position_); | 514 layer->SetPosition(position_); |
515 layer->SetIsContainerForFixedPositionLayers( | 515 layer->SetIsContainerForFixedPositionLayers( |
516 is_container_for_fixed_position_layers_); | 516 is_container_for_fixed_position_layers_); |
517 layer->SetPositionConstraint(position_constraint_); | 517 layer->SetPositionConstraint(position_constraint_); |
518 layer->SetShouldFlattenTransform(should_flatten_transform_); | 518 layer->SetShouldFlattenTransform(should_flatten_transform_); |
519 layer->SetIs3dSorted(is_3d_sorted_); | |
520 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 519 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); |
521 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); | 520 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); |
522 | 521 |
523 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() | 522 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() |
524 : Layer::INVALID_ID); | 523 : Layer::INVALID_ID); |
525 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); | 524 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); |
526 layer->set_user_scrollable_vertical(user_scrollable_vertical_); | 525 layer->set_user_scrollable_vertical(user_scrollable_vertical_); |
527 layer->SetScrollOffsetAndDelta( | 526 layer->SetScrollOffsetAndDelta( |
528 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); | 527 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); |
529 layer->SetSentScrollDelta(gfx::Vector2d()); | 528 layer->SetSentScrollDelta(gfx::Vector2d()); |
| 529 layer->SetContextId(context_id()); |
530 | 530 |
531 LayerImpl* scroll_parent = NULL; | 531 LayerImpl* scroll_parent = NULL; |
532 if (scroll_parent_) { | 532 if (scroll_parent_) { |
533 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); | 533 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); |
534 DCHECK(scroll_parent); | 534 DCHECK(scroll_parent); |
535 } | 535 } |
536 | 536 |
537 layer->SetScrollParent(scroll_parent); | 537 layer->SetScrollParent(scroll_parent); |
538 if (scroll_children_) { | 538 if (scroll_children_) { |
539 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; | 539 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 | 628 |
629 const gfx::Transform& gfx_transform = draw_properties_.target_space_transform; | 629 const gfx::Transform& gfx_transform = draw_properties_.target_space_transform; |
630 double transform[16]; | 630 double transform[16]; |
631 gfx_transform.matrix().asColMajord(transform); | 631 gfx_transform.matrix().asColMajord(transform); |
632 list = new base::ListValue; | 632 list = new base::ListValue; |
633 for (int i = 0; i < 16; ++i) | 633 for (int i = 0; i < 16; ++i) |
634 list->AppendDouble(transform[i]); | 634 list->AppendDouble(transform[i]); |
635 result->Set("DrawTransform", list); | 635 result->Set("DrawTransform", list); |
636 | 636 |
637 result->SetBoolean("DrawsContent", draws_content_); | 637 result->SetBoolean("DrawsContent", draws_content_); |
638 result->SetBoolean("Is3DSorted", is_3d_sorted_); | 638 result->SetBoolean("Is3dSorted", Is3dSorted()); |
639 result->SetDouble("Opacity", opacity()); | 639 result->SetDouble("Opacity", opacity()); |
640 result->SetBoolean("ContentsOpaque", contents_opaque_); | 640 result->SetBoolean("ContentsOpaque", contents_opaque_); |
641 | 641 |
642 if (scrollable()) | 642 if (scrollable()) |
643 result->SetBoolean("Scrollable", true); | 643 result->SetBoolean("Scrollable", true); |
644 | 644 |
645 if (have_wheel_event_handlers_) | 645 if (have_wheel_event_handlers_) |
646 result->SetBoolean("WheelHandler", have_wheel_event_handlers_); | 646 result->SetBoolean("WheelHandler", have_wheel_event_handlers_); |
647 if (have_scroll_event_handlers_) | 647 if (have_scroll_event_handlers_) |
648 result->SetBoolean("ScrollHandler", have_scroll_event_handlers_); | 648 result->SetBoolean("ScrollHandler", have_scroll_event_handlers_); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 } | 971 } |
972 | 972 |
973 void LayerImpl::SetShouldFlattenTransform(bool flatten) { | 973 void LayerImpl::SetShouldFlattenTransform(bool flatten) { |
974 if (should_flatten_transform_ == flatten) | 974 if (should_flatten_transform_ == flatten) |
975 return; | 975 return; |
976 | 976 |
977 should_flatten_transform_ = flatten; | 977 should_flatten_transform_ = flatten; |
978 NoteLayerPropertyChangedForSubtree(); | 978 NoteLayerPropertyChangedForSubtree(); |
979 } | 979 } |
980 | 980 |
981 void LayerImpl::SetIs3dSorted(bool sorted) { | 981 void LayerImpl::SetContextId(int id) { |
982 if (is_3d_sorted_ == sorted) | 982 if ((id == 0 && context_id() == 0) || (id > 0 && context_id() > 0)) |
983 return; | 983 return; |
984 | 984 draw_properties_.context_id = id; |
985 is_3d_sorted_ = sorted; | |
986 NoteLayerPropertyChangedForSubtree(); | 985 NoteLayerPropertyChangedForSubtree(); |
987 } | 986 } |
988 | 987 |
989 void LayerImpl::SetTransform(const gfx::Transform& transform) { | 988 void LayerImpl::SetTransform(const gfx::Transform& transform) { |
990 if (transform_ == transform) | 989 if (transform_ == transform) |
991 return; | 990 return; |
992 | 991 |
993 transform_ = transform; | 992 transform_ = transform; |
994 transform_is_invertible_ = transform_.IsInvertible(); | 993 transform_is_invertible_ = transform_.IsInvertible(); |
995 NoteLayerPropertyChangedForSubtree(); | 994 NoteLayerPropertyChangedForSubtree(); |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 scoped_ptr<base::Value> LayerImpl::AsValue() const { | 1500 scoped_ptr<base::Value> LayerImpl::AsValue() const { |
1502 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 1501 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
1503 AsValueInto(state.get()); | 1502 AsValueInto(state.get()); |
1504 return state.PassAs<base::Value>(); | 1503 return state.PassAs<base::Value>(); |
1505 } | 1504 } |
1506 | 1505 |
1507 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { | 1506 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { |
1508 benchmark->RunOnLayer(this); | 1507 benchmark->RunOnLayer(this); |
1509 } | 1508 } |
1510 } // namespace cc | 1509 } // namespace cc |
OLD | NEW |