Skip to content

Commit

Permalink
cc: Move main thread hierarchy dependencies into PropertyTreeBuilder
Browse files Browse the repository at this point in the history
Move PreCalculateMetaInformation to PropertyTreeBuilder.
Convert Layer::children() calls to using LayerListIterator.

BUG=600390
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review-Url: https://codereview.chromium.org/1921503005
Cr-Commit-Position: refs/heads/master@{#390461}
  • Loading branch information
sunxd authored and Commit bot committed Apr 28, 2016
1 parent 2f5b9a2 commit b365de0
Show file tree
Hide file tree
Showing 18 changed files with 255 additions and 289 deletions.
6 changes: 3 additions & 3 deletions cc/layers/layer_iterator_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ TEST_F(LayerIteratorTest, SimpleTree) {
LayerImplList render_surface_layer_list;
LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
root_ptr, root_ptr->bounds(), &render_surface_layer_list);
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);

IterateFrontToBack(&render_surface_layer_list);
EXPECT_COUNT(root_ptr, 5, -1, 4);
Expand Down Expand Up @@ -186,7 +186,7 @@ TEST_F(LayerIteratorTest, ComplexTree) {
LayerImplList render_surface_layer_list;
LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
root_ptr, root_ptr->bounds(), &render_surface_layer_list);
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);

IterateFrontToBack(&render_surface_layer_list);
EXPECT_COUNT(root_ptr, 9, -1, 8);
Expand Down Expand Up @@ -239,7 +239,7 @@ TEST_F(LayerIteratorTest, ComplexTreeMultiSurface) {
LayerImplList render_surface_layer_list;
LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
root_ptr, root_ptr->bounds(), &render_surface_layer_list);
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);

IterateFrontToBack(&render_surface_layer_list);
EXPECT_COUNT(root_ptr, 14, -1, 13);
Expand Down
2 changes: 1 addition & 1 deletion cc/layers/layer_position_constraint_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void ExecuteCalculateDrawProperties(LayerImpl* root_layer) {
root_layer->layer_tree_impl()->InnerViewportScrollLayer();
inputs.outer_viewport_scroll_layer =
root_layer->layer_tree_impl()->OuterViewportScrollLayer();
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
}

class LayerPositionConstraintTest : public testing::Test {
Expand Down
2 changes: 1 addition & 1 deletion cc/test/layer_test_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void LayerTestCommon::LayerImplTest::CalcDrawProps(
LayerImplList layer_list;
LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
root_layer(), viewport_size, &layer_list);
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
}

void LayerTestCommon::LayerImplTest::AppendQuadsWithOcclusion(
Expand Down
10 changes: 5 additions & 5 deletions cc/test/layer_tree_host_common_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties(
Layer* page_scale_layer,
bool can_use_lcd_text,
bool layers_always_allowed_lcd_text) {
LayerTreeHostCommon::PreCalculateMetaInformation(root_layer);
PropertyTreeBuilder::PreCalculateMetaInformation(root_layer);

EXPECT_TRUE(page_scale_layer || (page_scale_factor == 1.f));
gfx::Transform identity_matrix;
Expand All @@ -96,7 +96,7 @@ void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties(
void LayerTreeHostCommonTestBase::
ExecuteCalculateDrawPropertiesWithPropertyTrees(Layer* root_layer) {
DCHECK(root_layer->layer_tree_host());
LayerTreeHostCommon::PreCalculateMetaInformation(root_layer);
PropertyTreeBuilder::PreCalculateMetaInformation(root_layer);

gfx::Transform identity_transform;

Expand Down Expand Up @@ -138,7 +138,7 @@ void LayerTreeHostCommonTestBase::
void LayerTreeHostCommonTestBase::
ExecuteCalculateDrawPropertiesWithPropertyTrees(LayerImpl* root_layer) {
DCHECK(root_layer->layer_tree_impl());
LayerTreeHostCommon::PreCalculateMetaInformationForTesting(root_layer);
PropertyTreeBuilder::PreCalculateMetaInformationForTesting(root_layer);

gfx::Transform identity_transform;

Expand Down Expand Up @@ -198,7 +198,7 @@ void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties(
inputs.layers_always_allowed_lcd_text = layers_always_allowed_lcd_text;
inputs.can_adjust_raster_scales = true;

LayerTreeHostCommon::CalculateDrawProperties(&inputs);
LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
}

void LayerTreeHostCommonTestBase::
Expand All @@ -215,7 +215,7 @@ void LayerTreeHostCommonTestBase::
inputs.can_adjust_raster_scales = true;
inputs.can_render_to_separate_surface = false;

LayerTreeHostCommon::CalculateDrawProperties(&inputs);
LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
}

bool LayerTreeHostCommonTestBase::UpdateLayerListContains(int id) const {
Expand Down
2 changes: 1 addition & 1 deletion cc/trees/damage_tracker_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void ExecuteCalculateDrawProperties(LayerImpl* root,
FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root);
LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
root, root->bounds(), render_surface_layer_list);
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
ASSERT_TRUE(root->render_surface());
}

Expand Down
21 changes: 4 additions & 17 deletions cc/trees/draw_property_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ static void ValidateRenderSurfaceForLayer(LayerType* layer) {
ValidateIsNotRootForIsolatedGroup(layer);
}

static void ValidateRenderSurfacesRecursive(Layer* layer) {
ValidateRenderSurfaceForLayer(layer);
for (size_t i = 0; i < layer->children().size(); ++i)
ValidateRenderSurfacesRecursive(layer->child_at(i));
}
#endif

template <typename LayerType>
Expand Down Expand Up @@ -373,15 +368,6 @@ void UpdateRenderSurfaceForLayer(EffectTree* effect_tree,
layer->SetHasRenderSurface(false);
}

void UpdateRenderSurfacesForLayersRecursive(EffectTree* effect_tree,
Layer* layer) {
UpdateRenderSurfaceForLayer(effect_tree, true, layer);

for (size_t i = 0; i < layer->children().size(); ++i) {
UpdateRenderSurfacesForLayersRecursive(effect_tree, layer->child_at(i));
}
}

} // namespace

template <typename LayerType>
Expand Down Expand Up @@ -658,11 +644,12 @@ static void ComputeVisibleRectsInternal(
}

void UpdateRenderSurfaces(Layer* root_layer, PropertyTrees* property_trees) {
UpdateRenderSurfacesForLayersRecursive(&property_trees->effect_tree,
root_layer);
for (auto* layer : *root_layer->layer_tree_host()) {
UpdateRenderSurfaceForLayer(&property_trees->effect_tree, true, layer);
#if DCHECK_IS_ON()
ValidateRenderSurfacesRecursive(root_layer);
ValidateRenderSurfaceForLayer(layer);
#endif
}
}

void UpdatePropertyTrees(PropertyTrees* property_trees,
Expand Down
47 changes: 14 additions & 33 deletions cc/trees/layer_tree_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ LayerTreeHost::LayerTreeHost(InitParams* params, CompositorMode mode)
needs_meta_info_recomputation_(true),
client_(params->client),
source_frame_number_(0),
meta_information_sequence_number_(1),
rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()),
output_surface_lost_(true),
settings_(*params->settings),
Expand Down Expand Up @@ -656,16 +655,8 @@ void LayerTreeHost::SetDeferCommits(bool defer_commits) {
}

void LayerTreeHost::SetNeedsDisplayOnAllLayers() {
std::stack<Layer*> layer_stack;
layer_stack.push(root_layer());
while (!layer_stack.empty()) {
Layer* current_layer = layer_stack.top();
layer_stack.pop();
current_layer->SetNeedsDisplay();
for (unsigned int i = 0; i < current_layer->children().size(); i++) {
layer_stack.push(current_layer->child_at(i));
}
}
for (auto* layer : *this)
layer->SetNeedsDisplay();
}

void LayerTreeHost::SetOutputIsSecure(bool output_is_secure) {
Expand Down Expand Up @@ -910,6 +901,14 @@ LayerListIterator<Layer> LayerTreeHost::end() {
return LayerListIterator<Layer>(nullptr);
}

const LayerListIterator<Layer> LayerTreeHost::begin() const {
return LayerListIterator<Layer>(root_layer_.get());
}

const LayerListIterator<Layer> LayerTreeHost::end() const {
return LayerListIterator<Layer>(nullptr);
}

LayerListReverseIterator<Layer> LayerTreeHost::rbegin() {
return LayerListReverseIterator<Layer>(root_layer_.get());
}
Expand All @@ -922,22 +921,6 @@ void LayerTreeHost::DidCompletePageScaleAnimation() {
did_complete_scale_animation_ = true;
}

static Layer* FindFirstScrollableLayer(Layer* layer) {
if (!layer)
return NULL;

if (layer->scrollable())
return layer;

for (size_t i = 0; i < layer->children().size(); ++i) {
Layer* found = FindFirstScrollableLayer(layer->children()[i].get());
if (found)
return found;
}

return NULL;
}

void LayerTreeHost::RecordGpuRasterizationHistogram() {
// Gpu rasterization is only supported for Renderer compositors.
// Checking for IsSingleThreaded() to exclude Browser compositors.
Expand Down Expand Up @@ -965,7 +948,7 @@ void LayerTreeHost::RecordGpuRasterizationHistogram() {
}

void LayerTreeHost::BuildPropertyTreesForTesting() {
LayerTreeHostCommon::PreCalculateMetaInformationForTesting(root_layer_.get());
PropertyTreeBuilder::PreCalculateMetaInformation(root_layer_.get());
gfx::Transform identity_transform;
PropertyTreeBuilder::BuildPropertyTrees(
root_layer_.get(), page_scale_layer_.get(),
Expand All @@ -985,7 +968,8 @@ bool LayerTreeHost::DoUpdateLayers(Layer* root_layer) {

UpdateHudLayer();

Layer* root_scroll = FindFirstScrollableLayer(root_layer);
Layer* root_scroll =
PropertyTreeBuilder::FindFirstScrollableLayer(root_layer);
Layer* page_scale_layer = page_scale_layer_.get();
if (!page_scale_layer && root_scroll)
page_scale_layer = root_scroll->parent();
Expand All @@ -1002,7 +986,7 @@ bool LayerTreeHost::DoUpdateLayers(Layer* root_layer) {
TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::BuildPropertyTrees");
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
"LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees");
LayerTreeHostCommon::PreCalculateMetaInformation(root_layer);
PropertyTreeBuilder::PreCalculateMetaInformation(root_layer);
bool can_render_to_separate_surface = true;
PropertyTreeBuilder::BuildPropertyTrees(
root_layer, page_scale_layer, inner_viewport_scroll_layer_.get(),
Expand Down Expand Up @@ -1503,8 +1487,6 @@ void LayerTreeHost::ToProtobufForCommit(proto::LayerTreeHost* proto) {
proto->set_needs_full_tree_sync(needs_full_tree_sync_);
proto->set_needs_meta_info_recomputation(needs_meta_info_recomputation_);
proto->set_source_frame_number(source_frame_number_);
proto->set_meta_information_sequence_number(
meta_information_sequence_number_);

LayerProtoConverter::SerializeLayerHierarchy(root_layer_,
proto->mutable_root_layer());
Expand Down Expand Up @@ -1576,7 +1558,6 @@ void LayerTreeHost::FromProtobufForCommit(const proto::LayerTreeHost& proto) {
needs_full_tree_sync_ = proto.needs_full_tree_sync();
needs_meta_info_recomputation_ = proto.needs_meta_info_recomputation();
source_frame_number_ = proto.source_frame_number();
meta_information_sequence_number_ = proto.meta_information_sequence_number();

// Layer hierarchy.
scoped_refptr<Layer> new_root_layer =
Expand Down
11 changes: 2 additions & 9 deletions cc/trees/layer_tree_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient {

LayerListIterator<Layer> begin();
LayerListIterator<Layer> end();
const LayerListIterator<Layer> begin() const;
const LayerListIterator<Layer> end() const;
LayerListReverseIterator<Layer> rbegin();
LayerListReverseIterator<Layer> rend();

Expand All @@ -171,18 +173,10 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient {

int source_frame_number() const { return source_frame_number_; }

int meta_information_sequence_number() {
return meta_information_sequence_number_;
}

bool gpu_rasterization_histogram_recorded() const {
return gpu_rasterization_histogram_recorded_;
}

void IncrementMetaInformationSequenceNumber() {
meta_information_sequence_number_++;
}

void SetNeedsDisplayOnAllLayers();

void SetOutputIsSecure(bool output_is_secure);
Expand Down Expand Up @@ -510,7 +504,6 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient {
std::unique_ptr<TaskRunnerProvider> task_runner_provider_;

int source_frame_number_;
int meta_information_sequence_number_;
std::unique_ptr<RenderingStatsInstrumentation>
rendering_stats_instrumentation_;

Expand Down
Loading

0 comments on commit b365de0

Please sign in to comment.