Commit 75d740d4 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Convert LayerTreeImplTest* to layer list mode

Bug: 994361
Change-Id: Ibab9ea4f67f6159dab0e1027be65270b44e9d73a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1787461Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693938}
parent 2dfc49fc
......@@ -348,4 +348,11 @@ void LayerTestCommon::SetupBrowserControlsAndScrollLayerWithVirtualViewport(
EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds());
}
void LayerTestCommon::LayerImplTest::UpdateDrawProperties(
LayerTreeImpl* layer_tree_impl) {
LayerTreeHostCommon::PrepareForUpdateDrawPropertiesForTesting(
layer_tree_impl);
layer_tree_impl->UpdateDrawProperties();
}
} // namespace cc
......@@ -158,6 +158,11 @@ class LayerTestCommon {
host_impl()->active_tree()->SetElementIdsForTesting();
}
// These two functions calculates draw properties by directly calling
// LayerTreeHostCommon, not through LayerTreeImpl API, thus they don't
// update LayerTreeImpl's needs_update_draw_properties flag.
// TODO(wangxianzhu): Remove this version after cleaning up
// LayerTreeHostCommon API.
void ExecuteCalculateDrawProperties(
LayerImpl* root_layer,
float device_scale_factor = 1.0f,
......@@ -168,6 +173,9 @@ class LayerTestCommon {
void ExecuteCalculateDrawPropertiesWithoutAdjustingRasterScales(
LayerImpl* root_layer);
// This function updates draw properties through LayerTreeImpl API.
void UpdateDrawProperties(LayerTreeImpl*);
const RenderSurfaceList* render_surface_list_impl() const {
return render_surface_list_impl_.get();
}
......
This diff is collapsed.
......@@ -119,16 +119,21 @@ void SetFilter(const LayerType* layer, const FilterOperations& filters) {
// Creates viewport layers and (in layer list mode) paint properties.
// Convenient overload of the method below that creates a scrolling layer as
// the outer viewport scroll layer.
// the outer viewport scroll layer. The inner viewport size will be
// root->bounds().
void SetupViewport(Layer* root,
const gfx::Size& outer_bounds,
const gfx::Size& scroll_bounds);
const gfx::Size& outer_viewport_size,
const gfx::Size& content_size);
// Creates viewport layers and (in layer list mode) paint properties.
// Uses the given scroll layer as the content "outer viewport scroll layer".
void SetupViewport(Layer* root,
scoped_refptr<Layer> outer_scroll_layer,
const gfx::Size& outer_bounds);
scoped_refptr<Layer> outer_viewport_scroll_layer,
const gfx::Size& outer_viewport_size);
// The impl-side counterpart of the first version of SetupViewport().
void SetupViewport(LayerImpl* root,
const gfx::Size& outer_viewport_size,
const gfx::Size& content_size);
// Returns the RenderSurfaceImpl into which the given layer draws.
inline RenderSurfaceImpl* GetRenderSurface(const LayerImpl* layer) {
......
......@@ -647,22 +647,28 @@ void LayerTreeHostCommon::CalculateDrawProperties(
CalculateDrawPropertiesInternal(inputs, DONT_BUILD_PROPERTY_TREES, nullptr);
}
void LayerTreeHostCommon::CalculateDrawPropertiesForTesting(
CalcDrawPropsImplInputsForTesting* inputs) {
if (inputs->root_layer->layer_tree_impl()->settings().use_layer_lists) {
void LayerTreeHostCommon::PrepareForUpdateDrawPropertiesForTesting(
LayerTreeImpl* layer_tree_impl) {
if (layer_tree_impl->settings().use_layer_lists) {
// TODO(wangxianzhu): We should DCHECK(!needs_rebuild) after we remove all
// unnecessary setting of the flag in layer list mode.
inputs->property_trees->needs_rebuild = false;
auto* property_trees = layer_tree_impl->property_trees();
property_trees->needs_rebuild = false;
// The following are needed for tests that modify impl-side property trees.
// In production code impl-side property trees are pushed from the main
// thread and the following are done in other ways.
std::vector<std::unique_ptr<RenderSurfaceImpl>> old_render_surfaces;
inputs->property_trees->effect_tree.TakeRenderSurfaces(
&old_render_surfaces);
inputs->property_trees->effect_tree.CreateOrReuseRenderSurfaces(
&old_render_surfaces, inputs->root_layer->layer_tree_impl());
inputs->property_trees->ResetCachedData();
property_trees->effect_tree.TakeRenderSurfaces(&old_render_surfaces);
property_trees->effect_tree.CreateOrReuseRenderSurfaces(
&old_render_surfaces, layer_tree_impl);
property_trees->ResetCachedData();
}
}
void LayerTreeHostCommon::CalculateDrawPropertiesForTesting(
CalcDrawPropsImplInputsForTesting* inputs) {
PrepareForUpdateDrawPropertiesForTesting(
inputs->root_layer->layer_tree_impl());
CalculateDrawPropertiesInternal(inputs,
inputs->property_trees->needs_rebuild
? BUILD_PROPERTY_TREES
......
......@@ -122,6 +122,9 @@ class CC_EXPORT LayerTreeHostCommon {
CalcDrawPropsMainInputsForTesting* inputs);
static void CalculateDrawProperties(CalcDrawPropsImplInputs* inputs);
// TODO(wangxianzhu): Move these functions into testing classes.
static void PrepareForUpdateDrawPropertiesForTesting(LayerTreeImpl*);
static void CalculateDrawPropertiesForTesting(
CalcDrawPropsImplInputsForTesting* inputs);
......
This diff is collapsed.
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