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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 scroll_parent_(nullptr), | 53 scroll_parent_(nullptr), |
54 clip_parent_(nullptr), | 54 clip_parent_(nullptr), |
55 mask_layer_id_(-1), | 55 mask_layer_id_(-1), |
56 replica_layer_id_(-1), | 56 replica_layer_id_(-1), |
57 layer_id_(id), | 57 layer_id_(id), |
58 layer_tree_impl_(tree_impl), | 58 layer_tree_impl_(tree_impl), |
59 scroll_offset_(scroll_offset), | 59 scroll_offset_(scroll_offset), |
60 scroll_clip_layer_id_(Layer::INVALID_ID), | 60 scroll_clip_layer_id_(Layer::INVALID_ID), |
61 main_thread_scrolling_reasons_( | 61 main_thread_scrolling_reasons_( |
62 MainThreadScrollingReason::kNotScrollingOnMain), | 62 MainThreadScrollingReason::kNotScrollingOnMain), |
63 have_wheel_event_handlers_(false), | |
64 have_scroll_event_handlers_(false), | 63 have_scroll_event_handlers_(false), |
65 user_scrollable_horizontal_(true), | 64 user_scrollable_horizontal_(true), |
66 user_scrollable_vertical_(true), | 65 user_scrollable_vertical_(true), |
67 stacking_order_changed_(false), | 66 stacking_order_changed_(false), |
68 double_sided_(true), | 67 double_sided_(true), |
69 should_flatten_transform_(true), | 68 should_flatten_transform_(true), |
70 should_flatten_transform_from_property_tree_(false), | 69 should_flatten_transform_from_property_tree_(false), |
71 layer_property_changed_(false), | 70 layer_property_changed_(false), |
72 masks_to_bounds_(false), | 71 masks_to_bounds_(false), |
73 contents_opaque_(false), | 72 contents_opaque_(false), |
(...skipping 18 matching lines...) Expand all Loading... |
92 needs_push_properties_(false), | 91 needs_push_properties_(false), |
93 num_dependents_need_push_properties_(0), | 92 num_dependents_need_push_properties_(0), |
94 sorting_context_id_(0), | 93 sorting_context_id_(0), |
95 current_draw_mode_(DRAW_MODE_NONE), | 94 current_draw_mode_(DRAW_MODE_NONE), |
96 element_id_(0), | 95 element_id_(0), |
97 mutable_properties_(MutableProperty::kNone), | 96 mutable_properties_(MutableProperty::kNone), |
98 force_render_surface_(false), | 97 force_render_surface_(false), |
99 frame_timing_requests_dirty_(false), | 98 frame_timing_requests_dirty_(false), |
100 visited_(false), | 99 visited_(false), |
101 layer_or_descendant_is_drawn_(false), | 100 layer_or_descendant_is_drawn_(false), |
102 layer_or_descendant_has_input_handler_(false), | 101 layer_or_descendant_has_touch_handler_(false), |
103 sorted_for_recursion_(false) { | 102 sorted_for_recursion_(false) { |
104 DCHECK_GT(layer_id_, 0); | 103 DCHECK_GT(layer_id_, 0); |
105 DCHECK(layer_tree_impl_); | 104 DCHECK(layer_tree_impl_); |
106 layer_tree_impl_->RegisterLayer(this); | 105 layer_tree_impl_->RegisterLayer(this); |
107 | 106 |
108 if (!layer_tree_impl_->settings().use_compositor_animation_timelines) { | 107 if (!layer_tree_impl_->settings().use_compositor_animation_timelines) { |
109 AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar(); | 108 AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar(); |
110 layer_animation_controller_ = | 109 layer_animation_controller_ = |
111 registrar->GetAnimationControllerForId(layer_id_); | 110 registrar->GetAnimationControllerForId(layer_id_); |
112 layer_animation_controller_->AddValueObserver(this); | 111 layer_animation_controller_->AddValueObserver(this); |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 TRACE_EVENT0("cc", | 549 TRACE_EVENT0("cc", |
551 "LayerImpl::tryScroll: Failed NonFastScrollableRegion"); | 550 "LayerImpl::tryScroll: Failed NonFastScrollableRegion"); |
552 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD; | 551 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD; |
553 scroll_status.main_thread_scrolling_reasons = | 552 scroll_status.main_thread_scrolling_reasons = |
554 MainThreadScrollingReason::kNonFastScrollableRegion; | 553 MainThreadScrollingReason::kNonFastScrollableRegion; |
555 return scroll_status; | 554 return scroll_status; |
556 } | 555 } |
557 } | 556 } |
558 | 557 |
559 if ((type == InputHandler::WHEEL || type == InputHandler::ANIMATED_WHEEL) && | 558 if ((type == InputHandler::WHEEL || type == InputHandler::ANIMATED_WHEEL) && |
560 have_wheel_event_handlers()) { | 559 layer_tree_impl_->have_wheel_event_handlers()) { |
561 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed WheelEventHandlers"); | 560 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed WheelEventHandlers"); |
562 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD; | 561 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD; |
563 scroll_status.main_thread_scrolling_reasons = | 562 scroll_status.main_thread_scrolling_reasons = |
564 MainThreadScrollingReason::kEventHandlers; | 563 MainThreadScrollingReason::kEventHandlers; |
565 return scroll_status; | 564 return scroll_status; |
566 } | 565 } |
567 | 566 |
568 if (!scrollable()) { | 567 if (!scrollable()) { |
569 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable"); | 568 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable"); |
570 scroll_status.thread = InputHandler::SCROLL_IGNORED; | 569 scroll_status.thread = InputHandler::SCROLL_IGNORED; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 // TODO(weiliangc): Should be safely removed after impl side is able to | 607 // TODO(weiliangc): Should be safely removed after impl side is able to |
609 // update render surfaces without rebuilding property trees. | 608 // update render surfaces without rebuilding property trees. |
610 if (layer->has_render_surface() != has_render_surface()) | 609 if (layer->has_render_surface() != has_render_surface()) |
611 layer->layer_tree_impl()->set_needs_update_draw_properties(); | 610 layer->layer_tree_impl()->set_needs_update_draw_properties(); |
612 layer->SetHasRenderSurface(!!render_surface()); | 611 layer->SetHasRenderSurface(!!render_surface()); |
613 layer->SetForceRenderSurface(force_render_surface_); | 612 layer->SetForceRenderSurface(force_render_surface_); |
614 layer->SetFilters(filters()); | 613 layer->SetFilters(filters()); |
615 layer->SetBackgroundFilters(background_filters()); | 614 layer->SetBackgroundFilters(background_filters()); |
616 layer->SetMasksToBounds(masks_to_bounds_); | 615 layer->SetMasksToBounds(masks_to_bounds_); |
617 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); | 616 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); |
618 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | |
619 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); | 617 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); |
620 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 618 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); |
621 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 619 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
622 layer->SetContentsOpaque(contents_opaque_); | 620 layer->SetContentsOpaque(contents_opaque_); |
623 layer->SetOpacity(opacity_); | 621 layer->SetOpacity(opacity_); |
624 layer->SetBlendMode(blend_mode_); | 622 layer->SetBlendMode(blend_mode_); |
625 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); | 623 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); |
626 layer->SetPosition(position_); | 624 layer->SetPosition(position_); |
627 layer->SetIsContainerForFixedPositionLayers( | 625 layer->SetIsContainerForFixedPositionLayers( |
628 is_container_for_fixed_position_layers_); | 626 is_container_for_fixed_position_layers_); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 result->Set("DrawTransform", list); | 756 result->Set("DrawTransform", list); |
759 | 757 |
760 result->SetBoolean("DrawsContent", draws_content_); | 758 result->SetBoolean("DrawsContent", draws_content_); |
761 result->SetBoolean("Is3dSorted", Is3dSorted()); | 759 result->SetBoolean("Is3dSorted", Is3dSorted()); |
762 result->SetDouble("OPACITY", opacity()); | 760 result->SetDouble("OPACITY", opacity()); |
763 result->SetBoolean("ContentsOpaque", contents_opaque_); | 761 result->SetBoolean("ContentsOpaque", contents_opaque_); |
764 | 762 |
765 if (scrollable()) | 763 if (scrollable()) |
766 result->SetBoolean("Scrollable", true); | 764 result->SetBoolean("Scrollable", true); |
767 | 765 |
768 if (have_wheel_event_handlers_) | |
769 result->SetBoolean("WheelHandler", have_wheel_event_handlers_); | |
770 if (have_scroll_event_handlers_) | 766 if (have_scroll_event_handlers_) |
771 result->SetBoolean("ScrollHandler", have_scroll_event_handlers_); | 767 result->SetBoolean("ScrollHandler", have_scroll_event_handlers_); |
772 if (!touch_event_handler_region_.IsEmpty()) { | 768 if (!touch_event_handler_region_.IsEmpty()) { |
773 scoped_ptr<base::Value> region = touch_event_handler_region_.AsValue(); | 769 scoped_ptr<base::Value> region = touch_event_handler_region_.AsValue(); |
774 result->Set("TouchRegion", region.release()); | 770 result->Set("TouchRegion", region.release()); |
775 } | 771 } |
776 | 772 |
777 list = new base::ListValue; | 773 list = new base::ListValue; |
778 for (size_t i = 0; i < children_.size(); ++i) | 774 for (size_t i = 0; i < children_.size(); ++i) |
779 list->Append(children_[i]->LayerTreeAsJson()); | 775 list->Append(children_[i]->LayerTreeAsJson()); |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1723 bool clipped; | 1719 bool clipped; |
1724 gfx::QuadF layer_quad = | 1720 gfx::QuadF layer_quad = |
1725 MathUtil::MapQuad(ScreenSpaceTransform(), | 1721 MathUtil::MapQuad(ScreenSpaceTransform(), |
1726 gfx::QuadF(gfx::RectF(gfx::Rect(bounds()))), &clipped); | 1722 gfx::QuadF(gfx::RectF(gfx::Rect(bounds()))), &clipped); |
1727 MathUtil::AddToTracedValue("layer_quad", layer_quad, state); | 1723 MathUtil::AddToTracedValue("layer_quad", layer_quad, state); |
1728 if (!touch_event_handler_region_.IsEmpty()) { | 1724 if (!touch_event_handler_region_.IsEmpty()) { |
1729 state->BeginArray("touch_event_handler_region"); | 1725 state->BeginArray("touch_event_handler_region"); |
1730 touch_event_handler_region_.AsValueInto(state); | 1726 touch_event_handler_region_.AsValueInto(state); |
1731 state->EndArray(); | 1727 state->EndArray(); |
1732 } | 1728 } |
1733 if (have_wheel_event_handlers_) { | |
1734 gfx::Rect wheel_rect(bounds()); | |
1735 Region wheel_region(wheel_rect); | |
1736 state->BeginArray("wheel_event_handler_region"); | |
1737 wheel_region.AsValueInto(state); | |
1738 state->EndArray(); | |
1739 } | |
1740 if (have_scroll_event_handlers_) { | 1729 if (have_scroll_event_handlers_) { |
1741 gfx::Rect scroll_rect(bounds()); | 1730 gfx::Rect scroll_rect(bounds()); |
1742 Region scroll_region(scroll_rect); | 1731 Region scroll_region(scroll_rect); |
1743 state->BeginArray("scroll_event_handler_region"); | 1732 state->BeginArray("scroll_event_handler_region"); |
1744 scroll_region.AsValueInto(state); | 1733 scroll_region.AsValueInto(state); |
1745 state->EndArray(); | 1734 state->EndArray(); |
1746 } | 1735 } |
1747 if (!non_fast_scrollable_region_.IsEmpty()) { | 1736 if (!non_fast_scrollable_region_.IsEmpty()) { |
1748 state->BeginArray("non_fast_scrollable_region"); | 1737 state->BeginArray("non_fast_scrollable_region"); |
1749 non_fast_scrollable_region_.AsValueInto(state); | 1738 non_fast_scrollable_region_.AsValueInto(state); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1929 .layer_transforms_should_scale_layer_contents) { | 1918 .layer_transforms_should_scale_layer_contents) { |
1930 return default_scale; | 1919 return default_scale; |
1931 } | 1920 } |
1932 | 1921 |
1933 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1922 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
1934 DrawTransform(), default_scale); | 1923 DrawTransform(), default_scale); |
1935 return std::max(transform_scales.x(), transform_scales.y()); | 1924 return std::max(transform_scales.x(), transform_scales.y()); |
1936 } | 1925 } |
1937 | 1926 |
1938 } // namespace cc | 1927 } // namespace cc |
OLD | NEW |