Commit b36e0d5d authored by nyquist's avatar nyquist Committed by Commit bot

Ensure Layers have valid sequence numbers for PropertyTrees

Calling Layer::set_property_tree_sequence_number() does not set the
flag that a commit is needed, which means it can quickly get out of
date for layers that are not updated for other reasons when the Layer
is (de)serialized.

This CL makes the LayerTreeHost forcefully set the sequence number
to the same value as the current PropertyTrees.sequence_number, since
all valid in the hierarchy is valid at that point.

BUG=577352, 538710
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review URL: https://codereview.chromium.org/1584653004

Cr-Commit-Position: refs/heads/master@{#371654}
parent 1d7a11cf
......@@ -472,6 +472,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
void set_property_tree_sequence_number(int sequence_number) {
property_tree_sequence_number_ = sequence_number;
}
int property_tree_sequence_number() { return property_tree_sequence_number_; }
void SetTransformTreeIndex(int index);
int transform_tree_index() const;
......
......@@ -1438,6 +1438,17 @@ void LayerTreeHost::FromProtobufForCommit(const proto::LayerTreeHost& proto) {
property_trees_ = PropertyTrees();
property_trees_.FromProtobuf(proto.property_trees());
// Forcefully override the sequence number of all layers in the tree to have
// a valid sequence number. Changing the sequence number for a layer does not
// need a commit, so the value will become out of date for layers that are not
// updated for other reasons. All layers that at this point are part of the
// layer tree are valid, so it is OK that they have a valid sequence number.
int seq_num = property_trees_.sequence_number;
LayerTreeHostCommon::CallFunctionForSubtree(
root_layer(), [seq_num](Layer* layer) {
layer->set_property_tree_sequence_number(seq_num);
});
surface_id_namespace_ = proto.surface_id_namespace();
next_surface_sequence_ = proto.next_surface_sequence();
}
......
......@@ -155,6 +155,15 @@ class LayerTreeHostSerializationTest : public testing::Test {
layer_tree_host_dst_->surface_id_namespace_);
EXPECT_EQ(layer_tree_host_src_->next_surface_sequence_,
layer_tree_host_dst_->next_surface_sequence_);
// All layers must have a property tree index that matches PropertyTrees.
if (layer_tree_host_dst_->property_trees_.sequence_number) {
int seq_num = layer_tree_host_dst_->property_trees_.sequence_number;
LayerTreeHostCommon::CallFunctionForSubtree(
layer_tree_host_dst_->root_layer_.get(), [seq_num](Layer* layer) {
EXPECT_EQ(seq_num, layer->property_tree_sequence_number());
});
}
}
void RunAllMembersChangedTest() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment