summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjaydasika <jaydasika@chromium.org>2016-01-29 11:35:40 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-29 19:37:39 +0000
commite99e83e941ee73edccbaea5ec8313734dd71fe53 (patch)
treee929aa6fcb2fd7c37a6416876769be48f0518c73
parentd9e62efae7f7f8e42ffe7e6046759f0b7bc73cd1 (diff)
downloadchromium_src-e99e83e941ee73edccbaea5ec8313734dd71fe53.zip
chromium_src-e99e83e941ee73edccbaea5ec8313734dd71fe53.tar.gz
chromium_src-e99e83e941ee73edccbaea5ec8313734dd71fe53.tar.bz2
cc:: Layer with animating opacity should contribute to drawn surface
Right now, layer with animating opacity and opacity 0 draws but does not contribute to drawn surface. This patch also replaces screen_space_opacity_is_aniamting on the effect tree with has_animated_opacity. We don't need to know screen space opacity animation because even if some ancestor has animating opacity, the current layer need not draw if has opacity 0 and itself doesn't animate opacity. BUG=580940, 582021 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1649783004 Cr-Commit-Position: refs/heads/master@{#372397}
-rw-r--r--cc/proto/property_tree.proto2
-rw-r--r--cc/trees/layer_tree_host_common_unittest.cc21
-rw-r--r--cc/trees/property_tree.cc17
-rw-r--r--cc/trees/property_tree.h2
-rw-r--r--cc/trees/property_tree_builder.cc6
5 files changed, 30 insertions, 18 deletions
diff --git a/cc/proto/property_tree.proto b/cc/proto/property_tree.proto
index f70c8bd..713c60a 100644
--- a/cc/proto/property_tree.proto
+++ b/cc/proto/property_tree.proto
@@ -85,7 +85,7 @@ message EffectNodeData {
optional bool has_copy_request = 4;
optional bool has_background_filters = 5;
optional bool is_drawn = 6;
- optional bool screen_space_opacity_is_animating = 7;
+ optional bool has_animated_opacity = 7;
optional int64 num_copy_requests_in_subtree = 8;
optional int64 transform_id = 9;
optional int64 clip_id = 10;
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index 84e7fde..50fbaa5 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -5188,7 +5188,7 @@ TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) {
// If the root itself is hidden, the child should not be drawn even if it has
// an animating opacity.
- root->SetOpacity(0.f);
+ root->SetOpacity(0.0f);
root->layer_tree_impl()->property_trees()->needs_rebuild = true;
LayerImplList render_surface_layer_list2;
root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
@@ -5202,6 +5202,25 @@ TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) {
EffectTree tree = root->layer_tree_impl()->property_trees()->effect_tree;
EffectNode* node = tree.Node(child_ptr->effect_tree_index());
EXPECT_FALSE(node->data.is_drawn);
+
+ // A layer should be drawn and it should contribute to drawn surface when
+ // it has animating opacity even if it has opacity 0.
+ root->SetOpacity(1.0f);
+ child_ptr->SetOpacity(0.0f);
+ root->layer_tree_impl()->property_trees()->needs_rebuild = true;
+ LayerImplList render_surface_layer_list3;
+ root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
+ LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3(
+ root.get(), root->bounds(), &render_surface_layer_list3,
+ root->layer_tree_impl()->current_render_surface_list_id());
+ inputs3.can_adjust_raster_scales = true;
+ LayerTreeHostCommon::CalculateDrawProperties(&inputs3);
+
+ child_ptr = root->layer_tree_impl()->LayerById(2);
+ tree = root->layer_tree_impl()->property_trees()->effect_tree;
+ node = tree.Node(child_ptr->effect_tree_index());
+ EXPECT_TRUE(node->data.is_drawn);
+ EXPECT_TRUE(tree.ContributesToDrawnSurface(child_ptr->effect_tree_index()));
}
class LayerTreeSettingsForLCDTextTest : public LayerTreeSettings {
diff --git a/cc/trees/property_tree.cc b/cc/trees/property_tree.cc
index 2f88c83..a425efa 100644
--- a/cc/trees/property_tree.cc
+++ b/cc/trees/property_tree.cc
@@ -422,7 +422,7 @@ EffectNodeData::EffectNodeData()
has_copy_request(false),
has_background_filters(false),
is_drawn(true),
- screen_space_opacity_is_animating(false),
+ has_animated_opacity(false),
num_copy_requests_in_subtree(0),
transform_id(0),
clip_id(0) {}
@@ -434,8 +434,7 @@ bool EffectNodeData::operator==(const EffectNodeData& other) const {
has_copy_request == other.has_copy_request &&
has_background_filters == other.has_background_filters &&
is_drawn == other.is_drawn &&
- screen_space_opacity_is_animating ==
- other.screen_space_opacity_is_animating &&
+ has_animated_opacity == other.has_animated_opacity &&
num_copy_requests_in_subtree == other.num_copy_requests_in_subtree &&
transform_id == other.transform_id && clip_id == other.clip_id;
}
@@ -449,8 +448,7 @@ void EffectNodeData::ToProtobuf(proto::TreeNode* proto) const {
data->set_has_copy_request(has_copy_request);
data->set_has_background_filters(has_background_filters);
data->set_is_drawn(is_drawn);
- data->set_screen_space_opacity_is_animating(
- screen_space_opacity_is_animating);
+ data->set_has_animated_opacity(has_animated_opacity);
data->set_num_copy_requests_in_subtree(num_copy_requests_in_subtree);
data->set_transform_id(transform_id);
data->set_clip_id(clip_id);
@@ -466,7 +464,7 @@ void EffectNodeData::FromProtobuf(const proto::TreeNode& proto) {
has_copy_request = data.has_copy_request();
has_background_filters = data.has_background_filters();
is_drawn = data.is_drawn();
- screen_space_opacity_is_animating = data.screen_space_opacity_is_animating();
+ has_animated_opacity = data.has_animated_opacity();
num_copy_requests_in_subtree = data.num_copy_requests_in_subtree();
transform_id = data.transform_id();
clip_id = data.clip_id();
@@ -1103,9 +1101,7 @@ void EffectTree::UpdateIsDrawn(EffectNode* node, EffectNode* parent_node) {
// drawn irrespective of their opacity.
if (node->data.has_copy_request || node->data.has_background_filters)
node->data.is_drawn = true;
- else if (node->data.screen_space_opacity_is_animating)
- node->data.is_drawn = parent_node ? parent_node->data.is_drawn : true;
- else if (node->data.opacity == 0.f)
+ else if (node->data.opacity == 0.f && !node->data.has_animated_opacity)
node->data.is_drawn = false;
else if (parent_node)
node->data.is_drawn = parent_node->data.is_drawn;
@@ -1137,7 +1133,8 @@ bool EffectTree::ContributesToDrawnSurface(int id) {
EffectNode* parent_node = parent(node);
bool contributes_to_drawn_surface =
node->data.is_drawn &&
- (node->data.opacity != 0.f || node->data.has_background_filters);
+ (node->data.opacity != 0.f || node->data.has_animated_opacity ||
+ node->data.has_background_filters);
if (parent_node && !parent_node->data.is_drawn)
contributes_to_drawn_surface = false;
return contributes_to_drawn_surface;
diff --git a/cc/trees/property_tree.h b/cc/trees/property_tree.h
index 52aa419..f419e5f 100644
--- a/cc/trees/property_tree.h
+++ b/cc/trees/property_tree.h
@@ -251,7 +251,7 @@ struct CC_EXPORT EffectNodeData {
bool has_copy_request;
bool has_background_filters;
bool is_drawn;
- bool screen_space_opacity_is_animating;
+ bool has_animated_opacity;
int num_copy_requests_in_subtree;
int transform_id;
int clip_id;
diff --git a/cc/trees/property_tree_builder.cc b/cc/trees/property_tree_builder.cc
index 0dc9e13..7319c6e 100644
--- a/cc/trees/property_tree_builder.cc
+++ b/cc/trees/property_tree_builder.cc
@@ -603,6 +603,7 @@ bool AddEffectNodeIfNeeded(
node.data.has_render_surface = should_create_render_surface;
node.data.has_copy_request = layer->HasCopyRequest();
node.data.has_background_filters = !layer->background_filters().IsEmpty();
+ node.data.has_animated_opacity = has_animated_opacity;
if (!is_root) {
// The effect node's transform id is used only when we create a render
@@ -616,10 +617,6 @@ bool AddEffectNodeIfNeeded(
data_from_ancestor.transform_tree->next_available_id();
}
node.data.clip_id = data_from_ancestor.clip_tree_parent;
-
- EffectNode* parent = data_from_ancestor.effect_tree->Node(parent_id);
- node.data.screen_space_opacity_is_animating =
- parent->data.screen_space_opacity_is_animating || has_animated_opacity;
} else {
// Root render surface acts the unbounded and untransformed to draw content
// into. Transform node created from root layer (includes device scale
@@ -627,7 +624,6 @@ bool AddEffectNodeIfNeeded(
// to root render surface's content, but not root render surface itself.
node.data.transform_id = kRootPropertyTreeNodeId;
node.data.clip_id = kRootPropertyTreeNodeId;
- node.data.screen_space_opacity_is_animating = has_animated_opacity;
}
data_for_children->effect_tree_parent =
data_for_children->effect_tree->Insert(node, parent_id);