summaryrefslogtreecommitdiffstats
path: root/chromium/cc/trees/occlusion_tracker_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/cc/trees/occlusion_tracker_unittest.cc')
-rw-r--r--chromium/cc/trees/occlusion_tracker_unittest.cc746
1 files changed, 377 insertions, 369 deletions
diff --git a/chromium/cc/trees/occlusion_tracker_unittest.cc b/chromium/cc/trees/occlusion_tracker_unittest.cc
index 41c812e1585..6fa6693d1f4 100644
--- a/chromium/cc/trees/occlusion_tracker_unittest.cc
+++ b/chromium/cc/trees/occlusion_tracker_unittest.cc
@@ -14,13 +14,15 @@
#include "cc/paint/filter_operations.h"
#include "cc/test/animation_test_common.h"
#include "cc/test/fake_impl_task_runner_provider.h"
+#include "cc/test/fake_layer_tree_frame_sink.h"
#include "cc/test/fake_layer_tree_host.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/layer_test_common.h"
+#include "cc/test/property_tree_test_utils.h"
#include "cc/test/test_occlusion_tracker.h"
#include "cc/test/test_task_graph_runner.h"
-#include "cc/trees/layer_tree_host_common.h"
+#include "cc/trees/draw_property_utils.h"
#include "cc/trees/single_thread_proxy.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "components/viz/common/frame_sinks/copy_output_result.h"
@@ -90,35 +92,34 @@ class OcclusionTrackerTest : public testing::Test {
protected:
explicit OcclusionTrackerTest(bool opaque_layers)
: opaque_layers_(opaque_layers),
+ layer_tree_frame_sink_(FakeLayerTreeFrameSink::Create3d()),
animation_host_(AnimationHost::CreateForTesting(ThreadInstance::MAIN)),
host_(FakeLayerTreeHost::Create(&client_,
&task_graph_runner_,
- animation_host_.get())),
- next_layer_impl_id_(1) {}
+ animation_host_.get(),
+ LayerListSettings())),
+ next_layer_impl_id_(1) {
+ host_->host_impl()->InitializeFrameSink(layer_tree_frame_sink_.get());
+ }
virtual void RunMyTest() = 0;
void TearDown() override { DestroyLayers(); }
- TestContentLayerImpl* CreateRoot(const gfx::Transform& transform,
- const gfx::PointF& position,
- const gfx::Size& bounds) {
+ TestContentLayerImpl* CreateRoot(const gfx::Size& bounds) {
LayerTreeImpl* tree = host_->host_impl()->active_tree();
int id = next_layer_impl_id_++;
std::unique_ptr<TestContentLayerImpl> layer(
new TestContentLayerImpl(tree, id));
TestContentLayerImpl* layer_ptr = layer.get();
- SetProperties(layer_ptr, transform, position, bounds);
+ layer_ptr->SetBounds(bounds);
+ SetupRootProperties(layer_ptr);
host_->host_impl()->active_tree()->SetRootLayerForTesting(std::move(layer));
-
- layer_ptr->test_properties()->force_render_surface = true;
- SetRootLayerOnMainThread(layer_ptr);
-
return layer_ptr;
}
- LayerImpl* CreateLayer(LayerImpl* parent,
+ LayerImpl* CreateLayer(LayerImpl* property_parent,
const gfx::Transform& transform,
const gfx::PointF& position,
const gfx::Size& bounds) {
@@ -126,21 +127,30 @@ class OcclusionTrackerTest : public testing::Test {
int id = next_layer_impl_id_++;
std::unique_ptr<LayerImpl> layer = LayerImpl::Create(tree, id);
LayerImpl* layer_ptr = layer.get();
- SetProperties(layer_ptr, transform, position, bounds);
- parent->test_properties()->AddChild(std::move(layer));
+ SetProperties(layer_ptr, property_parent, transform, position, bounds);
+ tree->AddLayer(std::move(layer));
return layer_ptr;
}
+ void EnsureTransformNode(LayerImpl* layer) {
+ if (!layer->has_transform_node()) {
+ CreateTransformNode(layer).post_translation =
+ layer->offset_to_transform_parent();
+ layer->SetOffsetToTransformParent(gfx::Vector2dF());
+ }
+ }
+
LayerImpl* CreateSurface(LayerImpl* parent,
const gfx::Transform& transform,
const gfx::PointF& position,
const gfx::Size& bounds) {
LayerImpl* layer = CreateLayer(parent, transform, position, bounds);
- layer->test_properties()->force_render_surface = true;
+ EnsureTransformNode(layer);
+ CreateEffectNode(layer).render_surface_reason = RenderSurfaceReason::kTest;
return layer;
}
- TestContentLayerImpl* CreateDrawingLayer(LayerImpl* parent,
+ TestContentLayerImpl* CreateDrawingLayer(LayerImpl* property_parent,
const gfx::Transform& transform,
const gfx::PointF& position,
const gfx::Size& bounds,
@@ -150,7 +160,7 @@ class OcclusionTrackerTest : public testing::Test {
std::unique_ptr<TestContentLayerImpl> layer(
new TestContentLayerImpl(tree, id));
TestContentLayerImpl* layer_ptr = layer.get();
- SetProperties(layer_ptr, transform, position, bounds);
+ SetProperties(layer_ptr, property_parent, transform, position, bounds);
if (opaque_layers_) {
layer_ptr->SetContentsOpaque(opaque);
@@ -162,64 +172,76 @@ class OcclusionTrackerTest : public testing::Test {
layer_ptr->SetOpaqueContentsRect(gfx::Rect());
}
- parent->test_properties()->AddChild(std::move(layer));
+ tree->AddLayer(std::move(layer));
return layer_ptr;
}
- TestContentLayerImpl* CreateDrawingSurface(LayerImpl* parent,
+ TestContentLayerImpl* CreateDrawingSurface(LayerImpl* property_parent,
const gfx::Transform& transform,
const gfx::PointF& position,
const gfx::Size& bounds,
bool opaque) {
- TestContentLayerImpl* layer =
- CreateDrawingLayer(parent, transform, position, bounds, opaque);
- layer->test_properties()->force_render_surface = true;
+ TestContentLayerImpl* layer = CreateDrawingLayer(property_parent, transform,
+ position, bounds, opaque);
+ EnsureTransformNode(layer);
+ CreateEffectNode(layer).render_surface_reason = RenderSurfaceReason::kTest;
return layer;
}
- void DestroyLayers() {
- host_->host_impl()->active_tree()->SetRootLayerForTesting(nullptr);
- render_surface_list_impl_.clear();
- mask_layers_.clear();
- layer_iterator_.reset();
+ void SetMasksToBounds(LayerImpl* layer) {
+ layer->SetMasksToBounds(true);
+ CreateClipNode(layer);
}
- void AddCopyRequest(Layer* layer) {
- layer->RequestCopyOfOutput(viz::CopyOutputRequest::CreateStubForTesting());
+ void DestroyLayers() {
+ auto* tree = host_->host_impl()->active_tree();
+ tree->DetachLayers();
+ tree->property_trees()->clear();
+ layer_iterator_.reset();
}
- void AddCopyRequest(LayerImpl* layer) {
- layer->test_properties()->copy_requests.push_back(
- viz::CopyOutputRequest::CreateStubForTesting());
+ LayerImpl* CreateCopyLayer(LayerImpl* parent,
+ const gfx::Transform& transform,
+ const gfx::PointF& position,
+ const gfx::Size& bounds) {
+ LayerImpl* layer = CreateSurface(parent, transform, position, bounds);
+ auto* effect_node = GetEffectNode(layer);
+ effect_node->render_surface_reason = RenderSurfaceReason::kCopyRequest;
+ effect_node->has_copy_request = true;
+ effect_node->closest_ancestor_with_copy_request_id = effect_node->id;
+ auto& effect_tree = GetPropertyTrees(layer)->effect_tree;
+ effect_tree.AddCopyRequest(effect_node->id,
+ viz::CopyOutputRequest::CreateStubForTesting());
+ // TODO(wangxianzhu): Let EffectTree::UpdateEffects() handle this.
+ do {
+ effect_node->subtree_has_copy_request = true;
+ effect_node = effect_tree.Node(effect_node->parent_id);
+ } while (effect_node && !effect_node->subtree_has_copy_request);
+ return layer;
}
- void CalcDrawEtc(TestContentLayerImpl* root) {
- root->layer_tree_impl()->BuildLayerListForTesting();
- DCHECK(root == root->layer_tree_impl()->root_layer_for_testing());
-
- // These occlusion tests attach and detach layers in multiple
- // iterations, so rebuild property trees every time.
- root->layer_tree_impl()->property_trees()->needs_rebuild = true;
-
- LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
- root, gfx::Rect(root->bounds()), &render_surface_list_impl_);
- LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
+ void CalcDrawEtc() {
+ LayerTreeImpl* tree = host_->host_impl()->active_tree();
+ tree->SetDeviceViewportRect(gfx::Rect(tree->root_layer()->bounds()));
+ UpdateDrawProperties(tree);
- layer_iterator_ = std::make_unique<EffectTreeLayerListIterator>(
- host_->host_impl()->active_tree());
+ layer_iterator_ = std::make_unique<EffectTreeLayerListIterator>(tree);
}
+#define ASSERT_EQ_WITH_IDS(a, b) \
+ ASSERT_EQ(a, b) << " ids: " << (a)->id() << " vs " << (b)->id()
+
void EnterLayer(LayerImpl* layer, OcclusionTracker* occlusion) {
- ASSERT_EQ(layer_iterator_->current_layer(), layer);
- ASSERT_TRUE(layer_iterator_->state() ==
- EffectTreeLayerListIterator::State::LAYER);
+ ASSERT_EQ(EffectTreeLayerListIterator::State::LAYER,
+ layer_iterator_->state());
+ ASSERT_EQ_WITH_IDS(layer, layer_iterator_->current_layer());
occlusion->EnterLayer(*layer_iterator_);
}
void LeaveLayer(LayerImpl* layer, OcclusionTracker* occlusion) {
- ASSERT_EQ(layer_iterator_->current_layer(), layer);
- ASSERT_TRUE(layer_iterator_->state() ==
- EffectTreeLayerListIterator::State::LAYER);
+ ASSERT_EQ(EffectTreeLayerListIterator::State::LAYER,
+ layer_iterator_->state());
+ ASSERT_EQ_WITH_IDS(layer, layer_iterator_->current_layer());
occlusion->LeaveLayer(*layer_iterator_);
++(*layer_iterator_);
}
@@ -230,23 +252,23 @@ class OcclusionTrackerTest : public testing::Test {
}
void EnterContributingSurface(LayerImpl* layer, OcclusionTracker* occlusion) {
- ASSERT_EQ(layer_iterator_->target_render_surface(),
- GetRenderSurface(layer));
- ASSERT_TRUE(layer_iterator_->state() ==
- EffectTreeLayerListIterator::State::TARGET_SURFACE);
+ ASSERT_EQ(EffectTreeLayerListIterator::State::TARGET_SURFACE,
+ layer_iterator_->state());
+ ASSERT_EQ_WITH_IDS(GetRenderSurface(layer),
+ layer_iterator_->target_render_surface());
occlusion->EnterLayer(*layer_iterator_);
occlusion->LeaveLayer(*layer_iterator_);
++(*layer_iterator_);
- ASSERT_TRUE(layer_iterator_->state() ==
- EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE);
+ ASSERT_EQ(EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE,
+ layer_iterator_->state());
occlusion->EnterLayer(*layer_iterator_);
}
void LeaveContributingSurface(LayerImpl* layer, OcclusionTracker* occlusion) {
- ASSERT_EQ(layer_iterator_->current_render_surface(),
- GetRenderSurface(layer));
- ASSERT_TRUE(layer_iterator_->state() ==
- EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE);
+ ASSERT_EQ(EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE,
+ layer_iterator_->state());
+ ASSERT_EQ_WITH_IDS(GetRenderSurface(layer),
+ layer_iterator_->current_render_surface());
occlusion->LeaveLayer(*layer_iterator_);
++(*layer_iterator_);
}
@@ -268,30 +290,33 @@ class OcclusionTrackerTest : public testing::Test {
host_->SetRootLayer(scoped_refptr<Layer>(root));
}
- void SetRootLayerOnMainThread(LayerImpl* root) {}
-
void SetProperties(LayerImpl* layer,
+ LayerImpl* property_parent,
const gfx::Transform& transform,
- const gfx::PointF& position,
+ const gfx::PointF& offset_to_property_parent,
const gfx::Size& bounds) {
- layer->test_properties()->transform = transform;
- layer->test_properties()->position = position;
+ layer->SetElementId(LayerIdToElementIdForTesting(layer->id()));
layer->SetBounds(bounds);
- }
-
- void SetMask(LayerImpl* owning_layer, std::unique_ptr<LayerImpl> layer) {
- owning_layer->test_properties()->SetMaskLayer(std::move(layer));
+ CopyProperties(property_parent, layer);
+ gfx::Vector2dF offset_to_transform_parent =
+ property_parent->offset_to_transform_parent() +
+ offset_to_property_parent.OffsetFromOrigin();
+ if (transform.IsIdentity()) {
+ layer->SetOffsetToTransformParent(offset_to_transform_parent);
+ } else {
+ auto& transform_node = CreateTransformNode(layer);
+ transform_node.local = transform;
+ transform_node.post_translation = offset_to_transform_parent;
+ }
}
bool opaque_layers_;
FakeLayerTreeHostClient client_;
TestTaskGraphRunner task_graph_runner_;
+ std::unique_ptr<LayerTreeFrameSink> layer_tree_frame_sink_;
std::unique_ptr<AnimationHost> animation_host_;
std::unique_ptr<FakeLayerTreeHost> host_;
- // These hold ownership of the layers for the duration of the test.
- RenderSurfaceList render_surface_list_impl_;
std::unique_ptr<EffectTreeLayerListIterator> layer_iterator_;
- LayerList mask_layers_;
int next_layer_impl_id_;
};
@@ -318,20 +343,19 @@ class OcclusionTrackerTestIdentityTransforms : public OcclusionTrackerTest {
: OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- TestContentLayerImpl* root = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
+ TestContentLayerImpl* root = this->CreateRoot(gfx::Size(200, 200));
TestContentLayerImpl* parent = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true);
+ SetMasksToBounds(parent);
TestContentLayerImpl* layer = this->CreateDrawingLayer(
parent, this->identity_matrix, gfx::PointF(30.f, 30.f),
gfx::Size(500, 500), true);
- parent->SetMasksToBounds(true);
- this->CalcDrawEtc(root);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(layer, &occlusion);
- this->EnterLayer(parent, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(parent, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -352,20 +376,19 @@ class OcclusionTrackerTestRotatedChild : public OcclusionTrackerTest {
layer_transform.Rotate(90.0);
layer_transform.Translate(-250.0, -250.0);
- TestContentLayerImpl* root = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
+ TestContentLayerImpl* root = this->CreateRoot(gfx::Size(200, 200));
TestContentLayerImpl* parent = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true);
+ SetMasksToBounds(parent);
TestContentLayerImpl* layer = this->CreateDrawingLayer(
parent, layer_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500),
true);
- parent->SetMasksToBounds(true);
- this->CalcDrawEtc(root);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(layer, &occlusion);
- this->EnterLayer(parent, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(parent, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -384,20 +407,19 @@ class OcclusionTrackerTestTranslatedChild : public OcclusionTrackerTest {
gfx::Transform layer_transform;
layer_transform.Translate(20.0, 20.0);
- TestContentLayerImpl* root = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
+ TestContentLayerImpl* root = this->CreateRoot(gfx::Size(200, 200));
TestContentLayerImpl* parent = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true);
+ SetMasksToBounds(parent);
TestContentLayerImpl* layer = this->CreateDrawingLayer(
parent, layer_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500),
true);
- parent->SetMasksToBounds(true);
- this->CalcDrawEtc(root);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(layer, &occlusion);
- this->EnterLayer(parent, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(parent, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -418,29 +440,28 @@ class OcclusionTrackerTestChildInRotatedChild : public OcclusionTrackerTest {
child_transform.Rotate(90.0);
child_transform.Translate(-250.0, -250.0);
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(100, 100));
- parent->SetMasksToBounds(true);
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(100, 100));
+ SetMasksToBounds(parent);
LayerImpl* child = this->CreateSurface(
parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500));
- child->SetMasksToBounds(true);
+ SetMasksToBounds(child);
TestContentLayerImpl* layer = this->CreateDrawingLayer(
child, this->identity_matrix, gfx::PointF(10.f, 10.f),
gfx::Size(500, 500), true);
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(layer, &occlusion);
- this->EnterContributingSurface(child, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterContributingSurface(child, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(),
occlusion.occlusion_from_inside_target().ToString());
- this->LeaveContributingSurface(child, &occlusion);
- this->EnterLayer(parent, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->LeaveContributingSurface(child, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(parent, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -505,14 +526,12 @@ class OcclusionTrackerTestScaledRenderSurface : public OcclusionTrackerTest {
: OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(200, 200));
gfx::Transform layer1_matrix;
layer1_matrix.Scale(2.0, 2.0);
- TestContentLayerImpl* layer1 = this->CreateDrawingLayer(
+ TestContentLayerImpl* layer1 = this->CreateDrawingSurface(
parent, layer1_matrix, gfx::PointF(), gfx::Size(100, 100), true);
- layer1->test_properties()->force_render_surface = true;
gfx::Transform layer2_matrix;
layer2_matrix.Translate(25.0, 25.0);
@@ -521,12 +540,12 @@ class OcclusionTrackerTestScaledRenderSurface : public OcclusionTrackerTest {
TestContentLayerImpl* occluder = this->CreateDrawingLayer(
parent, this->identity_matrix, gfx::PointF(100.f, 100.f),
gfx::Size(500, 500), true);
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(occluder, &occlusion);
- this->EnterLayer(layer2, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(occluder, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(layer2, &occlusion));
EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -542,8 +561,7 @@ class OcclusionTrackerTestVisitTargetTwoTimes : public OcclusionTrackerTest {
explicit OcclusionTrackerTestVisitTargetTwoTimes(bool opaque_layers)
: OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- TestContentLayerImpl* root = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
+ TestContentLayerImpl* root = this->CreateRoot(gfx::Size(200, 200));
LayerImpl* surface = this->CreateSurface(
root, this->identity_matrix, gfx::PointF(30.f, 30.f), gfx::Size());
TestContentLayerImpl* surface_child = this->CreateDrawingLayer(
@@ -556,25 +574,26 @@ class OcclusionTrackerTestVisitTargetTwoTimes : public OcclusionTrackerTest {
TestContentLayerImpl* top_layer = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::PointF(40.f, 90.f), gfx::Size(50, 20),
true);
- this->CalcDrawEtc(root);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(top_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(top_layer, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
EXPECT_EQ(gfx::Rect(40, 90, 50, 20).ToString(),
occlusion.occlusion_from_inside_target().ToString());
- this->VisitLayer(surface_child, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(surface_child, &occlusion));
EXPECT_EQ(gfx::Rect(10, 60, 50, 20).ToString(),
occlusion.occlusion_from_outside_target().ToString());
EXPECT_EQ(gfx::Rect(10, 10, 50, 50).ToString(),
occlusion.occlusion_from_inside_target().ToString());
- this->EnterContributingSurface(surface, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(
+ this->EnterContributingSurface(surface, &occlusion));
EXPECT_EQ(gfx::Rect(10, 60, 50, 20).ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -583,8 +602,9 @@ class OcclusionTrackerTestVisitTargetTwoTimes : public OcclusionTrackerTest {
// Occlusion from |top_layer| already in the root target should get merged
// with the occlusion from the |surface| we are leaving now.
- this->LeaveContributingSurface(surface, &occlusion);
- this->EnterLayer(root, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(
+ this->LeaveContributingSurface(surface, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(root, &occlusion));
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
EXPECT_EQ(gfx::Rect(40, 40, 50, 70).ToString(),
@@ -607,31 +627,30 @@ class OcclusionTrackerTestSurfaceRotatedOffAxis : public OcclusionTrackerTest {
gfx::Transform layer_transform;
layer_transform.Translate(10.0, 10.0);
- TestContentLayerImpl* root = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(1000, 1000));
+ TestContentLayerImpl* root = this->CreateRoot(gfx::Size(1000, 1000));
TestContentLayerImpl* parent = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true);
LayerImpl* child = this->CreateSurface(
parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500));
TestContentLayerImpl* layer = this->CreateDrawingLayer(
child, layer_transform, gfx::PointF(), gfx::Size(500, 500), true);
- this->CalcDrawEtc(root);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
gfx::Rect clipped_layer_in_child = MathUtil::MapEnclosingClippedRect(
layer_transform, layer->visible_layer_rect());
- this->VisitLayer(layer, &occlusion);
- this->EnterContributingSurface(child, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterContributingSurface(child, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
EXPECT_EQ(clipped_layer_in_child.ToString(),
occlusion.occlusion_from_inside_target().ToString());
- this->LeaveContributingSurface(child, &occlusion);
- this->EnterLayer(parent, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->LeaveContributingSurface(child, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(parent, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -653,37 +672,36 @@ class OcclusionTrackerTestSurfaceWithTwoOpaqueChildren
child_transform.Rotate(90.0);
child_transform.Translate(-250.0, -250.0);
- TestContentLayerImpl* root = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(1000, 1000));
+ TestContentLayerImpl* root = this->CreateRoot(gfx::Size(1000, 1000));
TestContentLayerImpl* parent = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true);
- parent->SetMasksToBounds(true);
+ SetMasksToBounds(parent);
TestContentLayerImpl* child = this->CreateDrawingSurface(
parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500),
false);
- child->SetMasksToBounds(true);
+ SetMasksToBounds(child);
TestContentLayerImpl* layer1 = this->CreateDrawingLayer(
child, this->identity_matrix, gfx::PointF(10.f, 10.f),
gfx::Size(500, 500), true);
TestContentLayerImpl* layer2 = this->CreateDrawingLayer(
child, this->identity_matrix, gfx::PointF(10.f, 450.f),
gfx::Size(500, 60), true);
- this->CalcDrawEtc(root);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(layer2, &occlusion);
- this->VisitLayer(layer1, &occlusion);
- this->VisitLayer(child, &occlusion);
- this->EnterContributingSurface(child, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(layer2, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(layer1, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(child, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterContributingSurface(child, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(),
occlusion.occlusion_from_inside_target().ToString());
- this->LeaveContributingSurface(child, &occlusion);
- this->EnterLayer(parent, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->LeaveContributingSurface(child, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(parent, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -725,9 +743,8 @@ class OcclusionTrackerTestOverlappingSurfaceSiblings
explicit OcclusionTrackerTestOverlappingSurfaceSiblings(bool opaque_layers)
: OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(100, 100));
- parent->SetMasksToBounds(true);
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(100, 100));
+ SetMasksToBounds(parent);
LayerImpl* child1 = this->CreateSurface(
parent, this->identity_matrix, gfx::PointF(10.f, 0.f), gfx::Size());
LayerImpl* child2 = this->CreateSurface(
@@ -737,12 +754,12 @@ class OcclusionTrackerTestOverlappingSurfaceSiblings
TestContentLayerImpl* layer2 = this->CreateDrawingLayer(
child2, this->identity_matrix, gfx::PointF(10.f, 0.f),
gfx::Size(40, 50), true);
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(layer2, &occlusion);
- this->EnterContributingSurface(child2, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(layer2, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterContributingSurface(child2, &occlusion));
// layer2's occlusion.
EXPECT_EQ(gfx::Rect().ToString(),
@@ -750,9 +767,9 @@ class OcclusionTrackerTestOverlappingSurfaceSiblings
EXPECT_EQ(gfx::Rect(10, 0, 40, 50).ToString(),
occlusion.occlusion_from_inside_target().ToString());
- this->LeaveContributingSurface(child2, &occlusion);
- this->VisitLayer(layer1, &occlusion);
- this->EnterContributingSurface(child1, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->LeaveContributingSurface(child2, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(layer1, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterContributingSurface(child1, &occlusion));
// layer2's occlusion in the target space of layer1.
EXPECT_EQ(gfx::Rect(30, 0, 40, 50).ToString(),
@@ -761,8 +778,8 @@ class OcclusionTrackerTestOverlappingSurfaceSiblings
EXPECT_EQ(gfx::Rect(0, 0, 40, 50).ToString(),
occlusion.occlusion_from_inside_target().ToString());
- this->LeaveContributingSurface(child1, &occlusion);
- this->EnterLayer(parent, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->LeaveContributingSurface(child1, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(parent, &occlusion));
// The occlusion from from layer1 and layer2 is merged.
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
@@ -790,51 +807,50 @@ class OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms
child2_transform.Rotate(90.0);
child2_transform.Translate(-250.0, -250.0);
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(100, 100));
- parent->SetMasksToBounds(true);
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(100, 100));
+ SetMasksToBounds(parent);
LayerImpl* child1 = this->CreateSurface(
parent, child1_transform, gfx::PointF(30.f, 20.f), gfx::Size(10, 10));
- LayerImpl* child2 = this->CreateDrawingSurface(parent, child2_transform,
- gfx::PointF(20.f, 40.f),
- gfx::Size(10, 10), false);
TestContentLayerImpl* layer1 = this->CreateDrawingLayer(
child1, this->identity_matrix, gfx::PointF(-10.f, -20.f),
gfx::Size(510, 510), true);
+ LayerImpl* child2 = this->CreateDrawingSurface(parent, child2_transform,
+ gfx::PointF(20.f, 40.f),
+ gfx::Size(10, 10), false);
TestContentLayerImpl* layer2 = this->CreateDrawingLayer(
child2, this->identity_matrix, gfx::PointF(-10.f, -10.f),
gfx::Size(510, 510), true);
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(layer2, &occlusion);
- this->EnterLayer(child2, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(layer2, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(child2, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(),
occlusion.occlusion_from_inside_target().ToString());
- this->LeaveLayer(child2, &occlusion);
- this->EnterContributingSurface(child2, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->LeaveLayer(child2, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterContributingSurface(child2, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(),
occlusion.occlusion_from_inside_target().ToString());
- this->LeaveContributingSurface(child2, &occlusion);
- this->VisitLayer(layer1, &occlusion);
- this->EnterContributingSurface(child1, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->LeaveContributingSurface(child2, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(layer1, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterContributingSurface(child1, &occlusion));
EXPECT_EQ(gfx::Rect(420, -10, 70, 80).ToString(),
occlusion.occlusion_from_outside_target().ToString());
EXPECT_EQ(gfx::Rect(420, -20, 80, 90).ToString(),
occlusion.occlusion_from_inside_target().ToString());
- this->LeaveContributingSurface(child1, &occlusion);
- this->EnterLayer(parent, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->LeaveContributingSurface(child1, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(parent, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -880,16 +896,15 @@ class OcclusionTrackerTestFilters : public OcclusionTrackerTest {
layer_transform.Rotate(90.0);
layer_transform.Translate(-250.0, -250.0);
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(100, 100));
- parent->SetMasksToBounds(true);
- TestContentLayerImpl* blur_layer = this->CreateDrawingLayer(
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(100, 100));
+ SetMasksToBounds(parent);
+ TestContentLayerImpl* blur_layer = this->CreateDrawingSurface(
parent, layer_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500),
true);
- TestContentLayerImpl* opaque_layer = this->CreateDrawingLayer(
+ TestContentLayerImpl* opaque_layer = this->CreateDrawingSurface(
parent, layer_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500),
true);
- TestContentLayerImpl* opacity_layer = this->CreateDrawingLayer(
+ TestContentLayerImpl* opacity_layer = this->CreateDrawingSurface(
parent, layer_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500),
true);
@@ -898,75 +913,82 @@ class OcclusionTrackerTestFilters : public OcclusionTrackerTest {
parent, rounded_corner_transform, gfx::PointF(30.f, 30.f),
gfx::Size(500, 500), true);
- blur_layer->test_properties()->force_render_surface = true;
FilterOperations filters;
filters.Append(FilterOperation::CreateBlurFilter(10.f));
- blur_layer->test_properties()->filters = filters;
+ GetEffectNode(blur_layer)->filters = filters;
- opaque_layer->test_properties()->force_render_surface = true;
filters.Clear();
filters.Append(FilterOperation::CreateGrayscaleFilter(0.5f));
- opaque_layer->test_properties()->filters = filters;
+ GetEffectNode(opaque_layer)->filters = filters;
- opacity_layer->test_properties()->force_render_surface = true;
filters.Clear();
filters.Append(FilterOperation::CreateOpacityFilter(0.5f));
- opacity_layer->test_properties()->filters = filters;
+ GetEffectNode(opacity_layer)->filters = filters;
- rounded_corner_layer->test_properties()->rounded_corner_bounds =
+ CreateEffectNode(rounded_corner_layer).rounded_corner_bounds =
gfx::RRectF(1, 2, 3, 4, 5, 6);
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
+ EXPECT_TRUE(rounded_corner_layer->contributes_to_drawn_render_surface());
+ EXPECT_TRUE(blur_layer->contributes_to_drawn_render_surface());
+ EXPECT_TRUE(opaque_layer->contributes_to_drawn_render_surface());
+ EXPECT_TRUE(opacity_layer->contributes_to_drawn_render_surface());
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
// Rounded corners won't contribute to occlusion.
- this->EnterLayer(rounded_corner_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(rounded_corner_layer, &occlusion));
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
- this->LeaveLayer(rounded_corner_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->LeaveLayer(rounded_corner_layer, &occlusion));
// Opacity layer won't contribute to occlusion.
- this->VisitLayer(opacity_layer, &occlusion);
- this->EnterContributingSurface(opacity_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(opacity_layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(
+ this->EnterContributingSurface(opacity_layer, &occlusion));
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
// And has nothing to contribute to its parent surface.
- this->LeaveContributingSurface(opacity_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(
+ this->LeaveContributingSurface(opacity_layer, &occlusion));
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
// Opaque layer will contribute to occlusion.
- this->VisitLayer(opaque_layer, &occlusion);
- this->EnterContributingSurface(opaque_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(opaque_layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(
+ this->EnterContributingSurface(opaque_layer, &occlusion));
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
EXPECT_EQ(gfx::Rect(0, 430, 70, 70).ToString(),
occlusion.occlusion_from_inside_target().ToString());
// And it gets translated to the parent surface.
- this->LeaveContributingSurface(opaque_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(
+ this->LeaveContributingSurface(opaque_layer, &occlusion));
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(),
occlusion.occlusion_from_inside_target().ToString());
// The blur layer needs to throw away any occlusion from outside its
// subtree.
- this->EnterLayer(blur_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(blur_layer, &occlusion));
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
// And it won't contribute to occlusion.
- this->LeaveLayer(blur_layer, &occlusion);
- this->EnterContributingSurface(blur_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->LeaveLayer(blur_layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(
+ this->EnterContributingSurface(blur_layer, &occlusion));
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
// But the opaque layer's occlusion is preserved on the parent.
- this->LeaveContributingSurface(blur_layer, &occlusion);
- this->EnterLayer(parent, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(
+ this->LeaveContributingSurface(blur_layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(parent, &occlusion));
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(),
occlusion.occlusion_from_inside_target().ToString());
@@ -981,22 +1003,21 @@ class OcclusionTrackerTestOpaqueContentsRegionEmpty
explicit OcclusionTrackerTestOpaqueContentsRegionEmpty(bool opaque_layers)
: OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(300, 300));
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(300, 300));
TestContentLayerImpl* layer =
this->CreateDrawingSurface(parent, this->identity_matrix, gfx::PointF(),
gfx::Size(200, 200), false);
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->EnterLayer(layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(layer, &occlusion));
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
- this->LeaveLayer(layer, &occlusion);
- this->VisitContributingSurface(layer, &occlusion);
- this->EnterLayer(parent, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->LeaveLayer(layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->VisitContributingSurface(layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(parent, &occlusion));
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
@@ -1011,19 +1032,18 @@ class OcclusionTrackerTestOpaqueContentsRegionNonEmpty
explicit OcclusionTrackerTestOpaqueContentsRegionNonEmpty(bool opaque_layers)
: OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(300, 300));
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(300, 300));
TestContentLayerImpl* layer = this->CreateDrawingLayer(
parent, this->identity_matrix, gfx::PointF(100.f, 100.f),
gfx::Size(200, 200), false);
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
{
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
layer->SetOpaqueContentsRect(gfx::Rect(0, 0, 100, 100));
this->ResetLayerIterator();
- this->VisitLayer(layer, &occlusion);
- this->EnterLayer(parent, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(parent, &occlusion));
EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(),
occlusion.occlusion_from_inside_target().ToString());
@@ -1033,8 +1053,8 @@ class OcclusionTrackerTestOpaqueContentsRegionNonEmpty
layer->SetOpaqueContentsRect(gfx::Rect(20, 20, 180, 180));
this->ResetLayerIterator();
- this->VisitLayer(layer, &occlusion);
- this->EnterLayer(parent, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(parent, &occlusion));
EXPECT_EQ(gfx::Rect(120, 120, 180, 180).ToString(),
occlusion.occlusion_from_inside_target().ToString());
@@ -1044,8 +1064,8 @@ class OcclusionTrackerTestOpaqueContentsRegionNonEmpty
layer->SetOpaqueContentsRect(gfx::Rect(150, 150, 100, 100));
this->ResetLayerIterator();
- this->VisitLayer(layer, &occlusion);
- this->EnterLayer(parent, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(parent, &occlusion));
EXPECT_EQ(gfx::Rect(250, 250, 50, 50).ToString(),
occlusion.occlusion_from_inside_target().ToString());
@@ -1068,21 +1088,20 @@ class OcclusionTrackerTestLayerBehindCameraDoesNotOcclude
transform.Translate3d(0.0, 0.0, 110.0);
transform.Translate(-50.0, -50.0);
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(100, 100));
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(100, 100));
TestContentLayerImpl* layer = this->CreateDrawingLayer(
parent, transform, gfx::PointF(), gfx::Size(100, 100), true);
- parent->test_properties()->should_flatten_transform = false;
- parent->test_properties()->sorting_context_id = 1;
- layer->test_properties()->should_flatten_transform = false;
- layer->test_properties()->sorting_context_id = 1;
- this->CalcDrawEtc(parent);
+ GetTransformNode(parent)->flattens_inherited_transform = false;
+ GetTransformNode(parent)->sorting_context_id = 1;
+ GetTransformNode(layer)->flattens_inherited_transform = false;
+ GetTransformNode(layer)->sorting_context_id = 1;
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
// The |layer| is entirely behind the camera and should not occlude.
- this->VisitLayer(layer, &occlusion);
- this->EnterLayer(parent, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(parent, &occlusion));
EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
}
@@ -1100,8 +1119,7 @@ class OcclusionTrackerTestSurfaceOcclusionTranslatesToParent
surface_transform.Scale(2.0, 2.0);
surface_transform.Translate(-150.0, -150.0);
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(500, 500));
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(500, 500));
TestContentLayerImpl* surface = this->CreateDrawingSurface(
parent, surface_transform, gfx::PointF(), gfx::Size(300, 300), false);
TestContentLayerImpl* surface2 = this->CreateDrawingSurface(
@@ -1109,12 +1127,13 @@ class OcclusionTrackerTestSurfaceOcclusionTranslatesToParent
gfx::Size(300, 300), false);
surface->SetOpaqueContentsRect(gfx::Rect(0, 0, 200, 200));
surface2->SetOpaqueContentsRect(gfx::Rect(0, 0, 200, 200));
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(surface2, &occlusion);
- this->VisitContributingSurface(surface2, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(surface2, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(
+ this->VisitContributingSurface(surface2, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -1125,8 +1144,9 @@ class OcclusionTrackerTestSurfaceOcclusionTranslatesToParent
occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion());
occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion());
- this->VisitLayer(surface, &occlusion);
- this->VisitContributingSurface(surface, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(surface, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(
+ this->VisitContributingSurface(surface, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -1145,19 +1165,19 @@ class OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping
bool opaque_layers)
: OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(300, 300));
- parent->SetMasksToBounds(true);
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(300, 300));
+ SetMasksToBounds(parent);
TestContentLayerImpl* surface =
this->CreateDrawingSurface(parent, this->identity_matrix, gfx::PointF(),
gfx::Size(500, 300), false);
surface->SetOpaqueContentsRect(gfx::Rect(0, 0, 400, 200));
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(surface, &occlusion);
- this->VisitContributingSurface(surface, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(surface, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(
+ this->VisitContributingSurface(surface, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -1177,8 +1197,7 @@ class OcclusionTrackerTestSurfaceChildOfSurface : public OcclusionTrackerTest {
// This test verifies that the surface cliprect does not end up empty and
// clip away the entire unoccluded rect.
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(100, 200));
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(100, 200));
LayerImpl* surface =
this->CreateDrawingSurface(parent, this->identity_matrix, gfx::PointF(),
gfx::Size(100, 100), false);
@@ -1187,20 +1206,20 @@ class OcclusionTrackerTestSurfaceChildOfSurface : public OcclusionTrackerTest {
gfx::Size(100, 50), true);
LayerImpl* topmost = this->CreateDrawingLayer(
parent, this->identity_matrix, gfx::PointF(), gfx::Size(100, 50), true);
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(-100, -100, 1000, 1000));
// |topmost| occludes everything partially so we know occlusion is happening
// at all.
- this->VisitLayer(topmost, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(topmost, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(),
occlusion.occlusion_from_inside_target().ToString());
- this->VisitLayer(surface_child, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(surface_child, &occlusion));
// surface_child increases the occlusion in the screen by a narrow sliver.
EXPECT_EQ(gfx::Rect(0, -10, 100, 50).ToString(),
@@ -1215,7 +1234,8 @@ class OcclusionTrackerTestSurfaceChildOfSurface : public OcclusionTrackerTest {
// |surface_child| exercises different code paths as its parent does not
// have a clip rect.
- this->EnterContributingSurface(surface_child, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(
+ this->EnterContributingSurface(surface_child, &occlusion));
// The |surface_child| can't occlude its own surface, but occlusion from
// |topmost| can.
EXPECT_EQ(gfx::Rect().ToString(),
@@ -1224,18 +1244,20 @@ class OcclusionTrackerTestSurfaceChildOfSurface : public OcclusionTrackerTest {
EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(),
occlusion.occlusion_on_contributing_surface_from_inside_target()
.ToString());
- this->LeaveContributingSurface(surface_child, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(
+ this->LeaveContributingSurface(surface_child, &occlusion));
// When the surface_child's occlusion is transformed up to its parent, make
// sure it is not clipped away inappropriately.
- this->EnterLayer(surface, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(surface, &occlusion));
EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(),
occlusion.occlusion_from_outside_target().ToString());
EXPECT_EQ(gfx::Rect(0, 10, 100, 50).ToString(),
occlusion.occlusion_from_inside_target().ToString());
- this->LeaveLayer(surface, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->LeaveLayer(surface, &occlusion));
- this->EnterContributingSurface(surface, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(
+ this->EnterContributingSurface(surface, &occlusion));
// The occlusion from inside |surface| can't affect the surface, but
// |topmost| can.
EXPECT_EQ(gfx::Rect().ToString(),
@@ -1245,8 +1267,9 @@ class OcclusionTrackerTestSurfaceChildOfSurface : public OcclusionTrackerTest {
occlusion.occlusion_on_contributing_surface_from_inside_target()
.ToString());
- this->LeaveContributingSurface(surface, &occlusion);
- this->EnterLayer(parent, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(
+ this->LeaveContributingSurface(surface, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(parent, &occlusion));
// The occlusion in |surface| and without are merged into the parent.
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -1285,12 +1308,11 @@ class OcclusionTrackerTestDontOccludePixelsNeededForBackdropFilter
// which are above it in the z-order in various configurations. The
// surface is scaled to test that the pixel moving is done in the target
// space, where the backdrop filter is applied.
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
- LayerImpl* filtered_surface = this->CreateDrawingLayer(
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(200, 200));
+ LayerImpl* filtered_surface = this->CreateDrawingSurface(
parent, scale_by_half, gfx::PointF(50.f, 50.f), gfx::Size(100, 100),
false);
- filtered_surface->test_properties()->backdrop_filters = filters;
+ GetEffectNode(filtered_surface)->backdrop_filters = filters;
gfx::Rect occlusion_rect;
switch (i) {
case LEFT:
@@ -1312,21 +1334,20 @@ class OcclusionTrackerTestDontOccludePixelsNeededForBackdropFilter
LayerImpl* occluding_layer = this->CreateDrawingLayer(
parent, this->identity_matrix, gfx::PointF(occlusion_rect.origin()),
occlusion_rect.size(), true);
- occluding_layer->test_properties()->force_render_surface = false;
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200));
// This layer occludes pixels directly beside the filtered_surface.
// Because filtered surface blends pixels in a radius, it will need to see
// some of the pixels (up to radius far) underneath the occluding layers.
- this->VisitLayer(occluding_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(occluding_layer, &occlusion));
EXPECT_EQ(occlusion_rect.ToString(),
occlusion.occlusion_from_inside_target().ToString());
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
- this->VisitLayer(filtered_surface, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(filtered_surface, &occlusion));
// The occlusion is used fully inside the surface.
gfx::Rect occlusion_inside_surface =
@@ -1339,8 +1360,9 @@ class OcclusionTrackerTestDontOccludePixelsNeededForBackdropFilter
// currently considered occluded in order to be drawn. The pixels it
// needs should be removed from the occluded area, so that they are drawn
// when we get to the parent.
- this->VisitContributingSurface(filtered_surface, &occlusion);
- this->EnterLayer(parent, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(
+ this->VisitContributingSurface(filtered_surface, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(parent, &occlusion));
// The spread due to a 10px blur is 30px.
gfx::Rect expected_occlusion = occlusion_rect;
@@ -1400,12 +1422,11 @@ class OcclusionTrackerTestPixelsNeededForDropShadowBackdropFilter
// which are above it in the z-order in various configurations. The
// surface is scaled to test that the pixel moving is done in the target
// space, where the backdrop filter is applied.
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
- LayerImpl* filtered_surface = this->CreateDrawingLayer(
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(200, 200));
+ LayerImpl* filtered_surface = this->CreateDrawingSurface(
parent, scale_by_half, gfx::PointF(50.f, 50.f), gfx::Size(100, 100),
false);
- filtered_surface->test_properties()->backdrop_filters = filters;
+ GetEffectNode(filtered_surface)->backdrop_filters = filters;
gfx::Rect occlusion_rect;
switch (i) {
case LEFT:
@@ -1427,21 +1448,20 @@ class OcclusionTrackerTestPixelsNeededForDropShadowBackdropFilter
LayerImpl* occluding_layer = this->CreateDrawingLayer(
parent, this->identity_matrix, gfx::PointF(occlusion_rect.origin()),
occlusion_rect.size(), true);
- occluding_layer->test_properties()->force_render_surface = false;
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200));
// This layer occludes pixels directly beside the filtered_surface.
// Because filtered surface blends pixels in a radius, it will need to see
// some of the pixels (up to radius far) underneath the occluding layers.
- this->VisitLayer(occluding_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(occluding_layer, &occlusion));
EXPECT_EQ(occlusion_rect.ToString(),
occlusion.occlusion_from_inside_target().ToString());
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
- this->VisitLayer(filtered_surface, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(filtered_surface, &occlusion));
// The occlusion is used fully inside the surface.
gfx::Rect occlusion_inside_surface =
@@ -1454,8 +1474,9 @@ class OcclusionTrackerTestPixelsNeededForDropShadowBackdropFilter
// currently considered occluded in order to be drawn. The pixels it
// needs should be removed from the occluded area, so that they are drawn
// when we get to the parent.
- this->VisitContributingSurface(filtered_surface, &occlusion);
- this->EnterLayer(parent, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(
+ this->VisitContributingSurface(filtered_surface, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(parent, &occlusion));
gfx::Rect expected_occlusion;
switch (i) {
@@ -1504,41 +1525,41 @@ class OcclusionTrackerTestTwoBackdropFiltersReduceOcclusionTwice
// Makes two surfaces that completely cover |parent|. The occlusion both
// above and below the filters will be reduced by each of them.
- TestContentLayerImpl* root = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(75, 75));
+ TestContentLayerImpl* root = this->CreateRoot(gfx::Size(75, 75));
LayerImpl* parent = this->CreateSurface(root, scale_by_half, gfx::PointF(),
gfx::Size(150, 150));
- parent->SetMasksToBounds(true);
- LayerImpl* filtered_surface1 = this->CreateDrawingLayer(
+ SetMasksToBounds(parent);
+ LayerImpl* filtered_surface1 = this->CreateDrawingSurface(
parent, scale_by_half, gfx::PointF(), gfx::Size(300, 300), false);
- LayerImpl* filtered_surface2 = this->CreateDrawingLayer(
+ LayerImpl* filtered_surface2 = this->CreateDrawingSurface(
parent, scale_by_half, gfx::PointF(), gfx::Size(300, 300), false);
LayerImpl* occluding_layer_above = this->CreateDrawingLayer(
parent, this->identity_matrix, gfx::PointF(100.f, 100.f),
gfx::Size(50, 50), true);
// Filters make the layers own surfaces.
- filtered_surface1->test_properties()->force_render_surface = true;
- filtered_surface2->test_properties()->force_render_surface = true;
FilterOperations filters;
filters.Append(FilterOperation::CreateBlurFilter(1.f));
- filtered_surface1->test_properties()->backdrop_filters = filters;
- filtered_surface2->test_properties()->backdrop_filters = filters;
+ GetEffectNode(filtered_surface1)->backdrop_filters = filters;
+ GetEffectNode(filtered_surface2)->backdrop_filters = filters;
- this->CalcDrawEtc(root);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(occluding_layer_above, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(
+ this->VisitLayer(occluding_layer_above, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
EXPECT_EQ(gfx::Rect(100 / 2, 100 / 2, 50 / 2, 50 / 2).ToString(),
occlusion.occlusion_from_inside_target().ToString());
- this->VisitLayer(filtered_surface2, &occlusion);
- this->VisitContributingSurface(filtered_surface2, &occlusion);
- this->VisitLayer(filtered_surface1, &occlusion);
- this->VisitContributingSurface(filtered_surface1, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(filtered_surface2, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(
+ this->VisitContributingSurface(filtered_surface2, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(filtered_surface1, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(
+ this->VisitContributingSurface(filtered_surface1, &occlusion));
// Test expectations in the target.
int blur_outset = 3;
@@ -1572,29 +1593,28 @@ class OcclusionTrackerTestDontReduceOcclusionBelowBackdropFilter
// The surface is scaled to test that the pixel moving is done in the target
// space, where the backdrop filter is applied, and the surface appears at
// 50, 50.
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(300, 150));
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(300, 150));
LayerImpl* behind_surface_layer = this->CreateDrawingLayer(
parent, this->identity_matrix, gfx::PointF(60.f, 60.f),
gfx::Size(30, 30), true);
- LayerImpl* filtered_surface =
- this->CreateDrawingLayer(parent, scale_by_half, gfx::PointF(50.f, 50.f),
- gfx::Size(100, 100), false);
+ LayerImpl* filtered_surface = this->CreateDrawingSurface(
+ parent, scale_by_half, gfx::PointF(50.f, 50.f), gfx::Size(100, 100),
+ false);
// Filters make the layer own a surface.
- filtered_surface->test_properties()->force_render_surface = true;
FilterOperations filters;
filters.Append(FilterOperation::CreateBlurFilter(3.f));
- filtered_surface->test_properties()->backdrop_filters = filters;
+ GetEffectNode(filtered_surface)->backdrop_filters = filters;
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
// The surface has a backdrop blur, so it blurs non-opaque pixels below
// it.
- this->VisitLayer(filtered_surface, &occlusion);
- this->VisitContributingSurface(filtered_surface, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(filtered_surface, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(
+ this->VisitContributingSurface(filtered_surface, &occlusion));
// The layers behind the surface are not blurred, and their occlusion does
// not change, until we leave the surface. So it should not be modified by
@@ -1605,7 +1625,7 @@ class OcclusionTrackerTestDontReduceOcclusionBelowBackdropFilter
// without existing occlusion interfering.
occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion());
- this->VisitLayer(behind_surface_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(behind_surface_layer, &occlusion));
// The layers behind the surface are not blurred, and their occlusion does
// not change, until we leave the surface. So it should not be modified by
@@ -1634,28 +1654,26 @@ class OcclusionTrackerTestDontReduceOcclusionIfBackdropFilterIsOccluded
// layer which is above it in the z-order. The surface is
// scaled to test that the pixel moving is done in the target space, where
// the backdrop filter is applied, and the surface appears at 50, 50.
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(200, 150));
- LayerImpl* filtered_surface =
- this->CreateDrawingLayer(parent, scale_by_half, gfx::PointF(50.f, 50.f),
- gfx::Size(100, 100), false);
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(200, 150));
+ LayerImpl* filtered_surface = this->CreateDrawingSurface(
+ parent, scale_by_half, gfx::PointF(50.f, 50.f), gfx::Size(100, 100),
+ false);
LayerImpl* occluding_layer = this->CreateDrawingLayer(
parent, this->identity_matrix, gfx::PointF(50.f, 50.f),
gfx::Size(50, 50), true);
// Filters make the layer own a surface.
- filtered_surface->test_properties()->force_render_surface = true;
FilterOperations filters;
filters.Append(FilterOperation::CreateBlurFilter(3.f));
- filtered_surface->test_properties()->backdrop_filters = filters;
+ GetEffectNode(filtered_surface)->backdrop_filters = filters;
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(occluding_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(occluding_layer, &occlusion));
- this->VisitLayer(filtered_surface, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(filtered_surface, &occlusion));
{
// The layers above the filtered surface occlude from outside.
gfx::Rect occlusion_above_surface = gfx::Rect(0, 0, 50, 50);
@@ -1668,7 +1686,8 @@ class OcclusionTrackerTestDontReduceOcclusionIfBackdropFilterIsOccluded
// The surface has a backdrop blur, so it blurs non-opaque pixels below
// it.
- this->VisitContributingSurface(filtered_surface, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(
+ this->VisitContributingSurface(filtered_surface, &occlusion));
{
// The filter is completely occluded, so it should not blur anything and
// reduce any occlusion.
@@ -1699,11 +1718,10 @@ class OcclusionTrackerTestReduceOcclusionWhenBkgdFilterIsPartiallyOccluded
// are above it in the z-order. The surface is scaled to test that the
// pixel moving is done in the target space, where the backdrop filter is
// applied, but the surface appears at 50, 50.
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(300, 150));
- LayerImpl* filtered_surface =
- this->CreateDrawingLayer(parent, scale_by_half, gfx::PointF(50.f, 50.f),
- gfx::Size(100, 100), false);
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(300, 150));
+ LayerImpl* filtered_surface = this->CreateDrawingSurface(
+ parent, scale_by_half, gfx::PointF(50.f, 50.f), gfx::Size(100, 100),
+ false);
LayerImpl* above_surface_layer = this->CreateDrawingLayer(
parent, this->identity_matrix, gfx::PointF(70.f, 50.f),
gfx::Size(30, 50), true);
@@ -1712,22 +1730,22 @@ class OcclusionTrackerTestReduceOcclusionWhenBkgdFilterIsPartiallyOccluded
gfx::Size(10, 10), true);
// Filters make the layer own a surface.
- filtered_surface->test_properties()->force_render_surface = true;
FilterOperations filters;
filters.Append(FilterOperation::CreateBlurFilter(3.f));
- filtered_surface->test_properties()->backdrop_filters = filters;
+ GetEffectNode(filtered_surface)->backdrop_filters = filters;
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(beside_surface_layer, &occlusion);
- this->VisitLayer(above_surface_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(beside_surface_layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(above_surface_layer, &occlusion));
// The surface has a backdrop blur, so it blurs non-opaque pixels below
// it.
- this->VisitLayer(filtered_surface, &occlusion);
- this->VisitContributingSurface(filtered_surface, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(filtered_surface, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(
+ this->VisitContributingSurface(filtered_surface, &occlusion));
// The filter in the surface is partially unoccluded. Only the unoccluded
// parts should reduce occlusion. This means it will push back the
@@ -1766,9 +1784,8 @@ class OcclusionTrackerTestBlendModeDoesNotOcclude
explicit OcclusionTrackerTestBlendModeDoesNotOcclude(bool opaque_layers)
: OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(100, 100));
- LayerImpl* blend_mode_layer = this->CreateDrawingLayer(
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(100, 100));
+ LayerImpl* blend_mode_layer = this->CreateDrawingSurface(
parent, this->identity_matrix, gfx::PointF(0.f, 0.f),
gfx::Size(100, 100), true);
LayerImpl* top_layer = this->CreateDrawingLayer(
@@ -1776,20 +1793,19 @@ class OcclusionTrackerTestBlendModeDoesNotOcclude
gfx::Size(20, 22), true);
// Blend mode makes the layer own a surface.
- blend_mode_layer->test_properties()->force_render_surface = true;
- blend_mode_layer->test_properties()->blend_mode = SkBlendMode::kMultiply;
+ GetEffectNode(blend_mode_layer)->blend_mode = SkBlendMode::kMultiply;
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(top_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(top_layer, &occlusion));
// |top_layer| occludes.
EXPECT_EQ(gfx::Rect(10, 12, 20, 22).ToString(),
occlusion.occlusion_from_inside_target().ToString());
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
- this->VisitLayer(blend_mode_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(blend_mode_layer, &occlusion));
// |top_layer| and |blend_mode_layer| both occlude, since the blend mode
// gets applied by blend_mode_layer's render surface, not when drawing the
// layer itself.
@@ -1798,7 +1814,8 @@ class OcclusionTrackerTestBlendModeDoesNotOcclude
EXPECT_EQ(gfx::Rect(10, 12, 20, 22).ToString(),
occlusion.occlusion_from_outside_target().ToString());
- this->VisitContributingSurface(blend_mode_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(
+ this->VisitContributingSurface(blend_mode_layer, &occlusion));
// |top_layer| occludes but not |blend_mode_layer|.
EXPECT_EQ(gfx::Rect(10, 12, 20, 22).ToString(),
occlusion.occlusion_from_inside_target().ToString());
@@ -1816,20 +1833,19 @@ class OcclusionTrackerTestMinimumTrackingSize : public OcclusionTrackerTest {
gfx::Size tracking_size(100, 100);
gfx::Size below_tracking_size(99, 99);
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(400, 400));
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(400, 400));
LayerImpl* large = this->CreateDrawingLayer(
parent, this->identity_matrix, gfx::PointF(), tracking_size, true);
LayerImpl* small =
this->CreateDrawingLayer(parent, this->identity_matrix, gfx::PointF(),
below_tracking_size, true);
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
occlusion.set_minimum_tracking_size(tracking_size);
// The small layer is not tracked because it is too small.
- this->VisitLayer(small, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(small, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -1837,7 +1853,7 @@ class OcclusionTrackerTestMinimumTrackingSize : public OcclusionTrackerTest {
occlusion.occlusion_from_inside_target().ToString());
// The large layer is tracked as it is large enough.
- this->VisitLayer(large, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(large, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -1856,21 +1872,20 @@ class OcclusionTrackerTestScaledLayerIsClipped : public OcclusionTrackerTest {
gfx::Transform scale_transform;
scale_transform.Scale(512.0, 512.0);
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(400, 400));
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(400, 400));
LayerImpl* clip =
this->CreateLayer(parent, this->identity_matrix,
gfx::PointF(10.f, 10.f), gfx::Size(50, 50));
- clip->SetMasksToBounds(true);
+ SetMasksToBounds(clip);
LayerImpl* scale = this->CreateLayer(clip, scale_transform, gfx::PointF(),
gfx::Size(1, 1));
LayerImpl* scaled = this->CreateDrawingLayer(
scale, this->identity_matrix, gfx::PointF(), gfx::Size(500, 500), true);
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(scaled, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(scaled, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -1890,25 +1905,25 @@ class OcclusionTrackerTestScaledLayerInSurfaceIsClipped
gfx::Transform scale_transform;
scale_transform.Scale(512.0, 512.0);
- TestContentLayerImpl* parent = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(400, 400));
+ TestContentLayerImpl* parent = this->CreateRoot(gfx::Size(400, 400));
LayerImpl* clip =
this->CreateLayer(parent, this->identity_matrix,
gfx::PointF(10.f, 10.f), gfx::Size(50, 50));
- clip->SetMasksToBounds(true);
+ SetMasksToBounds(clip);
LayerImpl* surface = this->CreateDrawingSurface(
clip, this->identity_matrix, gfx::PointF(), gfx::Size(400, 30), false);
LayerImpl* scale = this->CreateLayer(surface, scale_transform,
gfx::PointF(), gfx::Size(1, 1));
LayerImpl* scaled = this->CreateDrawingLayer(
scale, this->identity_matrix, gfx::PointF(), gfx::Size(500, 500), true);
- this->CalcDrawEtc(parent);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(scaled, &occlusion);
- this->VisitLayer(surface, &occlusion);
- this->VisitContributingSurface(surface, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(scaled, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(surface, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(
+ this->VisitContributingSurface(surface, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -1924,30 +1939,28 @@ class OcclusionTrackerTestCopyRequestDoesOcclude : public OcclusionTrackerTest {
explicit OcclusionTrackerTestCopyRequestDoesOcclude(bool opaque_layers)
: OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- TestContentLayerImpl* root = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(400, 400));
+ TestContentLayerImpl* root = this->CreateRoot(gfx::Size(400, 400));
TestContentLayerImpl* parent = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::PointF(), gfx::Size(400, 400), true);
LayerImpl* copy =
- this->CreateLayer(parent, this->identity_matrix, gfx::PointF(100, 0),
- gfx::Size(200, 400));
- this->AddCopyRequest(copy);
+ this->CreateCopyLayer(parent, this->identity_matrix,
+ gfx::PointF(100, 0), gfx::Size(200, 400));
LayerImpl* copy_child = this->CreateDrawingLayer(
copy, this->identity_matrix, gfx::PointF(), gfx::Size(200, 400), true);
LayerImpl* top_layer =
this->CreateDrawingLayer(root, this->identity_matrix,
gfx::PointF(50, 0), gfx::Size(50, 400), true);
- this->CalcDrawEtc(root);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(top_layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(top_layer, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
EXPECT_EQ(gfx::Rect(50, 0, 50, 400).ToString(),
occlusion.occlusion_from_inside_target().ToString());
- this->VisitLayer(copy_child, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(copy_child, &occlusion));
// Layers outside the copy request do not occlude.
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
@@ -1955,7 +1968,7 @@ class OcclusionTrackerTestCopyRequestDoesOcclude : public OcclusionTrackerTest {
occlusion.occlusion_from_inside_target().ToString());
// CopyRequests cause the layer to own a surface.
- this->VisitContributingSurface(copy, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitContributingSurface(copy, &occlusion));
// The occlusion from the copy should be kept.
EXPECT_EQ(gfx::Rect().ToString(),
@@ -1974,35 +1987,32 @@ class OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude
bool opaque_layers)
: OcclusionTrackerTest(opaque_layers) {}
void RunMyTest() override {
- TestContentLayerImpl* root = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(400, 400));
+ TestContentLayerImpl* root = this->CreateRoot(gfx::Size(400, 400));
TestContentLayerImpl* parent = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::PointF(), gfx::Size(400, 400), true);
LayerImpl* hide = this->CreateLayer(parent, this->identity_matrix,
gfx::PointF(), gfx::Size());
+ // The |copy| layer is hidden but since it is being copied, it will be
+ // drawn.
+ CreateEffectNode(hide).opacity = 0.f;
LayerImpl* copy =
- this->CreateLayer(hide, this->identity_matrix, gfx::PointF(100.f, 0.f),
- gfx::Size(200, 400));
- this->AddCopyRequest(copy);
+ this->CreateCopyLayer(hide, this->identity_matrix,
+ gfx::PointF(100.f, 0.f), gfx::Size(200, 400));
LayerImpl* copy_child = this->CreateDrawingLayer(
copy, this->identity_matrix, gfx::PointF(), gfx::Size(200, 400), true);
- // The |copy| layer is hidden but since it is being copied, it will be
- // drawn.
- hide->test_properties()->hide_layer_and_subtree = true;
-
- this->CalcDrawEtc(root);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
- this->VisitLayer(copy_child, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(copy_child, &occlusion));
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
EXPECT_EQ(gfx::Rect(200, 400).ToString(),
occlusion.occlusion_from_inside_target().ToString());
// CopyRequests cause the layer to own a surface.
- this->VisitContributingSurface(copy, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitContributingSurface(copy, &occlusion));
// The occlusion from the copy should be dropped since it is hidden.
EXPECT_EQ(gfx::Rect().ToString(),
@@ -2021,19 +2031,18 @@ class OcclusionTrackerTestOccludedLayer : public OcclusionTrackerTest {
void RunMyTest() override {
gfx::Transform translate;
translate.Translate(10.0, 20.0);
- TestContentLayerImpl* root = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
+ TestContentLayerImpl* root = this->CreateRoot(gfx::Size(200, 200));
LayerImpl* surface = this->CreateSurface(
root, this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
LayerImpl* layer = this->CreateDrawingLayer(
surface, translate, gfx::PointF(), gfx::Size(200, 200), false);
TestContentLayerImpl* outside_layer = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::PointF(), gfx::Size(200, 200), false);
- this->CalcDrawEtc(root);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200));
- this->VisitLayer(outside_layer, &occlusion);
- this->EnterLayer(layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(outside_layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(layer, &occlusion));
// No occlusion, is not occluded.
occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion());
@@ -2109,19 +2118,18 @@ class OcclusionTrackerTestUnoccludedLayerQuery : public OcclusionTrackerTest {
void RunMyTest() override {
gfx::Transform translate;
translate.Translate(10.0, 20.0);
- TestContentLayerImpl* root = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
+ TestContentLayerImpl* root = this->CreateRoot(gfx::Size(200, 200));
LayerImpl* surface = this->CreateSurface(
root, this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
LayerImpl* layer = this->CreateDrawingLayer(
surface, translate, gfx::PointF(), gfx::Size(200, 200), false);
TestContentLayerImpl* outside_layer = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::PointF(), gfx::Size(200, 200), false);
- this->CalcDrawEtc(root);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200));
- this->VisitLayer(outside_layer, &occlusion);
- this->EnterLayer(layer, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(outside_layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->EnterLayer(layer, &occlusion));
// No occlusion, is not occluded.
occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion());
@@ -2272,8 +2280,7 @@ class OcclusionTrackerTestUnoccludedSurfaceQuery : public OcclusionTrackerTest {
void RunMyTest() override {
gfx::Transform translate;
translate.Translate(10.0, 20.0);
- TestContentLayerImpl* root = this->CreateRoot(
- this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
+ TestContentLayerImpl* root = this->CreateRoot(gfx::Size(200, 200));
LayerImpl* surface = this->CreateSurface(root, translate, gfx::PointF(),
gfx::Size(200, 200));
LayerImpl* layer =
@@ -2281,12 +2288,13 @@ class OcclusionTrackerTestUnoccludedSurfaceQuery : public OcclusionTrackerTest {
gfx::Size(200, 200), false);
TestContentLayerImpl* outside_layer = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::PointF(), gfx::Size(200, 200), false);
- this->CalcDrawEtc(root);
+ this->CalcDrawEtc();
TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200));
- this->VisitLayer(outside_layer, &occlusion);
- this->VisitLayer(layer, &occlusion);
- this->EnterContributingSurface(surface, &occlusion);
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(outside_layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(this->VisitLayer(layer, &occlusion));
+ ASSERT_NO_FATAL_FAILURE(
+ this->EnterContributingSurface(surface, &occlusion));
// No occlusion, is not occluded.
occlusion.set_occlusion_on_contributing_surface_from_outside_target(