summaryrefslogtreecommitdiff
path: root/chromium/cc/layers/layer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/cc/layers/layer.cc')
-rw-r--r--chromium/cc/layers/layer.cc164
1 files changed, 75 insertions, 89 deletions
diff --git a/chromium/cc/layers/layer.cc b/chromium/cc/layers/layer.cc
index c5fb253d85e..823a5df49c7 100644
--- a/chromium/cc/layers/layer.cc
+++ b/chromium/cc/layers/layer.cc
@@ -19,7 +19,7 @@
#include "cc/input/main_thread_scrolling_reason.h"
#include "cc/layers/layer_client.h"
#include "cc/layers/layer_impl.h"
-#include "cc/layers/scrollbar_layer_interface.h"
+#include "cc/layers/picture_layer.h"
#include "cc/tiles/frame_viewer_instrumentation.h"
#include "cc/trees/draw_property_utils.h"
#include "cc/trees/effect_node.h"
@@ -85,7 +85,7 @@ Layer::Layer()
clip_tree_index_(ClipTree::kInvalidNodeId),
scroll_tree_index_(ScrollTree::kInvalidNodeId),
property_tree_sequence_number_(-1),
- should_flatten_transform_from_property_tree_(false),
+ should_flatten_screen_space_transform_from_property_tree_(false),
draws_content_(false),
should_check_backface_visibility_(false),
cache_render_surface_(false),
@@ -95,8 +95,7 @@ Layer::Layer()
needs_show_scrollbars_(false),
has_transform_node_(false),
subtree_has_copy_request_(false),
- safe_opaque_background_color_(0),
- num_unclipped_descendants_(0) {}
+ safe_opaque_background_color_(0) {}
Layer::~Layer() {
// Our parent should be holding a reference to us so there should be no
@@ -150,7 +149,7 @@ void Layer::SetLayerTreeHost(LayerTreeHost* host) {
inputs_.mask_layer->SetLayerTreeHost(host);
if (host && !host->IsUsingLayerLists() &&
- GetMutatorHost()->IsElementAnimating(element_id())) {
+ host->mutator_host()->IsElementAnimating(element_id())) {
host->SetNeedsCommit();
}
}
@@ -186,11 +185,6 @@ void Layer::SetNeedsPushProperties() {
layer_tree_host_->AddLayerShouldPushProperties(this);
}
-void Layer::ResetNeedsPushPropertiesForTesting() {
- if (layer_tree_host_)
- layer_tree_host_->RemoveLayerShouldPushProperties(this);
-}
-
bool Layer::IsPropertyChangeAllowed() const {
if (!layer_tree_host_)
return true;
@@ -361,16 +355,6 @@ void Layer::RemoveAllChildren() {
}
}
-void Layer::SetChildren(const LayerList& children) {
- DCHECK(IsPropertyChangeAllowed());
- if (children == inputs_.children)
- return;
-
- RemoveAllChildren();
- for (size_t i = 0; i < children.size(); ++i)
- AddChild(children[i]);
-}
-
bool Layer::HasAncestor(const Layer* ancestor) const {
for (const Layer* layer = parent(); layer; layer = layer->parent()) {
if (layer == ancestor)
@@ -423,9 +407,10 @@ void Layer::SetBackgroundColor(SkColor background_color) {
void Layer::SetSafeOpaqueBackgroundColor(SkColor background_color) {
DCHECK(IsPropertyChangeAllowed());
- if (safe_opaque_background_color_ == background_color)
+ SkColor opaque_color = SkColorSetA(background_color, 255);
+ if (safe_opaque_background_color_ == opaque_color)
return;
- safe_opaque_background_color_ = background_color;
+ safe_opaque_background_color_ = opaque_color;
SetNeedsPushProperties();
}
@@ -448,7 +433,7 @@ void Layer::SetMasksToBounds(bool masks_to_bounds) {
SetSubtreePropertyChanged();
}
-void Layer::SetMaskLayer(Layer* mask_layer) {
+void Layer::SetMaskLayer(PictureLayer* mask_layer) {
DCHECK(IsPropertyChangeAllowed());
if (inputs_.mask_layer.get() == mask_layer)
return;
@@ -644,8 +629,10 @@ void Layer::SetPosition(const gfx::PointF& position) {
return;
SetSubtreePropertyChanged();
- TransformNode* transform_node = GetTransformNode();
- if (transform_node) {
+ if (has_transform_node_) {
+ TransformNode* transform_node =
+ layer_tree_host_->property_trees()->transform_tree.Node(
+ transform_tree_index_);
transform_node->update_post_local_transform(position, transform_origin());
transform_node->needs_local_transform_update = true;
transform_node->transform_changed = true;
@@ -684,23 +671,21 @@ void Layer::SetTransform(const gfx::Transform& transform) {
SetSubtreePropertyChanged();
if (layer_tree_host_) {
if (has_transform_node_) {
- PropertyTrees* property_trees = layer_tree_host_->property_trees();
- if (TransformNode* transform_node =
- property_trees->transform_tree.Node(transform_tree_index())) {
- // We need to trigger a rebuild if we could have affected 2d axis
- // alignment. We'll check to see if transform and inputs_.transform are
- // axis align with respect to one another.
- DCHECK_EQ(transform_tree_index(), transform_node->id);
- bool preserves_2d_axis_alignment =
- Are2dAxisAligned(inputs_.transform, transform);
- transform_node->local = transform;
- transform_node->needs_local_transform_update = true;
- transform_node->transform_changed = true;
- layer_tree_host_->property_trees()->transform_tree.set_needs_update(
- true);
- if (!preserves_2d_axis_alignment)
- SetPropertyTreesNeedRebuild();
- }
+ TransformNode* transform_node =
+ layer_tree_host_->property_trees()->transform_tree.Node(
+ transform_tree_index_);
+ // We need to trigger a rebuild if we could have affected 2d axis
+ // alignment. We'll check to see if transform and inputs_.transform are
+ // axis align with respect to one another.
+ DCHECK_EQ(transform_tree_index(), transform_node->id);
+ bool preserves_2d_axis_alignment =
+ Are2dAxisAligned(inputs_.transform, transform);
+ transform_node->local = transform;
+ transform_node->needs_local_transform_update = true;
+ transform_node->transform_changed = true;
+ layer_tree_host_->property_trees()->transform_tree.set_needs_update(true);
+ if (!preserves_2d_axis_alignment)
+ SetPropertyTreesNeedRebuild();
} else {
SetPropertyTreesNeedRebuild();
}
@@ -720,8 +705,10 @@ void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) {
return;
SetSubtreePropertyChanged();
- TransformNode* transform_node = GetTransformNode();
- if (transform_node) {
+ if (has_transform_node_) {
+ TransformNode* transform_node =
+ layer_tree_host_->property_trees()->transform_tree.Node(
+ transform_tree_index_);
DCHECK_EQ(transform_tree_index(), transform_node->id);
transform_node->update_pre_local_transform(transform_origin);
transform_node->update_post_local_transform(position(), transform_origin);
@@ -735,10 +722,6 @@ void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) {
SetNeedsCommit();
}
-bool Layer::ScrollOffsetAnimationWasInterrupted() const {
- return GetMutatorHost()->ScrollOffsetAnimationWasInterrupted(element_id());
-}
-
void Layer::SetScrollParent(Layer* parent) {
DCHECK(IsPropertyChangeAllowed());
if (inputs_.scroll_parent == parent)
@@ -1039,6 +1022,13 @@ int Layer::scroll_tree_index() const {
return scroll_tree_index_;
}
+void Layer::SetOffsetToTransformParent(gfx::Vector2dF offset) {
+ if (offset_to_transform_parent_ == offset)
+ return;
+ offset_to_transform_parent_ = offset;
+ SetNeedsPushProperties();
+}
+
void Layer::InvalidatePropertyTreesIndices() {
SetTransformTreeIndex(TransformTree::kInvalidNodeId);
SetClipTreeIndex(ClipTree::kInvalidNodeId);
@@ -1168,8 +1158,8 @@ void Layer::SetLayerClient(base::WeakPtr<LayerClient> client) {
inputs_.debug_info = nullptr;
}
-bool Layer::IsSnapped() {
- return scrollable();
+bool Layer::IsSnappedToPixelGridInTarget() {
+ return false;
}
void Layer::PushPropertiesTo(LayerImpl* layer) {
@@ -1189,7 +1179,7 @@ void Layer::PushPropertiesTo(LayerImpl* layer) {
layer->SetEffectTreeIndex(effect_tree_index());
layer->SetClipTreeIndex(clip_tree_index());
layer->SetScrollTreeIndex(scroll_tree_index());
- layer->set_offset_to_transform_parent(offset_to_transform_parent_);
+ layer->SetOffsetToTransformParent(offset_to_transform_parent_);
layer->SetDrawsContent(DrawsContent());
layer->SetHitTestableWithoutDrawsContent(
hit_testable_without_draws_content());
@@ -1203,10 +1193,22 @@ void Layer::PushPropertiesTo(LayerImpl* layer) {
inputs_.main_thread_scrolling_reasons);
layer->SetNonFastScrollableRegion(inputs_.non_fast_scrollable_region);
layer->SetTouchActionRegion(inputs_.touch_action_region);
+ // TODO(sunxd): Pass the correct region for wheel event handlers, see
+ // https://crbug.com/841364.
+ if (layer_tree_host()->event_listener_properties(
+ EventListenerClass::kMouseWheel) ==
+ EventListenerProperties::kBlocking ||
+ layer_tree_host()->event_listener_properties(
+ EventListenerClass::kMouseWheel) ==
+ EventListenerProperties::kBlockingAndPassive) {
+ layer->SetWheelEventHandlerRegion(Region(gfx::Rect(bounds())));
+ } else {
+ layer->SetWheelEventHandlerRegion(Region());
+ }
layer->SetContentsOpaque(inputs_.contents_opaque);
layer->SetPosition(inputs_.position);
- layer->set_should_flatten_transform_from_property_tree(
- should_flatten_transform_from_property_tree_);
+ layer->SetShouldFlattenScreenSpaceTransformFromPropertyTree(
+ should_flatten_screen_space_transform_from_property_tree_);
layer->SetUseParentBackfaceVisibility(inputs_.use_parent_backface_visibility);
layer->SetShouldCheckBackfaceVisibility(should_check_backface_visibility_);
@@ -1221,10 +1223,11 @@ void Layer::PushPropertiesTo(LayerImpl* layer) {
// the pending tree will clobber any impl-side scrolling occuring on the
// active tree. To do so, avoid scrolling the pending tree along with it
// instead of trying to undo that scrolling later.
- if (ScrollOffsetAnimationWasInterrupted())
- layer->layer_tree_impl()
- ->property_trees()
- ->scroll_tree.SetScrollOffsetClobberActiveValue(layer->element_id());
+ if (layer_tree_host_->mutator_host()->ScrollOffsetAnimationWasInterrupted(
+ element_id())) {
+ PropertyTrees* trees = layer->layer_tree_impl()->property_trees();
+ trees->scroll_tree.SetScrollOffsetClobberActiveValue(layer->element_id());
+ }
if (needs_show_scrollbars_)
layer->set_needs_show_scrollbars(true);
@@ -1239,8 +1242,6 @@ void Layer::PushPropertiesTo(LayerImpl* layer) {
layer->SetHasWillChangeTransformHint(has_will_change_transform_hint());
layer->SetNeedsPushProperties();
- layer->SetTrilinearFiltering(trilinear_filtering());
-
// Reset any state that should be cleared for the next update.
needs_show_scrollbars_ = false;
subtree_property_changed_ = false;
@@ -1326,6 +1327,15 @@ void Layer::SetSubtreePropertyChanged() {
SetNeedsPushProperties();
}
+void Layer::SetShouldFlattenScreenSpaceTransformFromPropertyTree(
+ bool should_flatten) {
+ if (should_flatten_screen_space_transform_from_property_tree_ ==
+ should_flatten)
+ return;
+ should_flatten_screen_space_transform_from_property_tree_ = should_flatten;
+ SetNeedsPushProperties();
+}
+
void Layer::SetMayContainVideo(bool yes) {
if (may_contain_video_ == yes)
return;
@@ -1350,23 +1360,10 @@ void Layer::OnOpacityAnimated(float opacity) {
inputs_.opacity = opacity;
}
-TransformNode* Layer::GetTransformNode() const {
- return has_transform_node_
- ? layer_tree_host_->property_trees()->transform_tree.Node(
- transform_tree_index_)
- : nullptr;
-}
-
void Layer::OnTransformAnimated(const gfx::Transform& transform) {
inputs_.transform = transform;
}
-bool Layer::HasTickingAnimationForTesting() const {
- return layer_tree_host_
- ? GetMutatorHost()->HasTickingKeyframeModelForTesting(element_id())
- : false;
-}
-
void Layer::SetHasWillChangeTransformHint(bool has_will_change) {
if (inputs_.has_will_change_transform_hint == has_will_change)
return;
@@ -1378,21 +1375,18 @@ void Layer::SetTrilinearFiltering(bool trilinear_filtering) {
if (inputs_.trilinear_filtering == trilinear_filtering)
return;
inputs_.trilinear_filtering = trilinear_filtering;
+ // When true, makes a RenderSurface which makes an effect node.
+ SetPropertyTreesNeedRebuild();
+ // Adding a RenderSurface may change how things in the subtree appear, since
+ // it flattens transforms.
+ SetSubtreePropertyChanged();
SetNeedsCommit();
}
-MutatorHost* Layer::GetMutatorHost() const {
- return layer_tree_host_ ? layer_tree_host_->mutator_host() : nullptr;
-}
-
ElementListType Layer::GetElementTypeForAnimation() const {
return ElementListType::ACTIVE;
}
-ScrollbarLayerInterface* Layer::ToScrollbarLayer() {
- return nullptr;
-}
-
void Layer::RemoveFromClipTree() {
if (clip_children_.get()) {
std::set<Layer*> copy = *clip_children_;
@@ -1415,9 +1409,7 @@ void Layer::AddDrawableDescendants(int num) {
parent()->AddDrawableDescendants(num);
}
-void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) {
- benchmark->RunOnLayer(this);
-}
+void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) {}
void Layer::SetElementId(ElementId id) {
DCHECK(IsPropertyChangeAllowed());
@@ -1441,12 +1433,6 @@ void Layer::SetElementId(ElementId id) {
SetNeedsCommit();
}
-bool Layer::has_copy_requests_in_target_subtree() {
- return layer_tree_host_->property_trees()
- ->effect_tree.Node(effect_tree_index())
- ->subtree_has_copy_request;
-}
-
gfx::Transform Layer::ScreenSpaceTransform() const {
DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId);
return draw_property_utils::ScreenSpaceTransform(