| 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 <algorithm> | 10 #include <algorithm> |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 replica_layer_id_(-1), | 52 replica_layer_id_(-1), |
| 53 replica_layer_(nullptr), | 53 replica_layer_(nullptr), |
| 54 layer_id_(id), | 54 layer_id_(id), |
| 55 layer_tree_impl_(tree_impl), | 55 layer_tree_impl_(tree_impl), |
| 56 test_properties_(nullptr), | 56 test_properties_(nullptr), |
| 57 scroll_clip_layer_id_(Layer::INVALID_ID), | 57 scroll_clip_layer_id_(Layer::INVALID_ID), |
| 58 main_thread_scrolling_reasons_( | 58 main_thread_scrolling_reasons_( |
| 59 MainThreadScrollingReason::kNotScrollingOnMain), | 59 MainThreadScrollingReason::kNotScrollingOnMain), |
| 60 user_scrollable_horizontal_(true), | 60 user_scrollable_horizontal_(true), |
| 61 user_scrollable_vertical_(true), | 61 user_scrollable_vertical_(true), |
| 62 double_sided_(true), | |
| 63 should_flatten_transform_(true), | 62 should_flatten_transform_(true), |
| 64 should_flatten_transform_from_property_tree_(false), | 63 should_flatten_transform_from_property_tree_(false), |
| 65 layer_property_changed_(false), | 64 layer_property_changed_(false), |
| 66 masks_to_bounds_(false), | 65 masks_to_bounds_(false), |
| 67 contents_opaque_(false), | 66 contents_opaque_(false), |
| 68 is_root_for_isolated_group_(false), | 67 is_root_for_isolated_group_(false), |
| 69 use_parent_backface_visibility_(false), | 68 use_parent_backface_visibility_(false), |
| 70 use_local_transform_for_backface_visibility_(false), | 69 use_local_transform_for_backface_visibility_(false), |
| 71 should_check_backface_visibility_(false), | 70 should_check_backface_visibility_(false), |
| 72 draws_content_(false), | 71 draws_content_(false), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 83 num_descendants_that_draw_content_(0), | 82 num_descendants_that_draw_content_(0), |
| 84 transform_tree_index_(-1), | 83 transform_tree_index_(-1), |
| 85 effect_tree_index_(-1), | 84 effect_tree_index_(-1), |
| 86 clip_tree_index_(-1), | 85 clip_tree_index_(-1), |
| 87 scroll_tree_index_(-1), | 86 scroll_tree_index_(-1), |
| 88 sorting_context_id_(0), | 87 sorting_context_id_(0), |
| 89 current_draw_mode_(DRAW_MODE_NONE), | 88 current_draw_mode_(DRAW_MODE_NONE), |
| 90 element_id_(0), | 89 element_id_(0), |
| 91 mutable_properties_(MutableProperty::kNone), | 90 mutable_properties_(MutableProperty::kNone), |
| 92 debug_info_(nullptr), | 91 debug_info_(nullptr), |
| 93 force_render_surface_(false), | |
| 94 scrolls_drawn_descendant_(false), | 92 scrolls_drawn_descendant_(false), |
| 95 layer_or_descendant_has_touch_handler_(false) { | 93 layer_or_descendant_has_touch_handler_(false) { |
| 96 DCHECK_GT(layer_id_, 0); | 94 DCHECK_GT(layer_id_, 0); |
| 97 | 95 |
| 98 DCHECK(layer_tree_impl_); | 96 DCHECK(layer_tree_impl_); |
| 99 layer_tree_impl_->RegisterLayer(this); | 97 layer_tree_impl_->RegisterLayer(this); |
| 100 layer_tree_impl_->AddToElementMap(this); | 98 layer_tree_impl_->AddToElementMap(this); |
| 101 | 99 |
| 102 SetNeedsPushProperties(); | 100 SetNeedsPushProperties(); |
| 103 } | 101 } |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 } | 479 } |
| 482 } | 480 } |
| 483 | 481 |
| 484 main_thread_scrolling_reasons_ = main_thread_scrolling_reasons; | 482 main_thread_scrolling_reasons_ = main_thread_scrolling_reasons; |
| 485 } | 483 } |
| 486 | 484 |
| 487 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { | 485 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { |
| 488 layer->SetBackgroundColor(background_color_); | 486 layer->SetBackgroundColor(background_color_); |
| 489 layer->SetSafeOpaqueBackgroundColor(safe_opaque_background_color_); | 487 layer->SetSafeOpaqueBackgroundColor(safe_opaque_background_color_); |
| 490 layer->SetBounds(bounds_); | 488 layer->SetBounds(bounds_); |
| 491 layer->SetDoubleSided(double_sided_); | |
| 492 layer->SetDrawsContent(DrawsContent()); | 489 layer->SetDrawsContent(DrawsContent()); |
| 493 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); | 490 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); |
| 494 // If whether layer has render surface changes, we need to update draw | 491 // If whether layer has render surface changes, we need to update draw |
| 495 // properties. | 492 // properties. |
| 496 // TODO(weiliangc): Should be safely removed after impl side is able to | 493 // TODO(weiliangc): Should be safely removed after impl side is able to |
| 497 // update render surfaces without rebuilding property trees. | 494 // update render surfaces without rebuilding property trees. |
| 498 if (layer->has_render_surface() != has_render_surface()) | 495 if (layer->has_render_surface() != has_render_surface()) |
| 499 layer->layer_tree_impl()->set_needs_update_draw_properties(); | 496 layer->layer_tree_impl()->set_needs_update_draw_properties(); |
| 500 layer->SetHasRenderSurface(!!render_surface()); | 497 layer->SetHasRenderSurface(!!render_surface()); |
| 501 layer->SetForceRenderSurface(force_render_surface_); | |
| 502 layer->SetFilters(filters()); | 498 layer->SetFilters(filters()); |
| 503 layer->SetBackgroundFilters(background_filters()); | 499 layer->SetBackgroundFilters(background_filters()); |
| 504 layer->SetMasksToBounds(masks_to_bounds_); | 500 layer->SetMasksToBounds(masks_to_bounds_); |
| 505 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); | 501 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); |
| 506 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 502 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); |
| 507 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 503 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
| 508 layer->SetContentsOpaque(contents_opaque_); | 504 layer->SetContentsOpaque(contents_opaque_); |
| 509 layer->SetOpacity(opacity_); | 505 layer->SetOpacity(opacity_); |
| 510 layer->SetBlendMode(blend_mode_); | 506 layer->SetBlendMode(blend_mode_); |
| 511 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); | 507 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 TransformNode* node = transform_tree.Node(transform_tree_index_); | 1301 TransformNode* node = transform_tree.Node(transform_tree_index_); |
| 1306 gfx::ScrollOffset current_offset = CurrentScrollOffset(); | 1302 gfx::ScrollOffset current_offset = CurrentScrollOffset(); |
| 1307 if (node->data.scroll_offset != current_offset) { | 1303 if (node->data.scroll_offset != current_offset) { |
| 1308 node->data.scroll_offset = current_offset; | 1304 node->data.scroll_offset = current_offset; |
| 1309 node->data.needs_local_transform_update = true; | 1305 node->data.needs_local_transform_update = true; |
| 1310 transform_tree.set_needs_update(true); | 1306 transform_tree.set_needs_update(true); |
| 1311 } | 1307 } |
| 1312 } | 1308 } |
| 1313 } | 1309 } |
| 1314 | 1310 |
| 1315 void LayerImpl::SetDoubleSided(bool double_sided) { | |
| 1316 if (double_sided_ == double_sided) | |
| 1317 return; | |
| 1318 | |
| 1319 double_sided_ = double_sided; | |
| 1320 } | |
| 1321 | |
| 1322 SimpleEnclosedRegion LayerImpl::VisibleOpaqueRegion() const { | 1311 SimpleEnclosedRegion LayerImpl::VisibleOpaqueRegion() const { |
| 1323 if (contents_opaque()) | 1312 if (contents_opaque()) |
| 1324 return SimpleEnclosedRegion(visible_layer_rect()); | 1313 return SimpleEnclosedRegion(visible_layer_rect()); |
| 1325 return SimpleEnclosedRegion(); | 1314 return SimpleEnclosedRegion(); |
| 1326 } | 1315 } |
| 1327 | 1316 |
| 1328 void LayerImpl::DidBeginTracing() {} | 1317 void LayerImpl::DidBeginTracing() {} |
| 1329 | 1318 |
| 1330 void LayerImpl::ReleaseResources() {} | 1319 void LayerImpl::ReleaseResources() {} |
| 1331 | 1320 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 gfx::Transform LayerImpl::ScreenSpaceTransform() const { | 1496 gfx::Transform LayerImpl::ScreenSpaceTransform() const { |
| 1508 // Only drawn layers have up-to-date draw properties. | 1497 // Only drawn layers have up-to-date draw properties. |
| 1509 if (!IsDrawnRenderSurfaceLayerListMember()) { | 1498 if (!IsDrawnRenderSurfaceLayerListMember()) { |
| 1510 return draw_property_utils::ScreenSpaceTransform( | 1499 return draw_property_utils::ScreenSpaceTransform( |
| 1511 this, layer_tree_impl()->property_trees()->transform_tree); | 1500 this, layer_tree_impl()->property_trees()->transform_tree); |
| 1512 } | 1501 } |
| 1513 | 1502 |
| 1514 return draw_properties().screen_space_transform; | 1503 return draw_properties().screen_space_transform; |
| 1515 } | 1504 } |
| 1516 | 1505 |
| 1517 void LayerImpl::SetForceRenderSurface(bool force_render_surface) { | |
| 1518 if (force_render_surface == force_render_surface_) | |
| 1519 return; | |
| 1520 | |
| 1521 force_render_surface_ = force_render_surface; | |
| 1522 NoteLayerPropertyChanged(); | |
| 1523 } | |
| 1524 | |
| 1525 Region LayerImpl::GetInvalidationRegionForDebugging() { | 1506 Region LayerImpl::GetInvalidationRegionForDebugging() { |
| 1526 return Region(update_rect_); | 1507 return Region(update_rect_); |
| 1527 } | 1508 } |
| 1528 | 1509 |
| 1529 gfx::Rect LayerImpl::GetEnclosingRectInTargetSpace() const { | 1510 gfx::Rect LayerImpl::GetEnclosingRectInTargetSpace() const { |
| 1530 return MathUtil::MapEnclosingClippedRect(DrawTransform(), | 1511 return MathUtil::MapEnclosingClippedRect(DrawTransform(), |
| 1531 gfx::Rect(bounds())); | 1512 gfx::Rect(bounds())); |
| 1532 } | 1513 } |
| 1533 | 1514 |
| 1534 gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const { | 1515 gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1595 .layer_transforms_should_scale_layer_contents) { | 1576 .layer_transforms_should_scale_layer_contents) { |
| 1596 return default_scale; | 1577 return default_scale; |
| 1597 } | 1578 } |
| 1598 | 1579 |
| 1599 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1580 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
| 1600 DrawTransform(), default_scale); | 1581 DrawTransform(), default_scale); |
| 1601 return std::max(transform_scales.x(), transform_scales.y()); | 1582 return std::max(transform_scales.x(), transform_scales.y()); |
| 1602 } | 1583 } |
| 1603 | 1584 |
| 1604 } // namespace cc | 1585 } // namespace cc |
| OLD | NEW |