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/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/numerics/safe_conversions.h" | 8 #include "base/numerics/safe_conversions.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 draw_blend_mode_(SkXfermode::kSrcOver_Mode), | 78 draw_blend_mode_(SkXfermode::kSrcOver_Mode), |
79 num_descendants_that_draw_content_(0), | 79 num_descendants_that_draw_content_(0), |
80 transform_tree_index_(-1), | 80 transform_tree_index_(-1), |
81 effect_tree_index_(-1), | 81 effect_tree_index_(-1), |
82 clip_tree_index_(-1), | 82 clip_tree_index_(-1), |
83 draw_depth_(0.f), | 83 draw_depth_(0.f), |
84 needs_push_properties_(false), | 84 needs_push_properties_(false), |
85 num_dependents_need_push_properties_(0), | 85 num_dependents_need_push_properties_(0), |
86 sorting_context_id_(0), | 86 sorting_context_id_(0), |
87 current_draw_mode_(DRAW_MODE_NONE), | 87 current_draw_mode_(DRAW_MODE_NONE), |
88 force_render_surface_(false), | |
88 num_layer_or_descendants_with_copy_request_(0), | 89 num_layer_or_descendants_with_copy_request_(0), |
89 frame_timing_requests_dirty_(false), | 90 frame_timing_requests_dirty_(false), |
90 visited_(false), | 91 visited_(false), |
91 layer_or_descendant_is_drawn_(false), | 92 layer_or_descendant_is_drawn_(false), |
92 layer_or_descendant_has_input_handler_(false), | 93 layer_or_descendant_has_input_handler_(false), |
93 sorted_for_recursion_(false) { | 94 sorted_for_recursion_(false) { |
94 DCHECK_GT(layer_id_, 0); | 95 DCHECK_GT(layer_id_, 0); |
95 DCHECK(layer_tree_impl_); | 96 DCHECK(layer_tree_impl_); |
96 layer_tree_impl_->RegisterLayer(this); | 97 layer_tree_impl_->RegisterLayer(this); |
97 | 98 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 // handle preserving these output requests (and their surface). | 271 // handle preserving these output requests (and their surface). |
271 if (!copy_requests_.empty()) { | 272 if (!copy_requests_.empty()) { |
272 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); | 273 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); |
273 // Destroying these will abort them. | 274 // Destroying these will abort them. |
274 copy_requests_.clear(); | 275 copy_requests_.clear(); |
275 } | 276 } |
276 | 277 |
277 if (requests->empty()) | 278 if (requests->empty()) |
278 return; | 279 return; |
279 | 280 |
280 DCHECK(render_surface()); | |
281 bool was_empty = copy_requests_.empty(); | 281 bool was_empty = copy_requests_.empty(); |
282 for (auto& request : *requests) | 282 for (auto& request : *requests) |
283 copy_requests_.push_back(std::move(request)); | 283 copy_requests_.push_back(std::move(request)); |
284 requests->clear(); | 284 requests->clear(); |
285 | 285 |
286 if (was_empty && layer_tree_impl()->IsActiveTree()) | 286 if (was_empty && layer_tree_impl()->IsActiveTree()) |
287 layer_tree_impl()->AddLayerWithCopyOutputRequest(this); | 287 layer_tree_impl()->AddLayerWithCopyOutputRequest(this); |
288 NoteLayerPropertyChangedForSubtree(); | 288 NoteLayerPropertyChangedForSubtree(); |
289 } | 289 } |
290 | 290 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
564 } | 564 } |
565 | 565 |
566 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { | 566 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { |
567 layer->SetTransformOrigin(transform_origin_); | 567 layer->SetTransformOrigin(transform_origin_); |
568 layer->SetBackgroundColor(background_color_); | 568 layer->SetBackgroundColor(background_color_); |
569 layer->SetBounds(bounds_); | 569 layer->SetBounds(bounds_); |
570 layer->SetDoubleSided(double_sided_); | 570 layer->SetDoubleSided(double_sided_); |
571 layer->SetDrawsContent(DrawsContent()); | 571 layer->SetDrawsContent(DrawsContent()); |
572 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); | 572 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); |
573 layer->SetHasRenderSurface(!!render_surface()); | 573 layer->SetHasRenderSurface(!!render_surface()); |
574 layer->SetForceRenderSurface(force_render_surface_); | |
574 layer->SetFilters(filters()); | 575 layer->SetFilters(filters()); |
575 layer->SetBackgroundFilters(background_filters()); | 576 layer->SetBackgroundFilters(background_filters()); |
576 layer->SetMasksToBounds(masks_to_bounds_); | 577 layer->SetMasksToBounds(masks_to_bounds_); |
577 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); | 578 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); |
578 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | 579 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); |
579 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); | 580 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); |
580 layer->SetScrollBlocksOn(scroll_blocks_on_); | 581 layer->SetScrollBlocksOn(scroll_blocks_on_); |
581 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 582 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); |
582 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 583 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
583 layer->SetContentsOpaque(contents_opaque_); | 584 layer->SetContentsOpaque(contents_opaque_); |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1321 if (!layer_animation_controller_) | 1322 if (!layer_animation_controller_) |
1322 return layer_tree_impl_->HasOnlyTranslationTransforms(this); | 1323 return layer_tree_impl_->HasOnlyTranslationTransforms(this); |
1323 | 1324 |
1324 LayerAnimationController::ObserverType observer_type = | 1325 LayerAnimationController::ObserverType observer_type = |
1325 IsActive() ? LayerAnimationController::ObserverType::ACTIVE | 1326 IsActive() ? LayerAnimationController::ObserverType::ACTIVE |
1326 : LayerAnimationController::ObserverType::PENDING; | 1327 : LayerAnimationController::ObserverType::PENDING; |
1327 return layer_animation_controller_->HasOnlyTranslationTransforms( | 1328 return layer_animation_controller_->HasOnlyTranslationTransforms( |
1328 observer_type); | 1329 observer_type); |
1329 } | 1330 } |
1330 | 1331 |
1332 bool LayerImpl::AnimationsPreserveAxisAlignment() const { | |
1333 return layer_animation_controller_ | |
1334 ? layer_animation_controller_->AnimationsPreserveAxisAlignment() | |
1335 : layer_tree_impl_->AnimationsPreserveAxisAlignment(this); | |
1336 } | |
1337 | |
1331 bool LayerImpl::MaximumTargetScale(float* max_scale) const { | 1338 bool LayerImpl::MaximumTargetScale(float* max_scale) const { |
1332 if (!layer_animation_controller_) | 1339 if (!layer_animation_controller_) |
1333 return layer_tree_impl_->MaximumTargetScale(this, max_scale); | 1340 return layer_tree_impl_->MaximumTargetScale(this, max_scale); |
1334 | 1341 |
1335 LayerAnimationController::ObserverType observer_type = | 1342 LayerAnimationController::ObserverType observer_type = |
1336 IsActive() ? LayerAnimationController::ObserverType::ACTIVE | 1343 IsActive() ? LayerAnimationController::ObserverType::ACTIVE |
1337 : LayerAnimationController::ObserverType::PENDING; | 1344 : LayerAnimationController::ObserverType::PENDING; |
1338 return layer_animation_controller_->MaximumTargetScale(observer_type, | 1345 return layer_animation_controller_->MaximumTargetScale(observer_type, |
1339 max_scale); | 1346 max_scale); |
1340 } | 1347 } |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1760 int group) { | 1767 int group) { |
1761 if (target_property == Animation::SCROLL_OFFSET) | 1768 if (target_property == Animation::SCROLL_OFFSET) |
1762 layer_tree_impl_->InputScrollAnimationFinished(); | 1769 layer_tree_impl_->InputScrollAnimationFinished(); |
1763 } | 1770 } |
1764 | 1771 |
1765 void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) { | 1772 void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) { |
1766 if (!!render_surface() == should_have_render_surface) | 1773 if (!!render_surface() == should_have_render_surface) |
1767 return; | 1774 return; |
1768 | 1775 |
1769 SetNeedsPushProperties(); | 1776 SetNeedsPushProperties(); |
1770 layer_tree_impl()->set_needs_update_draw_properties(); | |
1771 if (should_have_render_surface) { | 1777 if (should_have_render_surface) { |
1772 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this)); | 1778 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this)); |
1773 return; | 1779 return; |
1774 } | 1780 } |
1775 render_surface_.reset(); | 1781 render_surface_.reset(); |
1776 } | 1782 } |
1777 | 1783 |
1778 gfx::Transform LayerImpl::DrawTransform() const { | 1784 gfx::Transform LayerImpl::DrawTransform() const { |
1779 // Only drawn layers have up-to-date draw properties when property trees are | 1785 // Only drawn layers have up-to-date draw properties when property trees are |
1780 // enabled. | 1786 // enabled. |
(...skipping 16 matching lines...) Expand all Loading... | |
1797 // enabled. | 1803 // enabled. |
1798 if (layer_tree_impl()->settings().use_property_trees && | 1804 if (layer_tree_impl()->settings().use_property_trees && |
1799 !IsDrawnRenderSurfaceLayerListMember()) { | 1805 !IsDrawnRenderSurfaceLayerListMember()) { |
1800 return ScreenSpaceTransformFromPropertyTrees( | 1806 return ScreenSpaceTransformFromPropertyTrees( |
1801 this, layer_tree_impl()->property_trees()->transform_tree); | 1807 this, layer_tree_impl()->property_trees()->transform_tree); |
1802 } | 1808 } |
1803 | 1809 |
1804 return draw_properties().screen_space_transform; | 1810 return draw_properties().screen_space_transform; |
1805 } | 1811 } |
1806 | 1812 |
1813 void LayerImpl::SetForceRenderSurface(bool force_render_surface) { | |
enne (OOO)
2015/12/02 21:59:51
I guess you need this to force the creation of a n
| |
1814 if (force_render_surface == force_render_surface_) | |
1815 return; | |
1816 | |
1817 force_render_surface_ = force_render_surface; | |
1818 NoteLayerPropertyChanged(); | |
1819 } | |
1820 | |
1807 Region LayerImpl::GetInvalidationRegion() { | 1821 Region LayerImpl::GetInvalidationRegion() { |
1808 return Region(update_rect_); | 1822 return Region(update_rect_); |
1809 } | 1823 } |
1810 | 1824 |
1811 gfx::Rect LayerImpl::GetEnclosingRectInTargetSpace() const { | 1825 gfx::Rect LayerImpl::GetEnclosingRectInTargetSpace() const { |
1812 return MathUtil::MapEnclosingClippedRect(DrawTransform(), | 1826 return MathUtil::MapEnclosingClippedRect(DrawTransform(), |
1813 gfx::Rect(bounds())); | 1827 gfx::Rect(bounds())); |
1814 } | 1828 } |
1815 | 1829 |
1816 gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const { | 1830 gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const { |
(...skipping 16 matching lines...) Expand all Loading... | |
1833 .layer_transforms_should_scale_layer_contents) { | 1847 .layer_transforms_should_scale_layer_contents) { |
1834 return default_scale; | 1848 return default_scale; |
1835 } | 1849 } |
1836 | 1850 |
1837 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1851 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
1838 DrawTransform(), default_scale); | 1852 DrawTransform(), default_scale); |
1839 return std::max(transform_scales.x(), transform_scales.y()); | 1853 return std::max(transform_scales.x(), transform_scales.y()); |
1840 } | 1854 } |
1841 | 1855 |
1842 } // namespace cc | 1856 } // namespace cc |
OLD | NEW |