Commit 601f2ef1 authored by enne's avatar enne Committed by Commit bot

Fix cc unit tests that depend on verify_property_trees=true

A number of cc unit tests have started checking property tree output,
primarily visible_rect_from_property_trees but also needs_rebuild on the
trees.

Because of this, these tests now depend on running the property tree
code, so setting verify_property_trees=false forces these tests to run
only CDP code which causes them to fail.

Therefore, convert these specific tests to use property tree updates
directly.  This also requires a PrecalculateMetaInformation function
for LayerImpl, as LayerTreeHostCommonTest.SkippingSubtreeImpl touched
LayerImpl properties that could only theoretically be changed from
the main thread.

In the future, I think all layer tree host common tests will need to go
down the property tree update path, but (in my opinion) it's not worth
doing that until we have property trees everywhere.  This patch is just
a step in that direction to unblock property trees for the compositor
thread first.

R=ajuma@chromium.org,vollick@chromium.org
BUG=481585

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

Cr-Commit-Position: refs/heads/master@{#330561}
parent 4a8834a2
......@@ -7,6 +7,7 @@
#include "cc/layers/layer.h"
#include "cc/layers/layer_impl.h"
#include "cc/test/fake_layer_tree_host.h"
#include "cc/trees/draw_property_utils.h"
#include "cc/trees/layer_tree_host_common.h"
namespace cc {
......@@ -80,6 +81,50 @@ void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties(
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
}
void LayerTreeHostCommonTestBase::
ExecuteCalculateDrawPropertiesWithPropertyTrees(Layer* root_layer) {
DCHECK(root_layer->layer_tree_host());
LayerTreeHostCommon::PreCalculateMetaInformation(root_layer);
gfx::Transform identity_transform;
bool preserves_2d_axis_alignment = false;
bool can_render_to_separate_surface = true;
LayerTreeHostCommon::UpdateRenderSurfaces(
root_layer, can_render_to_separate_surface, identity_transform,
preserves_2d_axis_alignment);
Layer* page_scale_layer = nullptr;
float page_scale_factor = 1.f;
float device_scale_factor = 1.f;
gfx::Size device_viewport_size =
gfx::Size(root_layer->bounds().width() * device_scale_factor,
root_layer->bounds().height() * device_scale_factor);
LayerList update_layer_list;
BuildPropertyTreesAndComputeVisibleRects(
root_layer, page_scale_layer, page_scale_factor, device_scale_factor,
gfx::Rect(device_viewport_size), identity_transform,
root_layer->layer_tree_host()->property_trees(), &update_layer_list);
}
void LayerTreeHostCommonTestBase::
ExecuteCalculateDrawPropertiesWithPropertyTrees(LayerImpl* root_layer) {
DCHECK(root_layer->layer_tree_impl());
LayerTreeHostCommon::PreCalculateMetaInformationForTesting(root_layer);
gfx::Transform identity_transform;
LayerImpl* page_scale_layer = nullptr;
float page_scale_factor = 1.f;
float device_scale_factor = 1.f;
gfx::Size device_viewport_size =
gfx::Size(root_layer->bounds().width() * device_scale_factor,
root_layer->bounds().height() * device_scale_factor);
std::vector<LayerImpl*> update_layer_list;
BuildPropertyTreesAndComputeVisibleRects(
root_layer, page_scale_layer, page_scale_factor, device_scale_factor,
gfx::Rect(device_viewport_size), identity_transform,
root_layer->layer_tree_impl()->property_trees(), &update_layer_list);
}
void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties(
LayerImpl* root_layer,
float device_scale_factor,
......
......@@ -10,6 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "cc/layers/layer_lists.h"
#include "cc/test/fake_layer_tree_host_client.h"
#include "cc/trees/property_tree.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace gfx {
......@@ -104,6 +105,9 @@ class LayerTreeHostCommonTestBase {
page_scale_application_layer, false, false);
}
void ExecuteCalculateDrawPropertiesWithPropertyTrees(Layer* layer);
void ExecuteCalculateDrawPropertiesWithPropertyTrees(LayerImpl* layer);
RenderSurfaceLayerList* render_surface_layer_list() const {
return render_surface_layer_list_.get();
}
......
......@@ -1359,6 +1359,12 @@ void LayerTreeHostCommon::PreCalculateMetaInformation(Layer* root_layer) {
PreCalculateMetaInformationInternal(root_layer, &recursive_data);
}
void LayerTreeHostCommon::PreCalculateMetaInformationForTesting(
LayerImpl* root_layer) {
PreCalculateMetaInformationRecursiveData recursive_data;
PreCalculateMetaInformationInternal(root_layer, &recursive_data);
}
template <typename LayerType>
struct SubtreeGlobals {
int max_texture_size;
......
......@@ -121,6 +121,7 @@ class CC_EXPORT LayerTreeHostCommon {
bool* animation_preserves_axis_alignment);
static void CalculateDrawProperties(CalcDrawPropsMainInputs* inputs);
static void PreCalculateMetaInformation(Layer* root_layer);
static void PreCalculateMetaInformationForTesting(LayerImpl* root_layer);
typedef CalcDrawPropsInputs<LayerImpl, LayerImplList> CalcDrawPropsImplInputs;
typedef CalcDrawPropsInputsForTesting<LayerImpl, LayerImplList>
......
This diff is collapsed.
......@@ -132,6 +132,7 @@ class CC_EXPORT LayerTreeImpl {
void SetPropertyTrees(const PropertyTrees& property_trees) {
property_trees_ = property_trees;
}
PropertyTrees* property_trees() { return &property_trees_; }
void PushPropertiesTo(LayerTreeImpl* tree_impl);
......
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