| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 transform_tree_index_(-1), | 81 transform_tree_index_(-1), |
| 82 effect_tree_index_(-1), | 82 effect_tree_index_(-1), |
| 83 clip_tree_index_(-1), | 83 clip_tree_index_(-1), |
| 84 draw_depth_(0.f), | 84 draw_depth_(0.f), |
| 85 needs_push_properties_(false), | 85 needs_push_properties_(false), |
| 86 num_dependents_need_push_properties_(0), | 86 num_dependents_need_push_properties_(0), |
| 87 sorting_context_id_(0), | 87 sorting_context_id_(0), |
| 88 current_draw_mode_(DRAW_MODE_NONE), | 88 current_draw_mode_(DRAW_MODE_NONE), |
| 89 element_id_(0), | 89 element_id_(0), |
| 90 mutable_properties_(kMutablePropertyNone), | 90 mutable_properties_(kMutablePropertyNone), |
| 91 force_render_surface_(false), | |
| 92 num_layer_or_descendants_with_copy_request_(0), | 91 num_layer_or_descendants_with_copy_request_(0), |
| 93 frame_timing_requests_dirty_(false), | 92 frame_timing_requests_dirty_(false), |
| 94 visited_(false), | 93 visited_(false), |
| 95 layer_or_descendant_is_drawn_(false), | 94 layer_or_descendant_is_drawn_(false), |
| 96 layer_or_descendant_has_input_handler_(false), | 95 layer_or_descendant_has_input_handler_(false), |
| 97 sorted_for_recursion_(false) { | 96 sorted_for_recursion_(false) { |
| 98 DCHECK_GT(layer_id_, 0); | 97 DCHECK_GT(layer_id_, 0); |
| 99 DCHECK(layer_tree_impl_); | 98 DCHECK(layer_tree_impl_); |
| 100 layer_tree_impl_->RegisterLayer(this); | 99 layer_tree_impl_->RegisterLayer(this); |
| 101 | 100 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 // handle preserving these output requests (and their surface). | 273 // handle preserving these output requests (and their surface). |
| 275 if (!copy_requests_.empty()) { | 274 if (!copy_requests_.empty()) { |
| 276 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); | 275 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); |
| 277 // Destroying these will abort them. | 276 // Destroying these will abort them. |
| 278 copy_requests_.clear(); | 277 copy_requests_.clear(); |
| 279 } | 278 } |
| 280 | 279 |
| 281 if (requests->empty()) | 280 if (requests->empty()) |
| 282 return; | 281 return; |
| 283 | 282 |
| 283 DCHECK(render_surface()); |
| 284 bool was_empty = copy_requests_.empty(); | 284 bool was_empty = copy_requests_.empty(); |
| 285 for (auto& request : *requests) | 285 for (auto& request : *requests) |
| 286 copy_requests_.push_back(std::move(request)); | 286 copy_requests_.push_back(std::move(request)); |
| 287 requests->clear(); | 287 requests->clear(); |
| 288 | 288 |
| 289 if (was_empty && layer_tree_impl()->IsActiveTree()) | 289 if (was_empty && layer_tree_impl()->IsActiveTree()) |
| 290 layer_tree_impl()->AddLayerWithCopyOutputRequest(this); | 290 layer_tree_impl()->AddLayerWithCopyOutputRequest(this); |
| 291 NoteLayerPropertyChangedForSubtree(); | 291 NoteLayerPropertyChangedForSubtree(); |
| 292 } | 292 } |
| 293 | 293 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 } | 567 } |
| 568 | 568 |
| 569 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { | 569 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { |
| 570 layer->SetTransformOrigin(transform_origin_); | 570 layer->SetTransformOrigin(transform_origin_); |
| 571 layer->SetBackgroundColor(background_color_); | 571 layer->SetBackgroundColor(background_color_); |
| 572 layer->SetBounds(bounds_); | 572 layer->SetBounds(bounds_); |
| 573 layer->SetDoubleSided(double_sided_); | 573 layer->SetDoubleSided(double_sided_); |
| 574 layer->SetDrawsContent(DrawsContent()); | 574 layer->SetDrawsContent(DrawsContent()); |
| 575 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); | 575 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); |
| 576 layer->SetHasRenderSurface(!!render_surface()); | 576 layer->SetHasRenderSurface(!!render_surface()); |
| 577 layer->SetForceRenderSurface(force_render_surface_); | |
| 578 layer->SetFilters(filters()); | 577 layer->SetFilters(filters()); |
| 579 layer->SetBackgroundFilters(background_filters()); | 578 layer->SetBackgroundFilters(background_filters()); |
| 580 layer->SetMasksToBounds(masks_to_bounds_); | 579 layer->SetMasksToBounds(masks_to_bounds_); |
| 581 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); | 580 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); |
| 582 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | 581 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); |
| 583 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); | 582 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); |
| 584 layer->SetScrollBlocksOn(scroll_blocks_on_); | 583 layer->SetScrollBlocksOn(scroll_blocks_on_); |
| 585 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 584 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); |
| 586 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 585 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
| 587 layer->SetContentsOpaque(contents_opaque_); | 586 layer->SetContentsOpaque(contents_opaque_); |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 if (!layer_animation_controller_) | 1348 if (!layer_animation_controller_) |
| 1350 return layer_tree_impl_->HasOnlyTranslationTransforms(this); | 1349 return layer_tree_impl_->HasOnlyTranslationTransforms(this); |
| 1351 | 1350 |
| 1352 LayerAnimationController::ObserverType observer_type = | 1351 LayerAnimationController::ObserverType observer_type = |
| 1353 IsActive() ? LayerAnimationController::ObserverType::ACTIVE | 1352 IsActive() ? LayerAnimationController::ObserverType::ACTIVE |
| 1354 : LayerAnimationController::ObserverType::PENDING; | 1353 : LayerAnimationController::ObserverType::PENDING; |
| 1355 return layer_animation_controller_->HasOnlyTranslationTransforms( | 1354 return layer_animation_controller_->HasOnlyTranslationTransforms( |
| 1356 observer_type); | 1355 observer_type); |
| 1357 } | 1356 } |
| 1358 | 1357 |
| 1359 bool LayerImpl::AnimationsPreserveAxisAlignment() const { | |
| 1360 return layer_animation_controller_ | |
| 1361 ? layer_animation_controller_->AnimationsPreserveAxisAlignment() | |
| 1362 : layer_tree_impl_->AnimationsPreserveAxisAlignment(this); | |
| 1363 } | |
| 1364 | |
| 1365 bool LayerImpl::MaximumTargetScale(float* max_scale) const { | 1358 bool LayerImpl::MaximumTargetScale(float* max_scale) const { |
| 1366 if (!layer_animation_controller_) | 1359 if (!layer_animation_controller_) |
| 1367 return layer_tree_impl_->MaximumTargetScale(this, max_scale); | 1360 return layer_tree_impl_->MaximumTargetScale(this, max_scale); |
| 1368 | 1361 |
| 1369 LayerAnimationController::ObserverType observer_type = | 1362 LayerAnimationController::ObserverType observer_type = |
| 1370 IsActive() ? LayerAnimationController::ObserverType::ACTIVE | 1363 IsActive() ? LayerAnimationController::ObserverType::ACTIVE |
| 1371 : LayerAnimationController::ObserverType::PENDING; | 1364 : LayerAnimationController::ObserverType::PENDING; |
| 1372 return layer_animation_controller_->MaximumTargetScale(observer_type, | 1365 return layer_animation_controller_->MaximumTargetScale(observer_type, |
| 1373 max_scale); | 1366 max_scale); |
| 1374 } | 1367 } |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1799 int group) { | 1792 int group) { |
| 1800 if (target_property == Animation::SCROLL_OFFSET) | 1793 if (target_property == Animation::SCROLL_OFFSET) |
| 1801 layer_tree_impl_->InputScrollAnimationFinished(); | 1794 layer_tree_impl_->InputScrollAnimationFinished(); |
| 1802 } | 1795 } |
| 1803 | 1796 |
| 1804 void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) { | 1797 void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) { |
| 1805 if (!!render_surface() == should_have_render_surface) | 1798 if (!!render_surface() == should_have_render_surface) |
| 1806 return; | 1799 return; |
| 1807 | 1800 |
| 1808 SetNeedsPushProperties(); | 1801 SetNeedsPushProperties(); |
| 1802 layer_tree_impl()->set_needs_update_draw_properties(); |
| 1809 if (should_have_render_surface) { | 1803 if (should_have_render_surface) { |
| 1810 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this)); | 1804 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this)); |
| 1811 return; | 1805 return; |
| 1812 } | 1806 } |
| 1813 render_surface_.reset(); | 1807 render_surface_.reset(); |
| 1814 } | 1808 } |
| 1815 | 1809 |
| 1816 gfx::Transform LayerImpl::DrawTransform() const { | 1810 gfx::Transform LayerImpl::DrawTransform() const { |
| 1817 // Only drawn layers have up-to-date draw properties when property trees are | 1811 // Only drawn layers have up-to-date draw properties when property trees are |
| 1818 // enabled. | 1812 // enabled. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1835 // enabled. | 1829 // enabled. |
| 1836 if (layer_tree_impl()->settings().use_property_trees && | 1830 if (layer_tree_impl()->settings().use_property_trees && |
| 1837 !IsDrawnRenderSurfaceLayerListMember()) { | 1831 !IsDrawnRenderSurfaceLayerListMember()) { |
| 1838 return ScreenSpaceTransformFromPropertyTrees( | 1832 return ScreenSpaceTransformFromPropertyTrees( |
| 1839 this, layer_tree_impl()->property_trees()->transform_tree); | 1833 this, layer_tree_impl()->property_trees()->transform_tree); |
| 1840 } | 1834 } |
| 1841 | 1835 |
| 1842 return draw_properties().screen_space_transform; | 1836 return draw_properties().screen_space_transform; |
| 1843 } | 1837 } |
| 1844 | 1838 |
| 1845 void LayerImpl::SetForceRenderSurface(bool force_render_surface) { | |
| 1846 if (force_render_surface == force_render_surface_) | |
| 1847 return; | |
| 1848 | |
| 1849 force_render_surface_ = force_render_surface; | |
| 1850 NoteLayerPropertyChanged(); | |
| 1851 } | |
| 1852 | |
| 1853 Region LayerImpl::GetInvalidationRegion() { | 1839 Region LayerImpl::GetInvalidationRegion() { |
| 1854 return Region(update_rect_); | 1840 return Region(update_rect_); |
| 1855 } | 1841 } |
| 1856 | 1842 |
| 1857 gfx::Rect LayerImpl::GetEnclosingRectInTargetSpace() const { | 1843 gfx::Rect LayerImpl::GetEnclosingRectInTargetSpace() const { |
| 1858 return MathUtil::MapEnclosingClippedRect(DrawTransform(), | 1844 return MathUtil::MapEnclosingClippedRect(DrawTransform(), |
| 1859 gfx::Rect(bounds())); | 1845 gfx::Rect(bounds())); |
| 1860 } | 1846 } |
| 1861 | 1847 |
| 1862 gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const { | 1848 gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1879 .layer_transforms_should_scale_layer_contents) { | 1865 .layer_transforms_should_scale_layer_contents) { |
| 1880 return default_scale; | 1866 return default_scale; |
| 1881 } | 1867 } |
| 1882 | 1868 |
| 1883 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1869 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
| 1884 DrawTransform(), default_scale); | 1870 DrawTransform(), default_scale); |
| 1885 return std::max(transform_scales.x(), transform_scales.y()); | 1871 return std::max(transform_scales.x(), transform_scales.y()); |
| 1886 } | 1872 } |
| 1887 | 1873 |
| 1888 } // namespace cc | 1874 } // namespace cc |
| OLD | NEW |