[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1 | // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 5 | #include "cc/trees/damage_tracker.h" |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 6 | |
avi | 02a4d17 | 2015-12-21 06:14:36 | [diff] [blame] | 7 | #include <stddef.h> |
| 8 | |
[email protected] | 681ccff | 2013-03-18 06:13:52 | [diff] [blame] | 9 | #include "cc/base/math_util.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 10 | #include "cc/layers/layer_impl.h" |
Khushal | 7865b5be | 2017-11-22 03:12:06 | [diff] [blame] | 11 | #include "cc/paint/filter_operation.h" |
| 12 | #include "cc/paint/filter_operations.h" |
khushalsagar | b64b360d | 2015-10-21 19:25:16 | [diff] [blame] | 13 | #include "cc/test/fake_impl_task_runner_provider.h" |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 14 | #include "cc/test/fake_layer_tree_host_impl.h" |
[email protected] | 101441ce | 2012-10-16 01:45:03 | [diff] [blame] | 15 | #include "cc/test/geometry_test_utils.h" |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 16 | #include "cc/test/layer_test_common.h" |
reveman | 34b7a152 | 2015-03-23 20:27:47 | [diff] [blame] | 17 | #include "cc/test/test_task_graph_runner.h" |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 18 | #include "cc/trees/layer_tree_host_common.h" |
miletus | 5032027d | 2015-06-10 01:27:47 | [diff] [blame] | 19 | #include "cc/trees/layer_tree_impl.h" |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 20 | #include "cc/trees/single_thread_proxy.h" |
[email protected] | 7f0c53db | 2012-10-02 00:23:18 | [diff] [blame] | 21 | #include "testing/gtest/include/gtest/gtest.h" |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 22 | #include "ui/gfx/geometry/quad_f.h" |
| 23 | #include "ui/gfx/geometry/rect_conversions.h" |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 24 | |
[email protected] | ba56574 | 2012-11-10 09:29:48 | [diff] [blame] | 25 | namespace cc { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 26 | namespace { |
| 27 | |
[email protected] | 7aad55f | 2013-07-26 11:25:53 | [diff] [blame] | 28 | void ExecuteCalculateDrawProperties(LayerImpl* root, |
senorblanco | 2bc7c61 | 2016-08-12 19:34:17 | [diff] [blame] | 29 | float device_scale_factor, |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 30 | RenderSurfaceList* render_surface_list) { |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 31 | // Sanity check: The test itself should create the root layer's render |
| 32 | // surface, so that the surface (and its damage tracker) can |
| 33 | // persist across multiple calls to this function. |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 34 | ASSERT_FALSE(render_surface_list->size()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 35 | |
[email protected] | 7aad55f | 2013-07-26 11:25:53 | [diff] [blame] | 36 | LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 37 | root, root->bounds(), device_scale_factor, render_surface_list); |
sunxd | b365de0 | 2016-04-28 20:32:57 | [diff] [blame] | 38 | LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 39 | ASSERT_TRUE(GetRenderSurface(root)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 40 | } |
| 41 | |
sunxd | b2e13c9 | 2016-04-23 01:00:05 | [diff] [blame] | 42 | void ClearDamageForAllSurfaces(LayerImpl* root) { |
| 43 | for (auto* layer : *root->layer_tree_impl()) { |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 44 | if (GetRenderSurface(layer)) |
| 45 | GetRenderSurface(layer)->damage_tracker()->DidDrawDamagedArea(); |
sunxd | b2e13c9 | 2016-04-23 01:00:05 | [diff] [blame] | 46 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 47 | } |
| 48 | |
jaydasika | 3a6b1443 | 2017-03-21 23:11:19 | [diff] [blame] | 49 | void EmulateDrawingOneFrame(LayerImpl* root, float device_scale_factor = 1.f) { |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 50 | // This emulates only steps that are relevant to testing the damage tracker: |
| 51 | // 1. computing the render passes and layerlists |
| 52 | // 2. updating all damage trackers in the correct order |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 53 | // 3. resetting all update_rects and property_changed flags for all layers |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 54 | // and surfaces. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 55 | |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 56 | RenderSurfaceList render_surface_list; |
senorblanco | 2bc7c61 | 2016-08-12 19:34:17 | [diff] [blame] | 57 | ExecuteCalculateDrawProperties(root, device_scale_factor, |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 58 | &render_surface_list); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 59 | |
ajuma | 9c92fa02 | 2017-04-18 19:53:08 | [diff] [blame] | 60 | DamageTracker::UpdateDamageTracking(root->layer_tree_impl(), |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 61 | render_surface_list); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 62 | |
jaydasika | d6f778b | 2016-05-19 22:51:26 | [diff] [blame] | 63 | root->layer_tree_impl()->ResetAllChangeTracking(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 64 | } |
| 65 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 66 | class DamageTrackerTest : public testing::Test { |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 67 | public: |
reveman | 34b7a152 | 2015-03-23 20:27:47 | [diff] [blame] | 68 | DamageTrackerTest() |
piman | c44437a2 | 2016-10-29 00:09:22 | [diff] [blame] | 69 | : host_impl_(&task_runner_provider_, &task_graph_runner_) {} |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 70 | |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 71 | LayerImpl* CreateTestTreeWithOneSurface(int number_of_children) { |
rockot | 2176f92 | 2016-06-08 19:18:32 | [diff] [blame] | 72 | host_impl_.active_tree()->DetachLayers(); |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 73 | std::unique_ptr<LayerImpl> root = |
| 74 | LayerImpl::Create(host_impl_.active_tree(), 1); |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 75 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 76 | root->SetPosition(gfx::PointF()); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 77 | root->SetBounds(gfx::Size(500, 500)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 78 | root->SetDrawsContent(true); |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 79 | root->test_properties()->force_render_surface = true; |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 80 | |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 81 | for (int i = 0; i < number_of_children; ++i) { |
| 82 | std::unique_ptr<LayerImpl> child = |
| 83 | LayerImpl::Create(host_impl_.active_tree(), 2 + i); |
| 84 | child->SetPosition(gfx::PointF(100.f, 100.f)); |
| 85 | child->SetBounds(gfx::Size(30, 30)); |
| 86 | child->SetDrawsContent(true); |
| 87 | root->test_properties()->AddChild(std::move(child)); |
| 88 | } |
jaydasika | bf1875a | 2016-06-28 03:39:59 | [diff] [blame] | 89 | host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); |
weiliangc | ea09f337 | 2017-03-29 16:43:24 | [diff] [blame] | 90 | host_impl_.active_tree()->SetElementIdsForTesting(); |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 91 | |
jaydasika | bf1875a | 2016-06-28 03:39:59 | [diff] [blame] | 92 | return host_impl_.active_tree()->root_layer_for_testing(); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 93 | } |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 94 | |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 95 | LayerImpl* CreateTestTreeWithTwoSurfaces() { |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 96 | // This test tree has two render surfaces: one for the root, and one for |
| 97 | // child1. Additionally, the root has a second child layer, and child1 has |
| 98 | // two children of its own. |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 99 | |
rockot | 2176f92 | 2016-06-08 19:18:32 | [diff] [blame] | 100 | host_impl_.active_tree()->DetachLayers(); |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 101 | std::unique_ptr<LayerImpl> root = |
| 102 | LayerImpl::Create(host_impl_.active_tree(), 1); |
| 103 | std::unique_ptr<LayerImpl> child1 = |
| 104 | LayerImpl::Create(host_impl_.active_tree(), 2); |
| 105 | std::unique_ptr<LayerImpl> child2 = |
| 106 | LayerImpl::Create(host_impl_.active_tree(), 3); |
| 107 | std::unique_ptr<LayerImpl> grand_child1 = |
| 108 | LayerImpl::Create(host_impl_.active_tree(), 4); |
| 109 | std::unique_ptr<LayerImpl> grand_child2 = |
| 110 | LayerImpl::Create(host_impl_.active_tree(), 5); |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 111 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 112 | root->SetPosition(gfx::PointF()); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 113 | root->SetBounds(gfx::Size(500, 500)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 114 | root->SetDrawsContent(true); |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 115 | root->test_properties()->force_render_surface = true; |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 116 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 117 | child1->SetPosition(gfx::PointF(100.f, 100.f)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 118 | child1->SetBounds(gfx::Size(30, 30)); |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 119 | // With a child that draws_content, opacity will cause the layer to create |
| 120 | // its own RenderSurface. This layer does not draw, but is intended to |
awoloszyn | e83f28c | 2014-12-22 15:40:00 | [diff] [blame] | 121 | // create its own RenderSurface. |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 122 | child1->SetDrawsContent(false); |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 123 | child1->test_properties()->force_render_surface = true; |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 124 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 125 | child2->SetPosition(gfx::PointF(11.f, 11.f)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 126 | child2->SetBounds(gfx::Size(18, 18)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 127 | child2->SetDrawsContent(true); |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 128 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 129 | grand_child1->SetPosition(gfx::PointF(200.f, 200.f)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 130 | grand_child1->SetBounds(gfx::Size(6, 8)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 131 | grand_child1->SetDrawsContent(true); |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 132 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 133 | grand_child2->SetPosition(gfx::PointF(190.f, 190.f)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 134 | grand_child2->SetBounds(gfx::Size(6, 8)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 135 | grand_child2->SetDrawsContent(true); |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 136 | |
jaydasika | 89f7b5a | 2016-06-22 02:08:39 | [diff] [blame] | 137 | child1->test_properties()->AddChild(std::move(grand_child1)); |
| 138 | child1->test_properties()->AddChild(std::move(grand_child2)); |
| 139 | root->test_properties()->AddChild(std::move(child1)); |
| 140 | root->test_properties()->AddChild(std::move(child2)); |
jaydasika | bf1875a | 2016-06-28 03:39:59 | [diff] [blame] | 141 | host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); |
weiliangc | ea09f337 | 2017-03-29 16:43:24 | [diff] [blame] | 142 | host_impl_.active_tree()->SetElementIdsForTesting(); |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 143 | |
jaydasika | bf1875a | 2016-06-28 03:39:59 | [diff] [blame] | 144 | return host_impl_.active_tree()->root_layer_for_testing(); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 145 | } |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 146 | |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 147 | LayerImpl* CreateAndSetUpTestTreeWithOneSurface(int number_of_children = 1) { |
| 148 | LayerImpl* root = CreateTestTreeWithOneSurface(number_of_children); |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 149 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 150 | // Setup includes going past the first frame which always damages |
| 151 | // everything, so that we can actually perform specific tests. |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 152 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 153 | EmulateDrawingOneFrame(root); |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 154 | |
danakj | a04855a | 2015-11-18 20:39:10 | [diff] [blame] | 155 | return root; |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 156 | } |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 157 | |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 158 | LayerImpl* CreateAndSetUpTestTreeWithTwoSurfaces() { |
| 159 | LayerImpl* root = CreateTestTreeWithTwoSurfaces(); |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 160 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 161 | // Setup includes going past the first frame which always damages |
| 162 | // everything, so that we can actually perform specific tests. |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 163 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 164 | EmulateDrawingOneFrame(root); |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 165 | |
danakj | a04855a | 2015-11-18 20:39:10 | [diff] [blame] | 166 | return root; |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 167 | } |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 168 | |
[email protected] | b50e06d | 2013-03-26 09:16:55 | [diff] [blame] | 169 | protected: |
khushalsagar | b64b360d | 2015-10-21 19:25:16 | [diff] [blame] | 170 | FakeImplTaskRunnerProvider task_runner_provider_; |
reveman | 34b7a152 | 2015-03-23 20:27:47 | [diff] [blame] | 171 | TestTaskGraphRunner task_graph_runner_; |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 172 | FakeLayerTreeHostImpl host_impl_; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 173 | }; |
| 174 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 175 | TEST_F(DamageTrackerTest, SanityCheckTestTreeWithOneSurface) { |
| 176 | // Sanity check that the simple test tree will actually produce the expected |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 177 | // render surfaces. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 178 | |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 179 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 180 | LayerImpl* child = root->test_properties()->children[0]; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 181 | |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 182 | EXPECT_EQ(2, GetRenderSurface(root)->num_contributors()); |
ajuma | 651848a | 2017-05-01 21:23:45 | [diff] [blame] | 183 | EXPECT_TRUE(root->contributes_to_drawn_render_surface()); |
| 184 | EXPECT_TRUE(child->contributes_to_drawn_render_surface()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 185 | |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 186 | gfx::Rect root_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 187 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 188 | &root_damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 189 | |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 190 | EXPECT_EQ(gfx::Rect(500, 500).ToString(), root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 191 | EXPECT_TRUE(GetRenderSurface(root) |
| 192 | ->damage_tracker() |
| 193 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 194 | } |
| 195 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 196 | TEST_F(DamageTrackerTest, SanityCheckTestTreeWithTwoSurfaces) { |
| 197 | // Sanity check that the complex test tree will actually produce the expected |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 198 | // render surfaces. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 199 | |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 200 | LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 201 | |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 202 | LayerImpl* child1 = root->test_properties()->children[0]; |
| 203 | LayerImpl* child2 = root->test_properties()->children[1]; |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 204 | |
| 205 | gfx::Rect child_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 206 | EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( |
| 207 | &child_damage_rect)); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 208 | gfx::Rect root_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 209 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 210 | &root_damage_rect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 211 | |
chrishtr | 5f60ca0 | 2017-05-11 23:09:49 | [diff] [blame] | 212 | EXPECT_NE(GetRenderSurface(child1), GetRenderSurface(root)); |
| 213 | EXPECT_EQ(GetRenderSurface(child2), GetRenderSurface(root)); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 214 | EXPECT_EQ(3, GetRenderSurface(root)->num_contributors()); |
| 215 | EXPECT_EQ(2, GetRenderSurface(child1)->num_contributors()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 216 | |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 217 | // The render surface for child1 only has a content_rect that encloses |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 218 | // grand_child1 and grand_child2, because child1 does not draw content. |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 219 | EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), |
| 220 | child_damage_rect.ToString()); |
| 221 | EXPECT_EQ(gfx::Rect(500, 500).ToString(), root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 222 | |
| 223 | EXPECT_TRUE(GetRenderSurface(root) |
| 224 | ->damage_tracker() |
| 225 | ->has_damage_from_contributing_content()); |
| 226 | EXPECT_TRUE(GetRenderSurface(child1) |
| 227 | ->damage_tracker() |
| 228 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 229 | } |
| 230 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 231 | TEST_F(DamageTrackerTest, VerifyDamageForUpdateRects) { |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 232 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 233 | LayerImpl* child = root->test_properties()->children[0]; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 234 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 235 | // CASE 1: Setting the update rect should cause the corresponding damage to |
| 236 | // the surface. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 237 | ClearDamageForAllSurfaces(root); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 238 | child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 239 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 240 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 241 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 242 | // Damage position on the surface should be: position of update_rect (10, 11) |
| 243 | // relative to the child (100, 100). |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 244 | gfx::Rect root_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 245 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 246 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 247 | EXPECT_EQ(gfx::Rect(110, 111, 12, 13).ToString(), |
| 248 | root_damage_rect.ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 249 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 250 | // CASE 2: The same update rect twice in a row still produces the same |
| 251 | // damage. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 252 | ClearDamageForAllSurfaces(root); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 253 | child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 254 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 255 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 256 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 257 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 258 | EXPECT_EQ(gfx::Rect(110, 111, 12, 13).ToString(), |
| 259 | root_damage_rect.ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 260 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 261 | // CASE 3: Setting a different update rect should cause damage on the new |
| 262 | // update region, but no additional exposed old region. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 263 | ClearDamageForAllSurfaces(root); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 264 | child->SetUpdateRect(gfx::Rect(20, 25, 1, 2)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 265 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 266 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 267 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 268 | // Damage position on the surface should be: position of update_rect (20, 25) |
| 269 | // relative to the child (100, 100). |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 270 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 271 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 272 | EXPECT_EQ(gfx::Rect(120, 125, 1, 2).ToString(), root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 273 | EXPECT_TRUE(GetRenderSurface(root) |
| 274 | ->damage_tracker() |
| 275 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 276 | } |
| 277 | |
[email protected] | cfa7fd92 | 2014-04-29 11:50:03 | [diff] [blame] | 278 | TEST_F(DamageTrackerTest, VerifyDamageForLayerDamageRects) { |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 279 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 280 | LayerImpl* child = root->test_properties()->children[0]; |
[email protected] | cfa7fd92 | 2014-04-29 11:50:03 | [diff] [blame] | 281 | |
| 282 | // CASE 1: Adding the layer damage rect should cause the corresponding damage |
| 283 | // to the surface. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 284 | ClearDamageForAllSurfaces(root); |
danakj | d344ab9 | 2015-08-28 19:25:51 | [diff] [blame] | 285 | child->AddDamageRect(gfx::Rect(10, 11, 12, 13)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 286 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 287 | EmulateDrawingOneFrame(root); |
[email protected] | cfa7fd92 | 2014-04-29 11:50:03 | [diff] [blame] | 288 | |
| 289 | // Damage position on the surface should be: position of layer damage_rect |
| 290 | // (10, 11) relative to the child (100, 100). |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 291 | gfx::Rect root_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 292 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 293 | &root_damage_rect)); |
[email protected] | cfa7fd92 | 2014-04-29 11:50:03 | [diff] [blame] | 294 | EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(110, 111, 12, 13))); |
| 295 | |
| 296 | // CASE 2: The same layer damage rect twice in a row still produces the same |
| 297 | // damage. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 298 | ClearDamageForAllSurfaces(root); |
danakj | d344ab9 | 2015-08-28 19:25:51 | [diff] [blame] | 299 | child->AddDamageRect(gfx::Rect(10, 11, 12, 13)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 300 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 301 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 302 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 303 | &root_damage_rect)); |
[email protected] | cfa7fd92 | 2014-04-29 11:50:03 | [diff] [blame] | 304 | EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(110, 111, 12, 13))); |
| 305 | |
| 306 | // CASE 3: Adding a different layer damage rect should cause damage on the |
| 307 | // new damaged region, but no additional exposed old region. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 308 | ClearDamageForAllSurfaces(root); |
danakj | d344ab9 | 2015-08-28 19:25:51 | [diff] [blame] | 309 | child->AddDamageRect(gfx::Rect(20, 25, 1, 2)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 310 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 311 | EmulateDrawingOneFrame(root); |
[email protected] | cfa7fd92 | 2014-04-29 11:50:03 | [diff] [blame] | 312 | |
| 313 | // Damage position on the surface should be: position of layer damage_rect |
| 314 | // (20, 25) relative to the child (100, 100). |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 315 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 316 | &root_damage_rect)); |
[email protected] | cfa7fd92 | 2014-04-29 11:50:03 | [diff] [blame] | 317 | EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(120, 125, 1, 2))); |
| 318 | |
| 319 | // CASE 4: Adding multiple layer damage rects should cause a unified |
| 320 | // damage on root damage rect. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 321 | ClearDamageForAllSurfaces(root); |
danakj | d344ab9 | 2015-08-28 19:25:51 | [diff] [blame] | 322 | child->AddDamageRect(gfx::Rect(20, 25, 1, 2)); |
| 323 | child->AddDamageRect(gfx::Rect(10, 15, 3, 4)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 324 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 325 | EmulateDrawingOneFrame(root); |
[email protected] | cfa7fd92 | 2014-04-29 11:50:03 | [diff] [blame] | 326 | |
| 327 | // Damage position on the surface should be: position of layer damage_rect |
| 328 | // (20, 25) relative to the child (100, 100). |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 329 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 330 | &root_damage_rect)); |
[email protected] | cfa7fd92 | 2014-04-29 11:50:03 | [diff] [blame] | 331 | EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(120, 125, 1, 2))); |
| 332 | EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(110, 115, 3, 4))); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 333 | EXPECT_TRUE(GetRenderSurface(root) |
| 334 | ->damage_tracker() |
| 335 | ->has_damage_from_contributing_content()); |
[email protected] | cfa7fd92 | 2014-04-29 11:50:03 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | TEST_F(DamageTrackerTest, VerifyDamageForLayerUpdateAndDamageRects) { |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 339 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 340 | LayerImpl* child = root->test_properties()->children[0]; |
[email protected] | cfa7fd92 | 2014-04-29 11:50:03 | [diff] [blame] | 341 | |
| 342 | // CASE 1: Adding the layer damage rect and update rect should cause the |
| 343 | // corresponding damage to the surface. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 344 | ClearDamageForAllSurfaces(root); |
danakj | d344ab9 | 2015-08-28 19:25:51 | [diff] [blame] | 345 | child->AddDamageRect(gfx::Rect(5, 6, 12, 13)); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 346 | child->SetUpdateRect(gfx::Rect(15, 16, 14, 10)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 347 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 348 | EmulateDrawingOneFrame(root); |
[email protected] | cfa7fd92 | 2014-04-29 11:50:03 | [diff] [blame] | 349 | |
| 350 | // Damage position on the surface should be: position of unified layer |
| 351 | // damage_rect and update rect (5, 6) |
| 352 | // relative to the child (100, 100). |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 353 | gfx::Rect root_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 354 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 355 | &root_damage_rect)); |
[email protected] | cfa7fd92 | 2014-04-29 11:50:03 | [diff] [blame] | 356 | EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(105, 106, 24, 20))); |
| 357 | |
| 358 | // CASE 2: The same layer damage rect and update rect twice in a row still |
| 359 | // produces the same damage. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 360 | ClearDamageForAllSurfaces(root); |
danakj | d344ab9 | 2015-08-28 19:25:51 | [diff] [blame] | 361 | child->AddDamageRect(gfx::Rect(10, 11, 12, 13)); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 362 | child->SetUpdateRect(gfx::Rect(10, 11, 14, 15)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 363 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 364 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 365 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 366 | &root_damage_rect)); |
[email protected] | cfa7fd92 | 2014-04-29 11:50:03 | [diff] [blame] | 367 | EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(110, 111, 14, 15))); |
| 368 | |
| 369 | // CASE 3: Adding a different layer damage rect and update rect should cause |
| 370 | // damage on the new damaged region, but no additional exposed old region. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 371 | ClearDamageForAllSurfaces(root); |
danakj | d344ab9 | 2015-08-28 19:25:51 | [diff] [blame] | 372 | child->AddDamageRect(gfx::Rect(20, 25, 2, 3)); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 373 | child->SetUpdateRect(gfx::Rect(5, 10, 7, 8)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 374 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 375 | EmulateDrawingOneFrame(root); |
[email protected] | cfa7fd92 | 2014-04-29 11:50:03 | [diff] [blame] | 376 | |
| 377 | // Damage position on the surface should be: position of unified layer damage |
| 378 | // rect and update rect (5, 10) relative to the child (100, 100). |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 379 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 380 | &root_damage_rect)); |
[email protected] | cfa7fd92 | 2014-04-29 11:50:03 | [diff] [blame] | 381 | EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(105, 110, 17, 18))); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 382 | EXPECT_TRUE(GetRenderSurface(root) |
| 383 | ->damage_tracker() |
| 384 | ->has_damage_from_contributing_content()); |
[email protected] | cfa7fd92 | 2014-04-29 11:50:03 | [diff] [blame] | 385 | } |
| 386 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 387 | TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) { |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 388 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 389 | LayerImpl* child = root->test_properties()->children[0]; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 390 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 391 | // CASE 1: The layer's property changed flag takes priority over update rect. |
| 392 | // |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 393 | child->test_properties()->force_render_surface = true; |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 394 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 395 | EmulateDrawingOneFrame(root); |
| 396 | ClearDamageForAllSurfaces(root); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 397 | child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); |
weiliangc | ea09f337 | 2017-03-29 16:43:24 | [diff] [blame] | 398 | root->layer_tree_impl()->SetOpacityMutated(child->element_id(), 0.5f); |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 399 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 400 | |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 401 | ASSERT_EQ(2, GetRenderSurface(root)->num_contributors()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 402 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 403 | // Damage should be the entire child layer in target_surface space. |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 404 | gfx::Rect expected_rect = gfx::Rect(100, 100, 30, 30); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 405 | gfx::Rect root_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 406 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 407 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 408 | EXPECT_EQ(expected_rect.ToString(), root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 409 | EXPECT_TRUE(GetRenderSurface(root) |
| 410 | ->damage_tracker() |
| 411 | ->has_damage_from_contributing_content()); |
| 412 | EXPECT_TRUE(GetRenderSurface(child) |
| 413 | ->damage_tracker() |
| 414 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 415 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 416 | // CASE 2: If a layer moves due to property change, it damages both the new |
| 417 | // location and the old (exposed) location. The old location is the |
| 418 | // entire old layer, not just the update_rect. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 419 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 420 | // Cycle one frame of no change, just to sanity check that the next rect is |
| 421 | // not because of the old damage state. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 422 | ClearDamageForAllSurfaces(root); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 423 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 424 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 425 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 426 | &root_damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 427 | EXPECT_TRUE(root_damage_rect.IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 428 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 429 | // Then, test the actual layer movement. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 430 | ClearDamageForAllSurfaces(root); |
ajuma | 816002e | 2016-09-23 23:30:42 | [diff] [blame] | 431 | gfx::Transform translation; |
| 432 | translation.Translate(100.f, 130.f); |
weiliangc | ea09f337 | 2017-03-29 16:43:24 | [diff] [blame] | 433 | root->layer_tree_impl()->SetTransformMutated(child->element_id(), |
| 434 | translation); |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 435 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 436 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 437 | // Expect damage to be the combination of the previous one and the new one. |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 438 | expected_rect.Union(gfx::Rect(200, 230, 30, 30)); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 439 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 440 | &root_damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 441 | EXPECT_FLOAT_RECT_EQ(expected_rect, root_damage_rect); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 442 | EXPECT_TRUE(GetRenderSurface(root) |
| 443 | ->damage_tracker() |
| 444 | ->has_damage_from_contributing_content()); |
| 445 | // Transform from browser animation should not be considered as damage from |
| 446 | // contributing layer since it is applied to the whole layer which has a |
| 447 | // render surface. |
| 448 | EXPECT_FALSE(GetRenderSurface(child) |
| 449 | ->damage_tracker() |
| 450 | ->has_damage_from_contributing_content()); |
| 451 | } |
| 452 | |
| 453 | TEST_F(DamageTrackerTest, |
| 454 | VerifyDamageForPropertyChangesFromContributingContents) { |
| 455 | LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
| 456 | LayerImpl* child1 = root->test_properties()->children[0]; |
| 457 | LayerImpl* child2 = root->test_properties()->children[1]; |
| 458 | LayerImpl* grandchild1 = child1->test_properties()->children[0]; |
| 459 | |
| 460 | // CASE 1: The child1's opacity changed. |
| 461 | ClearDamageForAllSurfaces(root); |
| 462 | root->layer_tree_impl()->SetOpacityMutated(child1->element_id(), 0.5f); |
| 463 | EmulateDrawingOneFrame(root); |
| 464 | EXPECT_TRUE(GetRenderSurface(root) |
| 465 | ->damage_tracker() |
| 466 | ->has_damage_from_contributing_content()); |
| 467 | EXPECT_FALSE(GetRenderSurface(child1) |
| 468 | ->damage_tracker() |
| 469 | ->has_damage_from_contributing_content()); |
| 470 | |
| 471 | // CASE 2: The layer2's opacity changed. |
| 472 | child2->test_properties()->force_render_surface = true; |
| 473 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 474 | EmulateDrawingOneFrame(root); |
| 475 | ClearDamageForAllSurfaces(root); |
| 476 | root->layer_tree_impl()->SetOpacityMutated(child2->element_id(), 0.5f); |
| 477 | EmulateDrawingOneFrame(root); |
| 478 | EXPECT_TRUE(GetRenderSurface(root) |
| 479 | ->damage_tracker() |
| 480 | ->has_damage_from_contributing_content()); |
| 481 | EXPECT_FALSE(GetRenderSurface(child1) |
| 482 | ->damage_tracker() |
| 483 | ->has_damage_from_contributing_content()); |
| 484 | |
| 485 | // CASE 3: The grandchild1's opacity changed. |
| 486 | grandchild1->test_properties()->force_render_surface = true; |
| 487 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 488 | EmulateDrawingOneFrame(root); |
| 489 | ClearDamageForAllSurfaces(root); |
| 490 | root->layer_tree_impl()->SetOpacityMutated(grandchild1->element_id(), 0.5f); |
| 491 | EmulateDrawingOneFrame(root); |
| 492 | EXPECT_TRUE(GetRenderSurface(root) |
| 493 | ->damage_tracker() |
| 494 | ->has_damage_from_contributing_content()); |
| 495 | EXPECT_TRUE(GetRenderSurface(child1) |
| 496 | ->damage_tracker() |
| 497 | ->has_damage_from_contributing_content()); |
| 498 | } |
| 499 | |
| 500 | TEST_F(DamageTrackerTest, |
| 501 | VerifyDamageForUpdateAndDamageRectsFromContributingContents) { |
| 502 | LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
| 503 | LayerImpl* child1 = root->test_properties()->children[0]; |
| 504 | LayerImpl* child2 = root->test_properties()->children[1]; |
| 505 | LayerImpl* grandchild1 = child1->test_properties()->children[0]; |
| 506 | |
| 507 | // CASE 1: Adding the layer1's damage rect and update rect should cause the |
| 508 | // corresponding damage to the surface. |
| 509 | child1->SetDrawsContent(true); |
| 510 | ClearDamageForAllSurfaces(root); |
| 511 | child1->AddDamageRect(gfx::Rect(105, 106, 12, 15)); |
| 512 | child1->SetUpdateRect(gfx::Rect(115, 116, 12, 15)); |
| 513 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 514 | EmulateDrawingOneFrame(root); |
| 515 | EXPECT_TRUE(GetRenderSurface(root) |
| 516 | ->damage_tracker() |
| 517 | ->has_damage_from_contributing_content()); |
| 518 | EXPECT_TRUE(GetRenderSurface(child1) |
| 519 | ->damage_tracker() |
| 520 | ->has_damage_from_contributing_content()); |
| 521 | |
| 522 | // CASE 2: Adding the layer2's damage rect and update rect should cause the |
| 523 | // corresponding damage to the surface. |
| 524 | ClearDamageForAllSurfaces(root); |
| 525 | child2->AddDamageRect(gfx::Rect(11, 11, 12, 15)); |
| 526 | child2->SetUpdateRect(gfx::Rect(12, 12, 12, 15)); |
| 527 | EmulateDrawingOneFrame(root); |
| 528 | EXPECT_TRUE(GetRenderSurface(root) |
| 529 | ->damage_tracker() |
| 530 | ->has_damage_from_contributing_content()); |
| 531 | EXPECT_FALSE(GetRenderSurface(child1) |
| 532 | ->damage_tracker() |
| 533 | ->has_damage_from_contributing_content()); |
| 534 | |
| 535 | // CASE 3: Adding the grandchild1's damage rect and update rect should cause |
| 536 | // the corresponding damage to the surface. |
| 537 | ClearDamageForAllSurfaces(root); |
| 538 | grandchild1->AddDamageRect(gfx::Rect(1, 0, 2, 5)); |
| 539 | grandchild1->SetUpdateRect(gfx::Rect(2, 1, 2, 5)); |
| 540 | EmulateDrawingOneFrame(root); |
| 541 | EXPECT_TRUE(GetRenderSurface(root) |
| 542 | ->damage_tracker() |
| 543 | ->has_damage_from_contributing_content()); |
| 544 | EXPECT_TRUE(GetRenderSurface(child1) |
| 545 | ->damage_tracker() |
| 546 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 547 | } |
| 548 | |
jaydasika | cf22376 | 2016-05-16 23:02:09 | [diff] [blame] | 549 | TEST_F(DamageTrackerTest, VerifyDamageWhenSurfaceRemoved) { |
| 550 | LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 551 | LayerImpl* surface = root->test_properties()->children[0]; |
| 552 | LayerImpl* child = surface->test_properties()->children[0]; |
jaydasika | cf22376 | 2016-05-16 23:02:09 | [diff] [blame] | 553 | child->SetDrawsContent(true); |
| 554 | EmulateDrawingOneFrame(root); |
| 555 | ClearDamageForAllSurfaces(root); |
| 556 | |
| 557 | surface->test_properties()->force_render_surface = false; |
| 558 | child->SetDrawsContent(false); |
| 559 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 560 | EmulateDrawingOneFrame(root); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 561 | gfx::Rect root_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 562 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 563 | &root_damage_rect)); |
jaydasika | cf22376 | 2016-05-16 23:02:09 | [diff] [blame] | 564 | EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(), |
| 565 | root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 566 | EXPECT_TRUE(GetRenderSurface(root) |
| 567 | ->damage_tracker() |
| 568 | ->has_damage_from_contributing_content()); |
jaydasika | cf22376 | 2016-05-16 23:02:09 | [diff] [blame] | 569 | } |
| 570 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 571 | TEST_F(DamageTrackerTest, VerifyDamageForTransformedLayer) { |
| 572 | // If a layer is transformed, the damage rect should still enclose the entire |
| 573 | // transformed layer. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 574 | |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 575 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 576 | LayerImpl* child = root->test_properties()->children[0]; |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 577 | child->test_properties()->force_render_surface = true; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 578 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 579 | gfx::Transform rotation; |
| 580 | rotation.Rotate(45.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 581 | |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 582 | ClearDamageForAllSurfaces(root); |
jaydasika | 38be7a82 | 2016-04-21 16:07:06 | [diff] [blame] | 583 | child->test_properties()->transform_origin = gfx::Point3F( |
| 584 | child->bounds().width() * 0.5f, child->bounds().height() * 0.5f, 0.f); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 585 | child->SetPosition(gfx::PointF(85.f, 85.f)); |
jaydasika | adfec8e | 2016-02-17 02:46:11 | [diff] [blame] | 586 | child->NoteLayerPropertyChanged(); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 587 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 588 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 589 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 590 | // Sanity check that the layer actually moved to (85, 85), damaging its old |
| 591 | // location and new location. |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 592 | gfx::Rect root_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 593 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 594 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 595 | EXPECT_EQ(gfx::Rect(85, 85, 45, 45).ToString(), root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 596 | EXPECT_TRUE(GetRenderSurface(root) |
| 597 | ->damage_tracker() |
| 598 | ->has_damage_from_contributing_content()); |
wutao | bb1af5a | 2017-08-16 17:35:35 | [diff] [blame] | 599 | // Layer's layer_property_changed_not_from_property_trees_ should be |
| 600 | // considered as damage to render surface. |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 601 | EXPECT_TRUE(GetRenderSurface(child) |
| 602 | ->damage_tracker() |
| 603 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 604 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 605 | // With the anchor on the layer's center, now we can test the rotation more |
| 606 | // intuitively, since it applies about the layer's anchor. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 607 | ClearDamageForAllSurfaces(root); |
weiliangc | ea09f337 | 2017-03-29 16:43:24 | [diff] [blame] | 608 | root->layer_tree_impl()->SetTransformMutated(child->element_id(), rotation); |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 609 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 610 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 611 | // Since the child layer is square, rotation by 45 degrees about the center |
| 612 | // should increase the size of the expected rect by sqrt(2), centered around |
| 613 | // (100, 100). The old exposed region should be fully contained in the new |
| 614 | // region. |
[email protected] | 803f6b5 | 2013-09-12 00:51:26 | [diff] [blame] | 615 | float expected_width = 30.f * sqrt(2.f); |
| 616 | float expected_position = 100.f - 0.5f * expected_width; |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 617 | gfx::Rect expected_rect = gfx::ToEnclosingRect(gfx::RectF( |
| 618 | expected_position, expected_position, expected_width, expected_width)); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 619 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 620 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 621 | EXPECT_EQ(expected_rect.ToString(), root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 622 | EXPECT_TRUE(GetRenderSurface(root) |
| 623 | ->damage_tracker() |
| 624 | ->has_damage_from_contributing_content()); |
| 625 | // Transform from browser animation should not be considered as damage from |
| 626 | // contributing layer since it is applied to the whole layer which has a |
| 627 | // render surface. |
| 628 | EXPECT_FALSE(GetRenderSurface(child) |
| 629 | ->damage_tracker() |
| 630 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 631 | } |
| 632 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 633 | TEST_F(DamageTrackerTest, VerifyDamageForPerspectiveClippedLayer) { |
| 634 | // If a layer has a perspective transform that causes w < 0, then not |
| 635 | // clipping the layer can cause an invalid damage rect. This test checks that |
| 636 | // the w < 0 case is tracked properly. |
| 637 | // |
| 638 | // The transform is constructed so that if w < 0 clipping is not performed, |
| 639 | // the incorrect rect will be very small, specifically: position (500.972504, |
| 640 | // 498.544617) and size 0.056610 x 2.910767. Instead, the correctly |
| 641 | // transformed rect should actually be very huge (i.e. in theory, -infinity |
| 642 | // on the left), and positioned so that the right-most bound rect will be |
| 643 | // approximately 501 units in root surface space. |
| 644 | // |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 645 | |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 646 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 647 | LayerImpl* child = root->test_properties()->children[0]; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 648 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 649 | gfx::Transform transform; |
petermayo | fba53156 | 2016-06-17 21:37:02 | [diff] [blame] | 650 | transform.Translate3d(550.0, 500.0, 0.0); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 651 | transform.ApplyPerspectiveDepth(1.0); |
| 652 | transform.RotateAboutYAxis(45.0); |
| 653 | transform.Translate3d(-50.0, -50.0, 0.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 654 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 655 | // Set up the child |
| 656 | child->SetPosition(gfx::PointF(0.f, 0.f)); |
| 657 | child->SetBounds(gfx::Size(100, 100)); |
jaydasika | 10d43fc | 2016-08-18 04:06:04 | [diff] [blame] | 658 | child->test_properties()->transform = transform; |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 659 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 660 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 661 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 662 | // Sanity check that the child layer's bounds would actually get clipped by |
| 663 | // w < 0, otherwise this test is not actually testing the intended scenario. |
petermayo | d063e7b | 2017-03-14 12:30:20 | [diff] [blame] | 664 | gfx::RectF test_rect(child->position(), gfx::SizeF(child->bounds())); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 665 | bool clipped = false; |
petermayo | d063e7b | 2017-03-14 12:30:20 | [diff] [blame] | 666 | MathUtil::MapQuad(transform, gfx::QuadF(test_rect), &clipped); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 667 | EXPECT_TRUE(clipped); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 668 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 669 | // Damage the child without moving it. |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 670 | child->test_properties()->force_render_surface = true; |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 671 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 672 | EmulateDrawingOneFrame(root); |
| 673 | ClearDamageForAllSurfaces(root); |
weiliangc | ea09f337 | 2017-03-29 16:43:24 | [diff] [blame] | 674 | root->layer_tree_impl()->SetOpacityMutated(child->element_id(), 0.5f); |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 675 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 676 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 677 | // The expected damage should cover the entire root surface (500x500), but we |
| 678 | // don't care whether the damage rect was clamped or is larger than the |
| 679 | // surface for this test. |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 680 | gfx::Rect root_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 681 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 682 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 683 | gfx::Rect damage_we_care_about = gfx::Rect(gfx::Size(500, 500)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 684 | EXPECT_TRUE(root_damage_rect.Contains(damage_we_care_about)); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 685 | EXPECT_TRUE(GetRenderSurface(root) |
| 686 | ->damage_tracker() |
| 687 | ->has_damage_from_contributing_content()); |
| 688 | EXPECT_FALSE(GetRenderSurface(child) |
| 689 | ->damage_tracker() |
| 690 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 691 | } |
| 692 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 693 | TEST_F(DamageTrackerTest, VerifyDamageForBlurredSurface) { |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 694 | LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 695 | LayerImpl* surface = root->test_properties()->children[0]; |
| 696 | LayerImpl* child = surface->test_properties()->children[0]; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 697 | |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 698 | FilterOperations filters; |
| 699 | filters.Append(FilterOperation::CreateBlurFilter(5.f)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 700 | |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 701 | // Setting the filter should not damage the conrresponding render surface. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 702 | ClearDamageForAllSurfaces(root); |
ajuma | cb2b7443 | 2016-07-21 19:11:15 | [diff] [blame] | 703 | surface->test_properties()->filters = filters; |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 704 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 705 | EmulateDrawingOneFrame(root); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 706 | EXPECT_FALSE(GetRenderSurface(root) |
| 707 | ->damage_tracker() |
| 708 | ->has_damage_from_contributing_content()); |
| 709 | EXPECT_FALSE(GetRenderSurface(surface) |
| 710 | ->damage_tracker() |
| 711 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 712 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 713 | // Setting the update rect should cause the corresponding damage to the |
| 714 | // surface, blurred based on the size of the blur filter. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 715 | ClearDamageForAllSurfaces(root); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 716 | child->SetUpdateRect(gfx::Rect(1, 2, 3, 4)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 717 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 718 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 719 | |
[email protected] | 35a99a1 | 2013-05-09 23:52:29 | [diff] [blame] | 720 | // Damage position on the surface should be: position of update_rect (1, 2) |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 721 | // relative to the child (300, 300), but expanded by the blur outsets |
| 722 | // (15, since the blur radius is 5). |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 723 | gfx::Rect root_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 724 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 725 | &root_damage_rect)); |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 726 | EXPECT_EQ(gfx::Rect(286, 287, 33, 34), root_damage_rect); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 727 | EXPECT_TRUE(GetRenderSurface(root) |
| 728 | ->damage_tracker() |
| 729 | ->has_damage_from_contributing_content()); |
| 730 | EXPECT_TRUE(GetRenderSurface(surface) |
| 731 | ->damage_tracker() |
| 732 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 733 | } |
| 734 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 735 | TEST_F(DamageTrackerTest, VerifyDamageForImageFilter) { |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 736 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 737 | LayerImpl* child = root->test_properties()->children[0]; |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 738 | gfx::Rect root_damage_rect, child_damage_rect; |
[email protected] | 4000abf | 2012-10-23 04:45:45 | [diff] [blame] | 739 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 740 | // Allow us to set damage on child too. |
| 741 | child->SetDrawsContent(true); |
[email protected] | 4000abf | 2012-10-23 04:45:45 | [diff] [blame] | 742 | |
[email protected] | 1dc7943e | 2013-09-26 04:41:48 | [diff] [blame] | 743 | FilterOperations filters; |
Khushal | 7865b5be | 2017-11-22 03:12:06 | [diff] [blame] | 744 | filters.Append( |
| 745 | FilterOperation::CreateReferenceFilter(sk_make_sp<BlurPaintFilter>( |
| 746 | 2, 2, BlurPaintFilter::TileMode::kClampToBlack_TileMode, nullptr))); |
[email protected] | 4000abf | 2012-10-23 04:45:45 | [diff] [blame] | 747 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 748 | // Setting the filter will damage the whole surface. |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 749 | child->test_properties()->force_render_surface = true; |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 750 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 751 | EmulateDrawingOneFrame(root); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 752 | ClearDamageForAllSurfaces(root); |
weiliangc | ea09f337 | 2017-03-29 16:43:24 | [diff] [blame] | 753 | child->layer_tree_impl()->SetFilterMutated(child->element_id(), filters); |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 754 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 755 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 756 | &root_damage_rect)); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 757 | EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 758 | &child_damage_rect)); |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 759 | |
| 760 | // gfx::Rect(100, 100, 30, 30), expanded by 6px for the 2px blur filter. |
| 761 | EXPECT_EQ(gfx::Rect(94, 94, 42, 42), root_damage_rect); |
| 762 | |
| 763 | // gfx::Rect(0, 0, 30, 30), expanded by 6px for the 2px blur filter. |
| 764 | EXPECT_EQ(gfx::Rect(-6, -6, 42, 42), child_damage_rect); |
[email protected] | 4000abf | 2012-10-23 04:45:45 | [diff] [blame] | 765 | |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 766 | EXPECT_TRUE(GetRenderSurface(root) |
| 767 | ->damage_tracker() |
| 768 | ->has_damage_from_contributing_content()); |
| 769 | EXPECT_FALSE(GetRenderSurface(child) |
| 770 | ->damage_tracker() |
| 771 | ->has_damage_from_contributing_content()); |
| 772 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 773 | // CASE 1: Setting the update rect should damage the whole surface (for now) |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 774 | ClearDamageForAllSurfaces(root); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 775 | child->SetUpdateRect(gfx::Rect(1, 1)); |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 776 | EmulateDrawingOneFrame(root); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 777 | |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 778 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 779 | &root_damage_rect)); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 780 | EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 781 | &child_damage_rect)); |
hendrikw | 920114d | 2015-08-24 23:38:35 | [diff] [blame] | 782 | |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 783 | // gfx::Rect(100, 100, 1, 1), expanded by 6px for the 2px blur filter. |
| 784 | EXPECT_EQ(gfx::Rect(94, 94, 13, 13), root_damage_rect); |
| 785 | |
| 786 | // gfx::Rect(0, 0, 1, 1), expanded by 6px for the 2px blur filter. |
| 787 | EXPECT_EQ(gfx::Rect(-6, -6, 13, 13), child_damage_rect); |
wutao | 92b48551 | 2017-07-29 02:04:17 | [diff] [blame] | 788 | |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 789 | EXPECT_TRUE(GetRenderSurface(root) |
| 790 | ->damage_tracker() |
| 791 | ->has_damage_from_contributing_content()); |
| 792 | EXPECT_TRUE(GetRenderSurface(child) |
| 793 | ->damage_tracker() |
| 794 | ->has_damage_from_contributing_content()); |
| 795 | |
wutao | 92b48551 | 2017-07-29 02:04:17 | [diff] [blame] | 796 | // CASE 2: No changes, so should not damage the surface. |
| 797 | ClearDamageForAllSurfaces(root); |
| 798 | EmulateDrawingOneFrame(root); |
| 799 | |
| 800 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
| 801 | &root_damage_rect)); |
| 802 | EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( |
| 803 | &child_damage_rect)); |
| 804 | |
| 805 | // Should not be expanded by the blur filter. |
| 806 | EXPECT_EQ(gfx::Rect(), root_damage_rect); |
| 807 | EXPECT_EQ(gfx::Rect(), child_damage_rect); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 808 | |
| 809 | EXPECT_FALSE(GetRenderSurface(root) |
| 810 | ->damage_tracker() |
| 811 | ->has_damage_from_contributing_content()); |
| 812 | EXPECT_FALSE(GetRenderSurface(child) |
| 813 | ->damage_tracker() |
| 814 | ->has_damage_from_contributing_content()); |
weiliangc | d68cf71 | 2016-05-02 23:29:07 | [diff] [blame] | 815 | } |
| 816 | |
| 817 | TEST_F(DamageTrackerTest, VerifyDamageForTransformedImageFilter) { |
| 818 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 819 | LayerImpl* child = root->test_properties()->children[0]; |
weiliangc | d68cf71 | 2016-05-02 23:29:07 | [diff] [blame] | 820 | gfx::Rect root_damage_rect, child_damage_rect; |
| 821 | |
| 822 | // Allow us to set damage on child too. |
| 823 | child->SetDrawsContent(true); |
| 824 | |
| 825 | FilterOperations filters; |
Khushal | 7865b5be | 2017-11-22 03:12:06 | [diff] [blame] | 826 | filters.Append( |
| 827 | FilterOperation::CreateReferenceFilter(sk_make_sp<BlurPaintFilter>( |
| 828 | 2, 2, BlurPaintFilter::TileMode::kClampToBlack_TileMode, nullptr))); |
weiliangc | d68cf71 | 2016-05-02 23:29:07 | [diff] [blame] | 829 | |
| 830 | // Setting the filter will damage the whole surface. |
| 831 | gfx::Transform transform; |
| 832 | transform.RotateAboutYAxis(60); |
| 833 | ClearDamageForAllSurfaces(root); |
| 834 | child->test_properties()->force_render_surface = true; |
jaydasika | 10d43fc | 2016-08-18 04:06:04 | [diff] [blame] | 835 | child->test_properties()->transform = transform; |
weiliangc | d68cf71 | 2016-05-02 23:29:07 | [diff] [blame] | 836 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 837 | EmulateDrawingOneFrame(root); |
weiliangc | ea09f337 | 2017-03-29 16:43:24 | [diff] [blame] | 838 | child->layer_tree_impl()->SetFilterMutated(child->element_id(), filters); |
weiliangc | d68cf71 | 2016-05-02 23:29:07 | [diff] [blame] | 839 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 840 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 841 | &root_damage_rect)); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 842 | EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 843 | &child_damage_rect)); |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 844 | |
| 845 | // Blur outset is 6px for a 2px blur. |
| 846 | int blur_outset = 6; |
| 847 | int rotated_outset_left = blur_outset / 2; |
| 848 | int expected_rotated_width = (30 + 2 * blur_outset) / 2; |
| 849 | gfx::Rect expected_root_damage(100 - rotated_outset_left, 100 - blur_outset, |
| 850 | expected_rotated_width, 30 + 2 * blur_outset); |
weiliangc | d68cf71 | 2016-05-02 23:29:07 | [diff] [blame] | 851 | expected_root_damage.Union(gfx::Rect(100, 100, 30, 30)); |
| 852 | EXPECT_EQ(expected_root_damage, root_damage_rect); |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 853 | EXPECT_EQ(gfx::Rect(-blur_outset, -blur_outset, 30 + 2 * blur_outset, |
| 854 | 30 + 2 * blur_outset), |
| 855 | child_damage_rect); |
weiliangc | d68cf71 | 2016-05-02 23:29:07 | [diff] [blame] | 856 | |
| 857 | // Setting the update rect should damage the whole surface (for now) |
| 858 | ClearDamageForAllSurfaces(root); |
| 859 | child->SetUpdateRect(gfx::Rect(30, 30)); |
weiliangc | d68cf71 | 2016-05-02 23:29:07 | [diff] [blame] | 860 | EmulateDrawingOneFrame(root); |
| 861 | |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 862 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 863 | &root_damage_rect)); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 864 | EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 865 | &child_damage_rect)); |
weiliangc | d68cf71 | 2016-05-02 23:29:07 | [diff] [blame] | 866 | |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 867 | int expect_width = 30 + 2 * blur_outset; |
| 868 | int expect_height = 30 + 2 * blur_outset; |
| 869 | EXPECT_EQ(gfx::Rect(100 - blur_outset / 2, 100 - blur_outset, |
| 870 | expect_width / 2, expect_height), |
weiliangc | d68cf71 | 2016-05-02 23:29:07 | [diff] [blame] | 871 | root_damage_rect); |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 872 | EXPECT_EQ(gfx::Rect(-blur_outset, -blur_outset, expect_width, expect_height), |
weiliangc | d68cf71 | 2016-05-02 23:29:07 | [diff] [blame] | 873 | child_damage_rect); |
[email protected] | 4000abf | 2012-10-23 04:45:45 | [diff] [blame] | 874 | } |
| 875 | |
senorblanco | 2bc7c61 | 2016-08-12 19:34:17 | [diff] [blame] | 876 | TEST_F(DamageTrackerTest, VerifyDamageForHighDPIImageFilter) { |
| 877 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 878 | LayerImpl* child = root->test_properties()->children[0]; |
| 879 | gfx::Rect root_damage_rect, child_damage_rect; |
| 880 | |
| 881 | // Allow us to set damage on child too. |
| 882 | child->SetDrawsContent(true); |
| 883 | |
| 884 | FilterOperations filters; |
| 885 | filters.Append(FilterOperation::CreateBlurFilter(3.f)); |
| 886 | |
| 887 | // Setting the filter will damage the whole surface. |
| 888 | ClearDamageForAllSurfaces(root); |
| 889 | child->test_properties()->force_render_surface = true; |
| 890 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 891 | int device_scale_factor = 2; |
| 892 | EmulateDrawingOneFrame(root, device_scale_factor); |
weiliangc | ea09f337 | 2017-03-29 16:43:24 | [diff] [blame] | 893 | child->layer_tree_impl()->SetFilterMutated(child->element_id(), filters); |
senorblanco | 2bc7c61 | 2016-08-12 19:34:17 | [diff] [blame] | 894 | EmulateDrawingOneFrame(root, device_scale_factor); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 895 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 896 | &root_damage_rect)); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 897 | EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 898 | &child_damage_rect)); |
senorblanco | 2bc7c61 | 2016-08-12 19:34:17 | [diff] [blame] | 899 | |
| 900 | // Blur outset is 9px for a 3px blur, scaled up by DSF. |
| 901 | int blur_outset = 9 * device_scale_factor; |
| 902 | gfx::Rect original_rect(100, 100, 100, 100); |
| 903 | gfx::Rect expected_child_damage_rect(60, 60); |
| 904 | expected_child_damage_rect.Inset(-blur_outset, -blur_outset); |
| 905 | gfx::Rect expected_root_damage_rect(child_damage_rect); |
| 906 | expected_root_damage_rect.Offset(200, 200); |
| 907 | gfx::Rect expected_total_damage_rect = expected_root_damage_rect; |
| 908 | expected_total_damage_rect.Union(original_rect); |
| 909 | EXPECT_EQ(expected_total_damage_rect, root_damage_rect); |
| 910 | EXPECT_EQ(expected_child_damage_rect, child_damage_rect); |
| 911 | |
| 912 | // Setting the update rect should damage only the affected area (original, |
| 913 | // outset by 3 * blur sigma * DSF). |
| 914 | ClearDamageForAllSurfaces(root); |
| 915 | child->SetUpdateRect(gfx::Rect(30, 30)); |
| 916 | EmulateDrawingOneFrame(root, device_scale_factor); |
| 917 | |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 918 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 919 | &root_damage_rect)); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 920 | EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 921 | &child_damage_rect)); |
senorblanco | 2bc7c61 | 2016-08-12 19:34:17 | [diff] [blame] | 922 | |
| 923 | EXPECT_EQ(expected_root_damage_rect, root_damage_rect); |
| 924 | EXPECT_EQ(expected_child_damage_rect, child_damage_rect); |
| 925 | } |
| 926 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 927 | TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 928 | LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 929 | LayerImpl* child1 = root->test_properties()->children[0]; |
| 930 | LayerImpl* child2 = root->test_properties()->children[1]; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 931 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 932 | // Allow us to set damage on child1 too. |
| 933 | child1->SetDrawsContent(true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 934 | |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 935 | FilterOperations filters; |
| 936 | filters.Append(FilterOperation::CreateBlurFilter(2.f)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 937 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 938 | // Setting the filter will damage the whole surface. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 939 | ClearDamageForAllSurfaces(root); |
ajuma | 50bce7e | 2016-06-24 20:56:04 | [diff] [blame] | 940 | child1->test_properties()->background_filters = filters; |
| 941 | child1->NoteLayerPropertyChanged(); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 942 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 943 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 944 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 945 | // CASE 1: Setting the update rect should cause the corresponding damage to |
| 946 | // the surface, blurred based on the size of the child's background |
jbroman | 8eb5fb7 | 2016-06-01 18:44:16 | [diff] [blame] | 947 | // blur filter. Note that child1's render surface has a size of |
| 948 | // 206x208 due to contributions from grand_child1 and grand_child2. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 949 | ClearDamageForAllSurfaces(root); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 950 | root->SetUpdateRect(gfx::Rect(297, 297, 2, 2)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 951 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 952 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 953 | |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 954 | gfx::Rect root_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 955 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 956 | &root_damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 957 | // Damage position on the surface should be a composition of the damage on |
| 958 | // the root and on child2. Damage on the root should be: position of |
| 959 | // update_rect (297, 297), but expanded by the blur outsets. |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 960 | gfx::Rect expected_damage_rect = gfx::Rect(297, 297, 2, 2); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 961 | |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 962 | // 6px spread for a 2px blur. |
| 963 | expected_damage_rect.Inset(-6, -6, -6, -6); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 964 | EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 965 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 966 | // CASE 2: Setting the update rect should cause the corresponding damage to |
| 967 | // the surface, blurred based on the size of the child's background |
| 968 | // blur filter. Since the damage extends to the right/bottom outside |
| 969 | // of the blurred layer, only the left/top should end up expanded. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 970 | ClearDamageForAllSurfaces(root); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 971 | root->SetUpdateRect(gfx::Rect(297, 297, 30, 30)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 972 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 973 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 974 | |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 975 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 976 | &root_damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 977 | // Damage position on the surface should be a composition of the damage on |
| 978 | // the root and on child2. Damage on the root should be: position of |
| 979 | // update_rect (297, 297), but expanded on the left/top by the blur outsets. |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 980 | expected_damage_rect = gfx::Rect(297, 297, 30, 30); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 981 | |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 982 | // 6px spread for a 2px blur. |
| 983 | expected_damage_rect.Inset(-6, -6, 0, 0); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 984 | EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 985 | |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 986 | // CASE 3: Setting this update rect outside the blurred content_bounds of the |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 987 | // blurred child1 will not cause it to be expanded. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 988 | ClearDamageForAllSurfaces(root); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 989 | root->SetUpdateRect(gfx::Rect(30, 30, 2, 2)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 990 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 991 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 992 | |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 993 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 994 | &root_damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 995 | // Damage on the root should be: position of update_rect (30, 30), not |
| 996 | // expanded. |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 997 | expected_damage_rect = gfx::Rect(30, 30, 2, 2); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 998 | |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 999 | EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1000 | |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 1001 | // CASE 4: Setting this update rect inside the blurred content_bounds but |
| 1002 | // outside the original content_bounds of the blurred child1 will |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1003 | // cause it to be expanded. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1004 | ClearDamageForAllSurfaces(root); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 1005 | root->SetUpdateRect(gfx::Rect(99, 99, 1, 1)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1006 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1007 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1008 | |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1009 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1010 | &root_damage_rect)); |
jbroman | 8eb5fb7 | 2016-06-01 18:44:16 | [diff] [blame] | 1011 | // Damage on the root should be: the originally damaged rect (99,99 1x1) |
| 1012 | // plus the rect that can influence with a 2px blur (93,93 13x13) intersected |
| 1013 | // with the surface rect (100,100 206x208). So no additional damage occurs |
| 1014 | // above or to the left, but there is additional damage within the blurred |
| 1015 | // area. |
| 1016 | expected_damage_rect = gfx::Rect(99, 99, 7, 7); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1017 | EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1018 | |
| 1019 | // CASE 5: Setting the update rect on child2, which is above child1, will |
| 1020 | // not get blurred by child1, so it does not need to get expanded. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1021 | ClearDamageForAllSurfaces(root); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 1022 | child2->SetUpdateRect(gfx::Rect(1, 1)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1023 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1024 | EmulateDrawingOneFrame(root); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1025 | |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1026 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1027 | &root_damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1028 | // Damage on child2 should be: position of update_rect offset by the child's |
| 1029 | // position (11, 11), and not expanded by anything. |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1030 | expected_damage_rect = gfx::Rect(11, 11, 1, 1); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1031 | |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1032 | EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1033 | |
| 1034 | // CASE 6: Setting the update rect on child1 will also blur the damage, so |
| 1035 | // that any pixels needed for the blur are redrawn in the current |
| 1036 | // frame. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1037 | ClearDamageForAllSurfaces(root); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 1038 | child1->SetUpdateRect(gfx::Rect(1, 1)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1039 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1040 | EmulateDrawingOneFrame(root); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1041 | |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1042 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1043 | &root_damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1044 | // Damage on child1 should be: position of update_rect offset by the child's |
| 1045 | // position (100, 100), and expanded by the damage. |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1046 | |
jbroman | 8eb5fb7 | 2016-06-01 18:44:16 | [diff] [blame] | 1047 | // Damage should be (0,0 1x1), offset by the 100,100 offset of child1 in |
| 1048 | // root, and expanded 6px for the 2px blur (i.e., 94,94 13x13), but there |
| 1049 | // should be no damage outside child1 (i.e. none above or to the left of |
| 1050 | // 100,100. |
| 1051 | expected_damage_rect = gfx::Rect(100, 100, 7, 7); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1052 | EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); |
wutao | 92b48551 | 2017-07-29 02:04:17 | [diff] [blame] | 1053 | |
| 1054 | // CASE 7: No changes, so should not damage the surface. |
| 1055 | ClearDamageForAllSurfaces(root); |
| 1056 | // We want to make sure that the background filter doesn't cause empty damage |
| 1057 | // to get expanded. We position child1 so that an expansion of the empty rect |
| 1058 | // would have non-empty intersection with child1 in its target space (root |
| 1059 | // space). |
| 1060 | child1->SetPosition(gfx::PointF()); |
| 1061 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1062 | EmulateDrawingOneFrame(root); |
| 1063 | |
| 1064 | gfx::Rect child_damage_rect; |
| 1065 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
| 1066 | &root_damage_rect)); |
| 1067 | EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( |
| 1068 | &child_damage_rect)); |
| 1069 | |
| 1070 | // Should not be expanded by the blur filter. |
| 1071 | EXPECT_EQ(gfx::Rect(), root_damage_rect); |
| 1072 | EXPECT_EQ(gfx::Rect(), child_damage_rect); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1073 | } |
| 1074 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1075 | TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingLayer) { |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1076 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 1077 | LayerImpl* child1 = root->test_properties()->children[0]; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1078 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1079 | // CASE 1: Adding a new layer should cause the appropriate damage. |
| 1080 | // |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1081 | ClearDamageForAllSurfaces(root); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1082 | { |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 1083 | std::unique_ptr<LayerImpl> child2 = |
| 1084 | LayerImpl::Create(host_impl_.active_tree(), 3); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1085 | child2->SetPosition(gfx::PointF(400.f, 380.f)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1086 | child2->SetBounds(gfx::Size(6, 8)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1087 | child2->SetDrawsContent(true); |
jaydasika | 89f7b5a | 2016-06-22 02:08:39 | [diff] [blame] | 1088 | root->test_properties()->AddChild(std::move(child2)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1089 | } |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1090 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1091 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1092 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1093 | // Sanity check - all 3 layers should be on the same render surface; render |
| 1094 | // surfaces are tested elsewhere. |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1095 | ASSERT_EQ(3, GetRenderSurface(root)->num_contributors()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1096 | |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1097 | gfx::Rect root_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1098 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1099 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1100 | EXPECT_EQ(gfx::Rect(400, 380, 6, 8).ToString(), root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1101 | EXPECT_TRUE(GetRenderSurface(root) |
| 1102 | ->damage_tracker() |
| 1103 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1104 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1105 | // CASE 2: If the layer is removed, its entire old layer becomes exposed, not |
| 1106 | // just the last update rect. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1107 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1108 | // Advance one frame without damage so that we know the damage rect is not |
| 1109 | // leftover from the previous case. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1110 | ClearDamageForAllSurfaces(root); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1111 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1112 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1113 | |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1114 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1115 | &root_damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1116 | EXPECT_TRUE(root_damage_rect.IsEmpty()); |
| 1117 | |
| 1118 | // Then, test removing child1. |
jaydasika | 89f7b5a | 2016-06-22 02:08:39 | [diff] [blame] | 1119 | root->test_properties()->RemoveChild(child1); |
Ivan Kotenkov | 05d5754 | 2017-10-25 06:47:00 | [diff] [blame] | 1120 | child1 = nullptr; |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1121 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1122 | EmulateDrawingOneFrame(root); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1123 | |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1124 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1125 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1126 | EXPECT_EQ(gfx::Rect(100, 100, 30, 30).ToString(), |
| 1127 | root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1128 | EXPECT_TRUE(GetRenderSurface(root) |
| 1129 | ->damage_tracker() |
| 1130 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1131 | } |
| 1132 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1133 | TEST_F(DamageTrackerTest, VerifyDamageForNewUnchangedLayer) { |
| 1134 | // If child2 is added to the layer tree, but it doesn't have any explicit |
| 1135 | // damage of its own, it should still indeed damage the target surface. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1136 | |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1137 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1138 | |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1139 | ClearDamageForAllSurfaces(root); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1140 | { |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 1141 | std::unique_ptr<LayerImpl> child2 = |
| 1142 | LayerImpl::Create(host_impl_.active_tree(), 3); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1143 | child2->SetPosition(gfx::PointF(400.f, 380.f)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1144 | child2->SetBounds(gfx::Size(6, 8)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1145 | child2->SetDrawsContent(true); |
jaydasika | 89f7b5a | 2016-06-22 02:08:39 | [diff] [blame] | 1146 | root->test_properties()->AddChild(std::move(child2)); |
jaydasika | 4b0fd751 | 2016-06-09 18:12:53 | [diff] [blame] | 1147 | root->layer_tree_impl()->BuildLayerListForTesting(); |
jaydasika | d6f778b | 2016-05-19 22:51:26 | [diff] [blame] | 1148 | host_impl_.active_tree()->ResetAllChangeTracking(); |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1149 | LayerImpl* child2_ptr = host_impl_.active_tree()->LayerById(3); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1150 | // Sanity check the initial conditions of the test, if these asserts |
| 1151 | // trigger, it means the test no longer actually covers the intended |
| 1152 | // scenario. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1153 | ASSERT_FALSE(child2_ptr->LayerPropertyChanged()); |
| 1154 | ASSERT_TRUE(child2_ptr->update_rect().IsEmpty()); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1155 | } |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1156 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1157 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1158 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1159 | // Sanity check - all 3 layers should be on the same render surface; render |
| 1160 | // surfaces are tested elsewhere. |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1161 | ASSERT_EQ(3, GetRenderSurface(root)->num_contributors()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1162 | |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1163 | gfx::Rect root_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1164 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1165 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1166 | EXPECT_EQ(gfx::Rect(400, 380, 6, 8).ToString(), root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1167 | EXPECT_TRUE(GetRenderSurface(root) |
| 1168 | ->damage_tracker() |
| 1169 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1170 | } |
| 1171 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1172 | TEST_F(DamageTrackerTest, VerifyDamageForMultipleLayers) { |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1173 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 1174 | LayerImpl* child1 = root->test_properties()->children[0]; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1175 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1176 | // In this test we don't want the above tree manipulation to be considered |
| 1177 | // part of the same frame. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1178 | ClearDamageForAllSurfaces(root); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1179 | { |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 1180 | std::unique_ptr<LayerImpl> child2 = |
| 1181 | LayerImpl::Create(host_impl_.active_tree(), 3); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1182 | child2->SetPosition(gfx::PointF(400.f, 380.f)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1183 | child2->SetBounds(gfx::Size(6, 8)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1184 | child2->SetDrawsContent(true); |
jaydasika | 89f7b5a | 2016-06-22 02:08:39 | [diff] [blame] | 1185 | root->test_properties()->AddChild(std::move(child2)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1186 | } |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 1187 | LayerImpl* child2 = root->test_properties()->children[1]; |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1188 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1189 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1190 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1191 | // Damaging two layers simultaneously should cause combined damage. |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1192 | // - child1 update rect in surface space: gfx::Rect(100, 100, 1, 2); |
| 1193 | // - child2 update rect in surface space: gfx::Rect(400, 380, 3, 4); |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1194 | ClearDamageForAllSurfaces(root); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 1195 | child1->SetUpdateRect(gfx::Rect(1, 2)); |
| 1196 | child2->SetUpdateRect(gfx::Rect(3, 4)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1197 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1198 | EmulateDrawingOneFrame(root); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1199 | gfx::Rect root_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1200 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1201 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1202 | EXPECT_EQ(gfx::Rect(100, 100, 303, 284).ToString(), |
| 1203 | root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1204 | EXPECT_TRUE(GetRenderSurface(root) |
| 1205 | ->damage_tracker() |
| 1206 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1207 | } |
| 1208 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1209 | TEST_F(DamageTrackerTest, VerifyDamageForNestedSurfaces) { |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1210 | LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 1211 | LayerImpl* child1 = root->test_properties()->children[0]; |
| 1212 | LayerImpl* child2 = root->test_properties()->children[1]; |
| 1213 | LayerImpl* grand_child1 = |
| 1214 | root->test_properties()->children[0]->test_properties()->children[0]; |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 1215 | child2->test_properties()->force_render_surface = true; |
| 1216 | grand_child1->test_properties()->force_render_surface = true; |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1217 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1218 | EmulateDrawingOneFrame(root); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1219 | gfx::Rect child_damage_rect; |
| 1220 | gfx::Rect root_damage_rect; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1221 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1222 | // CASE 1: Damage to a descendant surface should propagate properly to |
| 1223 | // ancestor surface. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1224 | ClearDamageForAllSurfaces(root); |
weiliangc | ea09f337 | 2017-03-29 16:43:24 | [diff] [blame] | 1225 | root->layer_tree_impl()->SetOpacityMutated(grand_child1->element_id(), 0.5f); |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1226 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1227 | EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( |
| 1228 | &child_damage_rect)); |
| 1229 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1230 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1231 | EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); |
| 1232 | EXPECT_EQ(gfx::Rect(300, 300, 6, 8).ToString(), root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1233 | EXPECT_TRUE(GetRenderSurface(root) |
| 1234 | ->damage_tracker() |
| 1235 | ->has_damage_from_contributing_content()); |
| 1236 | EXPECT_TRUE(GetRenderSurface(child1) |
| 1237 | ->damage_tracker() |
| 1238 | ->has_damage_from_contributing_content()); |
| 1239 | EXPECT_FALSE(GetRenderSurface(child2) |
| 1240 | ->damage_tracker() |
| 1241 | ->has_damage_from_contributing_content()); |
| 1242 | EXPECT_FALSE(GetRenderSurface(grand_child1) |
| 1243 | ->damage_tracker() |
| 1244 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1245 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1246 | // CASE 2: Same as previous case, but with additional damage elsewhere that |
| 1247 | // should be properly unioned. |
| 1248 | // - child1 surface damage in root surface space: |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1249 | // gfx::Rect(300, 300, 6, 8); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1250 | // - child2 damage in root surface space: |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1251 | // gfx::Rect(11, 11, 18, 18); |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1252 | ClearDamageForAllSurfaces(root); |
weiliangc | ea09f337 | 2017-03-29 16:43:24 | [diff] [blame] | 1253 | root->layer_tree_impl()->SetOpacityMutated(grand_child1->element_id(), 0.7f); |
| 1254 | root->layer_tree_impl()->SetOpacityMutated(child2->element_id(), 0.7f); |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1255 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1256 | EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( |
| 1257 | &child_damage_rect)); |
| 1258 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1259 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1260 | EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); |
| 1261 | EXPECT_EQ(gfx::Rect(11, 11, 295, 297).ToString(), |
| 1262 | root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1263 | EXPECT_TRUE(GetRenderSurface(root) |
| 1264 | ->damage_tracker() |
| 1265 | ->has_damage_from_contributing_content()); |
| 1266 | EXPECT_TRUE(GetRenderSurface(child1) |
| 1267 | ->damage_tracker() |
| 1268 | ->has_damage_from_contributing_content()); |
| 1269 | EXPECT_FALSE(GetRenderSurface(child2) |
| 1270 | ->damage_tracker() |
| 1271 | ->has_damage_from_contributing_content()); |
| 1272 | EXPECT_FALSE(GetRenderSurface(grand_child1) |
| 1273 | ->damage_tracker() |
| 1274 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1275 | } |
| 1276 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1277 | TEST_F(DamageTrackerTest, VerifyDamageForSurfaceChangeFromDescendantLayer) { |
| 1278 | // If descendant layer changes and affects the content bounds of the render |
| 1279 | // surface, then the entire descendant surface should be damaged, and it |
| 1280 | // should damage its ancestor surface with the old and new surface regions. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1281 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1282 | // This is a tricky case, since only the first grand_child changes, but the |
| 1283 | // entire surface should be marked dirty. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1284 | |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1285 | LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 1286 | LayerImpl* child1 = root->test_properties()->children[0]; |
| 1287 | LayerImpl* grand_child1 = |
| 1288 | root->test_properties()->children[0]->test_properties()->children[0]; |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1289 | gfx::Rect child_damage_rect; |
| 1290 | gfx::Rect root_damage_rect; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1291 | |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1292 | ClearDamageForAllSurfaces(root); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1293 | grand_child1->SetPosition(gfx::PointF(195.f, 205.f)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1294 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1295 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1296 | EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( |
| 1297 | &child_damage_rect)); |
| 1298 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1299 | &root_damage_rect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1300 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1301 | // The new surface bounds should be damaged entirely, even though only one of |
| 1302 | // the layers changed. |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1303 | EXPECT_EQ(gfx::Rect(190, 190, 11, 23).ToString(), |
| 1304 | child_damage_rect.ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1305 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1306 | // Damage to the root surface should be the union of child1's *entire* render |
| 1307 | // surface (in target space), and its old exposed area (also in target |
| 1308 | // space). |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1309 | EXPECT_EQ(gfx::Rect(290, 290, 16, 23).ToString(), |
| 1310 | root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1311 | |
| 1312 | EXPECT_TRUE(GetRenderSurface(root) |
| 1313 | ->damage_tracker() |
| 1314 | ->has_damage_from_contributing_content()); |
| 1315 | EXPECT_TRUE(GetRenderSurface(child1) |
| 1316 | ->damage_tracker() |
| 1317 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1318 | } |
| 1319 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1320 | TEST_F(DamageTrackerTest, VerifyDamageForSurfaceChangeFromAncestorLayer) { |
| 1321 | // An ancestor/owning layer changes that affects the position/transform of |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 1322 | // the render surface. Note that in this case, the layer_property_changed flag |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1323 | // already propagates to the subtree (tested in LayerImpltest), which damages |
| 1324 | // the entire child1 surface, but the damage tracker still needs the correct |
| 1325 | // logic to compute the exposed region on the root surface. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1326 | |
[email protected] | 27d851ab | 2013-06-28 01:09:50 | [diff] [blame] | 1327 | // TODO(shawnsingh): the expectations of this test case should change when we |
| 1328 | // add support for a unique scissor_rect per RenderSurface. In that case, the |
| 1329 | // child1 surface should be completely unchanged, since we are only |
| 1330 | // transforming it, while the root surface would be damaged appropriately. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1331 | |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1332 | LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 1333 | LayerImpl* child1 = root->test_properties()->children[0]; |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1334 | gfx::Rect child_damage_rect; |
| 1335 | gfx::Rect root_damage_rect; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1336 | |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1337 | ClearDamageForAllSurfaces(root); |
ajuma | 816002e | 2016-09-23 23:30:42 | [diff] [blame] | 1338 | gfx::Transform translation; |
| 1339 | translation.Translate(-50.f, -50.f); |
weiliangc | ea09f337 | 2017-03-29 16:43:24 | [diff] [blame] | 1340 | root->layer_tree_impl()->SetTransformMutated(child1->element_id(), |
| 1341 | translation); |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1342 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1343 | EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( |
| 1344 | &child_damage_rect)); |
| 1345 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1346 | &root_damage_rect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1347 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1348 | // The new surface bounds should be damaged entirely. |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1349 | EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), |
| 1350 | child_damage_rect.ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1351 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1352 | // The entire child1 surface and the old exposed child1 surface should damage |
| 1353 | // the root surface. |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1354 | // - old child1 surface in target space: gfx::Rect(290, 290, 16, 18) |
| 1355 | // - new child1 surface in target space: gfx::Rect(240, 240, 16, 18) |
| 1356 | EXPECT_EQ(gfx::Rect(240, 240, 66, 68).ToString(), |
| 1357 | root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1358 | |
| 1359 | EXPECT_TRUE(GetRenderSurface(root) |
| 1360 | ->damage_tracker() |
| 1361 | ->has_damage_from_contributing_content()); |
| 1362 | EXPECT_FALSE(GetRenderSurface(child1) |
| 1363 | ->damage_tracker() |
| 1364 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1365 | } |
| 1366 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1367 | TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingRenderSurfaces) { |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1368 | LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 1369 | LayerImpl* child1 = root->test_properties()->children[0]; |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1370 | gfx::Rect child_damage_rect; |
| 1371 | gfx::Rect root_damage_rect; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1372 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1373 | // CASE 1: If a descendant surface disappears, its entire old area becomes |
| 1374 | // exposed. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1375 | ClearDamageForAllSurfaces(root); |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 1376 | child1->test_properties()->force_render_surface = false; |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1377 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1378 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1379 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1380 | // Sanity check that there is only one surface now. |
chrishtr | 5f60ca0 | 2017-05-11 23:09:49 | [diff] [blame] | 1381 | ASSERT_EQ(GetRenderSurface(child1), GetRenderSurface(root)); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1382 | ASSERT_EQ(4, GetRenderSurface(root)->num_contributors()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1383 | |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1384 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1385 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1386 | EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(), |
| 1387 | root_damage_rect.ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1388 | |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1389 | EXPECT_TRUE(GetRenderSurface(root) |
| 1390 | ->damage_tracker() |
| 1391 | ->has_damage_from_contributing_content()); |
| 1392 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1393 | // CASE 2: If a descendant surface appears, its entire old area becomes |
| 1394 | // exposed. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1395 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1396 | // Cycle one frame of no change, just to sanity check that the next rect is |
| 1397 | // not because of the old damage state. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1398 | ClearDamageForAllSurfaces(root); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1399 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1400 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1401 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1402 | &root_damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1403 | EXPECT_TRUE(root_damage_rect.IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1404 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1405 | // Then change the tree so that the render surface is added back. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1406 | ClearDamageForAllSurfaces(root); |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 1407 | child1->test_properties()->force_render_surface = true; |
awoloszyn | e83f28c | 2014-12-22 15:40:00 | [diff] [blame] | 1408 | |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1409 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1410 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1411 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1412 | // Sanity check that there is a new surface now. |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1413 | ASSERT_TRUE(GetRenderSurface(child1)); |
| 1414 | EXPECT_EQ(3, GetRenderSurface(root)->num_contributors()); |
| 1415 | EXPECT_EQ(2, GetRenderSurface(child1)->num_contributors()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1416 | |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1417 | EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( |
| 1418 | &child_damage_rect)); |
| 1419 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1420 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1421 | EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), |
| 1422 | child_damage_rect.ToString()); |
| 1423 | EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(), |
| 1424 | root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1425 | EXPECT_TRUE(GetRenderSurface(root) |
| 1426 | ->damage_tracker() |
| 1427 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1428 | } |
| 1429 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1430 | TEST_F(DamageTrackerTest, VerifyNoDamageWhenNothingChanged) { |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1431 | LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 1432 | LayerImpl* child1 = root->test_properties()->children[0]; |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1433 | gfx::Rect child_damage_rect; |
| 1434 | gfx::Rect root_damage_rect; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1435 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1436 | // CASE 1: If nothing changes, the damage rect should be empty. |
| 1437 | // |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1438 | ClearDamageForAllSurfaces(root); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1439 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1440 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1441 | EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( |
| 1442 | &child_damage_rect)); |
| 1443 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1444 | &root_damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1445 | EXPECT_TRUE(child_damage_rect.IsEmpty()); |
| 1446 | EXPECT_TRUE(root_damage_rect.IsEmpty()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1447 | EXPECT_FALSE(GetRenderSurface(root) |
| 1448 | ->damage_tracker() |
| 1449 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1450 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1451 | // CASE 2: If nothing changes twice in a row, the damage rect should still be |
| 1452 | // empty. |
| 1453 | // |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1454 | ClearDamageForAllSurfaces(root); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1455 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1456 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1457 | EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( |
| 1458 | &child_damage_rect)); |
| 1459 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1460 | &root_damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1461 | EXPECT_TRUE(child_damage_rect.IsEmpty()); |
| 1462 | EXPECT_TRUE(root_damage_rect.IsEmpty()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1463 | EXPECT_FALSE(GetRenderSurface(root) |
| 1464 | ->damage_tracker() |
| 1465 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1466 | } |
| 1467 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1468 | TEST_F(DamageTrackerTest, VerifyNoDamageForUpdateRectThatDoesNotDrawContent) { |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1469 | LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 1470 | LayerImpl* child1 = root->test_properties()->children[0]; |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1471 | gfx::Rect child_damage_rect; |
| 1472 | gfx::Rect root_damage_rect; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1473 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1474 | // In our specific tree, the update rect of child1 should not cause any |
| 1475 | // damage to any surface because it does not actually draw content. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1476 | ClearDamageForAllSurfaces(root); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 1477 | child1->SetUpdateRect(gfx::Rect(1, 2)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1478 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1479 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1480 | EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( |
| 1481 | &child_damage_rect)); |
| 1482 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1483 | &root_damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1484 | EXPECT_TRUE(child_damage_rect.IsEmpty()); |
| 1485 | EXPECT_TRUE(root_damage_rect.IsEmpty()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1486 | EXPECT_FALSE(GetRenderSurface(root) |
| 1487 | ->damage_tracker() |
| 1488 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1489 | } |
| 1490 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1491 | TEST_F(DamageTrackerTest, VerifyDamageForMask) { |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1492 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 1493 | LayerImpl* child = root->test_properties()->children[0]; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1494 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1495 | // In the current implementation of the damage tracker, changes to mask |
| 1496 | // layers should damage the entire corresponding surface. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1497 | |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1498 | ClearDamageForAllSurfaces(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1499 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1500 | // Set up the mask layer. |
| 1501 | { |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 1502 | std::unique_ptr<LayerImpl> mask_layer = |
| 1503 | LayerImpl::Create(host_impl_.active_tree(), 3); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1504 | mask_layer->SetPosition(child->position()); |
bokan | cccfde7 | 2014-10-08 15:15:22 | [diff] [blame] | 1505 | mask_layer->SetBounds(child->bounds()); |
ajuma | 1d4026a3 | 2016-06-14 13:18:50 | [diff] [blame] | 1506 | child->test_properties()->SetMaskLayer(std::move(mask_layer)); |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 1507 | child->test_properties()->force_render_surface = true; |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1508 | } |
ajuma | 1d4026a3 | 2016-06-14 13:18:50 | [diff] [blame] | 1509 | LayerImpl* mask_layer = child->test_properties()->mask_layer; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1510 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1511 | // Add opacity and a grand_child so that the render surface persists even |
| 1512 | // after we remove the mask. |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1513 | { |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 1514 | std::unique_ptr<LayerImpl> grand_child = |
| 1515 | LayerImpl::Create(host_impl_.active_tree(), 4); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1516 | grand_child->SetPosition(gfx::PointF(2.f, 2.f)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1517 | grand_child->SetBounds(gfx::Size(2, 2)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1518 | grand_child->SetDrawsContent(true); |
jaydasika | 89f7b5a | 2016-06-22 02:08:39 | [diff] [blame] | 1519 | child->test_properties()->AddChild(std::move(grand_child)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1520 | } |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1521 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1522 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1523 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1524 | // CASE 1: the update_rect on a mask layer should damage the entire target |
| 1525 | // surface. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1526 | ClearDamageForAllSurfaces(root); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 1527 | mask_layer->SetUpdateRect(gfx::Rect(1, 2, 3, 4)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1528 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1529 | EmulateDrawingOneFrame(root); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1530 | gfx::Rect child_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1531 | EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1532 | &child_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1533 | EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1534 | |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1535 | EXPECT_TRUE(GetRenderSurface(root) |
| 1536 | ->damage_tracker() |
| 1537 | ->has_damage_from_contributing_content()); |
| 1538 | EXPECT_FALSE(GetRenderSurface(child) |
| 1539 | ->damage_tracker() |
| 1540 | ->has_damage_from_contributing_content()); |
| 1541 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1542 | // CASE 2: a property change on the mask layer should damage the entire |
| 1543 | // target surface. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1544 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1545 | // Advance one frame without damage so that we know the damage rect is not |
| 1546 | // leftover from the previous case. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1547 | ClearDamageForAllSurfaces(root); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1548 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1549 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1550 | EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1551 | &child_damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1552 | EXPECT_TRUE(child_damage_rect.IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1553 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1554 | // Then test the property change. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1555 | ClearDamageForAllSurfaces(root); |
jaydasika | 865fd48 | 2016-02-24 09:26:15 | [diff] [blame] | 1556 | mask_layer->NoteLayerPropertyChanged(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1557 | |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1558 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1559 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1560 | EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1561 | &child_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1562 | EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1563 | |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1564 | EXPECT_TRUE(GetRenderSurface(root) |
| 1565 | ->damage_tracker() |
| 1566 | ->has_damage_from_contributing_content()); |
| 1567 | EXPECT_FALSE(GetRenderSurface(child) |
| 1568 | ->damage_tracker() |
| 1569 | ->has_damage_from_contributing_content()); |
| 1570 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1571 | // CASE 3: removing the mask also damages the entire target surface. |
| 1572 | // |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1573 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1574 | // Advance one frame without damage so that we know the damage rect is not |
| 1575 | // leftover from the previous case. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1576 | ClearDamageForAllSurfaces(root); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1577 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1578 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1579 | EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1580 | &child_damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1581 | EXPECT_TRUE(child_damage_rect.IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1582 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1583 | // Then test mask removal. |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1584 | ClearDamageForAllSurfaces(root); |
ajuma | 1d4026a3 | 2016-06-14 13:18:50 | [diff] [blame] | 1585 | child->test_properties()->SetMaskLayer(nullptr); |
jaydasika | 03a99c4 | 2016-02-11 21:07:08 | [diff] [blame] | 1586 | child->NoteLayerPropertyChanged(); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1587 | ASSERT_TRUE(child->LayerPropertyChanged()); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1588 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1589 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1590 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1591 | // Sanity check that a render surface still exists. |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1592 | ASSERT_TRUE(GetRenderSurface(child)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1593 | |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1594 | EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1595 | &child_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1596 | EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1597 | |
| 1598 | EXPECT_TRUE(GetRenderSurface(root) |
| 1599 | ->damage_tracker() |
| 1600 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1601 | } |
| 1602 | |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 1603 | TEST_F(DamageTrackerTest, DamageWhenAddedExternally) { |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1604 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 1605 | LayerImpl* child = root->test_properties()->children[0]; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1606 | |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 1607 | // Case 1: This test ensures that when the tracker is given damage, that |
| 1608 | // it is included with any other partial damage. |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1609 | // |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1610 | ClearDamageForAllSurfaces(root); |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 1611 | child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1612 | GetRenderSurface(root)->damage_tracker()->AddDamageNextUpdate( |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1613 | gfx::Rect(15, 16, 32, 33)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1614 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1615 | EmulateDrawingOneFrame(root); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1616 | gfx::Rect root_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1617 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1618 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1619 | EXPECT_EQ(gfx::UnionRects(gfx::Rect(15, 16, 32, 33), |
| 1620 | gfx::Rect(100 + 10, 100 + 11, 12, 13)).ToString(), |
| 1621 | root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1622 | EXPECT_TRUE(GetRenderSurface(root) |
| 1623 | ->damage_tracker() |
| 1624 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1625 | |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 1626 | // Case 2: An additional sanity check that adding damage works even when |
| 1627 | // nothing on the layer tree changed. |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1628 | // |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1629 | ClearDamageForAllSurfaces(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1630 | GetRenderSurface(root)->damage_tracker()->AddDamageNextUpdate( |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1631 | gfx::Rect(30, 31, 14, 15)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1632 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1633 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1634 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1635 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1636 | EXPECT_EQ(gfx::Rect(30, 31, 14, 15).ToString(), root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1637 | EXPECT_FALSE(GetRenderSurface(root) |
| 1638 | ->damage_tracker() |
| 1639 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1640 | } |
| 1641 | |
ajuma | 9c92fa02 | 2017-04-18 19:53:08 | [diff] [blame] | 1642 | TEST_F(DamageTrackerTest, VerifyDamageWithNoContributingLayers) { |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 1643 | std::unique_ptr<LayerImpl> root = |
| 1644 | LayerImpl::Create(host_impl_.active_tree(), 1); |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 1645 | root->test_properties()->force_render_surface = true; |
jaydasika | bf1875a | 2016-06-28 03:39:59 | [diff] [blame] | 1646 | host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 1647 | LayerImpl* root_ptr = host_impl_.active_tree()->root_layer_for_testing(); |
jaydasika | 2411692c | 2016-03-23 01:56:09 | [diff] [blame] | 1648 | root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1649 | EmulateDrawingOneFrame(root_ptr); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1650 | |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1651 | DCHECK_EQ(GetRenderSurface(root_ptr), root_ptr->render_target()); |
| 1652 | RenderSurfaceImpl* target_surface = GetRenderSurface(root_ptr); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1653 | gfx::Rect damage_rect; |
| 1654 | EXPECT_TRUE( |
| 1655 | target_surface->damage_tracker()->GetDamageRectIfValid(&damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1656 | EXPECT_TRUE(damage_rect.IsEmpty()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1657 | EXPECT_FALSE(GetRenderSurface(root_ptr) |
| 1658 | ->damage_tracker() |
| 1659 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1660 | } |
| 1661 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1662 | TEST_F(DamageTrackerTest, VerifyDamageAccumulatesUntilReset) { |
| 1663 | // If damage is not cleared, it should accumulate. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1664 | |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1665 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 1666 | LayerImpl* child = root->test_properties()->children[0]; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1667 | |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1668 | ClearDamageForAllSurfaces(root); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1669 | child->SetUpdateRect(gfx::Rect(10.f, 11.f, 1.f, 2.f)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1670 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1671 | EmulateDrawingOneFrame(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1672 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1673 | // Sanity check damage after the first frame; this isnt the actual test yet. |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1674 | gfx::Rect root_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1675 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1676 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1677 | EXPECT_EQ(gfx::Rect(110, 111, 1, 2).ToString(), root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1678 | EXPECT_TRUE(GetRenderSurface(root) |
| 1679 | ->damage_tracker() |
| 1680 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1681 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1682 | // New damage, without having cleared the previous damage, should be unioned |
| 1683 | // to the previous one. |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 1684 | child->SetUpdateRect(gfx::Rect(20, 25, 1, 2)); |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1685 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1686 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1687 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1688 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1689 | EXPECT_EQ(gfx::Rect(110, 111, 11, 16).ToString(), |
| 1690 | root_damage_rect.ToString()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1691 | EXPECT_TRUE(GetRenderSurface(root) |
| 1692 | ->damage_tracker() |
| 1693 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1694 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1695 | // If we notify the damage tracker that we drew the damaged area, then damage |
| 1696 | // should be emptied. |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1697 | GetRenderSurface(root)->damage_tracker()->DidDrawDamagedArea(); |
| 1698 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1699 | &root_damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1700 | EXPECT_TRUE(root_damage_rect.IsEmpty()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1701 | EXPECT_FALSE(GetRenderSurface(root) |
| 1702 | ->damage_tracker() |
| 1703 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1704 | |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1705 | // Damage should remain empty even after one frame, since there's yet no new |
| 1706 | // damage. |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1707 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 1708 | EmulateDrawingOneFrame(root); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1709 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1710 | &root_damage_rect)); |
[email protected] | 035441d9 | 2013-03-22 23:21:39 | [diff] [blame] | 1711 | EXPECT_TRUE(root_damage_rect.IsEmpty()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1712 | EXPECT_FALSE(GetRenderSurface(root) |
| 1713 | ->damage_tracker() |
| 1714 | ->has_damage_from_contributing_content()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1715 | } |
| 1716 | |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1717 | TEST_F(DamageTrackerTest, HugeDamageRect) { |
| 1718 | // This number is so large that we start losting floating point accuracy. |
| 1719 | const int kBigNumber = 900000000; |
| 1720 | // Walk over a range to find floating point inaccuracy boundaries that move |
| 1721 | // toward the wrong direction. |
| 1722 | const int kRange = 5000; |
| 1723 | |
| 1724 | for (int i = 0; i < kRange; ++i) { |
ajuma | 816002e | 2016-09-23 23:30:42 | [diff] [blame] | 1725 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
jaydasika | fc66cfb | 2016-06-10 04:34:22 | [diff] [blame] | 1726 | LayerImpl* child = root->test_properties()->children[0]; |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1727 | |
| 1728 | gfx::Transform transform; |
| 1729 | transform.Translate(-kBigNumber, -kBigNumber); |
| 1730 | |
| 1731 | // The child layer covers (0, 0, i, i) of the viewport, |
| 1732 | // but has a huge negative position. |
| 1733 | child->SetPosition(gfx::PointF()); |
| 1734 | child->SetBounds(gfx::Size(kBigNumber + i, kBigNumber + i)); |
jaydasika | 10d43fc | 2016-08-18 04:06:04 | [diff] [blame] | 1735 | child->test_properties()->transform = transform; |
jaydasika | 16515f5 | 2016-03-01 00:28:35 | [diff] [blame] | 1736 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
jaydasika | 5237db0 | 2016-09-20 01:34:30 | [diff] [blame] | 1737 | float device_scale_factor = 1.f; |
| 1738 | // Visible rects computed from combining clips in target space and root |
| 1739 | // space don't match because of the loss in floating point accuracy. So, we |
| 1740 | // skip verify_clip_tree_calculations. |
jaydasika | 3a6b1443 | 2017-03-21 23:11:19 | [diff] [blame] | 1741 | EmulateDrawingOneFrame(root, device_scale_factor); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1742 | |
| 1743 | // The expected damage should cover the visible part of the child layer, |
| 1744 | // which is (0, 0, i, i) in the viewport. |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1745 | gfx::Rect root_damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1746 | EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
| 1747 | &root_damage_rect)); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1748 | gfx::Rect damage_we_care_about = gfx::Rect(i, i); |
| 1749 | EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); |
| 1750 | EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1751 | EXPECT_TRUE(GetRenderSurface(root) |
| 1752 | ->damage_tracker() |
| 1753 | ->has_damage_from_contributing_content()); |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 1754 | } |
| 1755 | } |
| 1756 | |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1757 | TEST_F(DamageTrackerTest, DamageRectTooBig) { |
| 1758 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(2); |
| 1759 | LayerImpl* child1 = root->test_properties()->children[0]; |
| 1760 | LayerImpl* child2 = root->test_properties()->children[1]; |
| 1761 | |
| 1762 | // Really far left. |
| 1763 | child1->SetPosition(gfx::PointF(std::numeric_limits<int>::min() + 100, 0)); |
| 1764 | child1->SetBounds(gfx::Size(1, 1)); |
| 1765 | |
| 1766 | // Really far right. |
| 1767 | child2->SetPosition(gfx::PointF(std::numeric_limits<int>::max() - 100, 0)); |
| 1768 | child2->SetBounds(gfx::Size(1, 1)); |
| 1769 | |
| 1770 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1771 | float device_scale_factor = 1.f; |
jaydasika | 3a6b1443 | 2017-03-21 23:11:19 | [diff] [blame] | 1772 | EmulateDrawingOneFrame(root, device_scale_factor); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1773 | |
| 1774 | // The expected damage would be too large to store in a gfx::Rect, so we |
| 1775 | // should damage everything (ie, we don't have a valid rect). |
| 1776 | gfx::Rect damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1777 | EXPECT_FALSE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1778 | &damage_rect)); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1779 | EXPECT_EQ(GetRenderSurface(root)->content_rect(), |
| 1780 | GetRenderSurface(root)->GetDamageRect()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1781 | EXPECT_TRUE(GetRenderSurface(root) |
| 1782 | ->damage_tracker() |
| 1783 | ->has_damage_from_contributing_content()); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1784 | } |
| 1785 | |
| 1786 | TEST_F(DamageTrackerTest, DamageRectTooBigWithFilter) { |
| 1787 | LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(2); |
| 1788 | LayerImpl* child1 = root->test_properties()->children[0]; |
| 1789 | LayerImpl* child2 = root->test_properties()->children[1]; |
| 1790 | |
| 1791 | FilterOperations filters; |
| 1792 | filters.Append(FilterOperation::CreateBlurFilter(5.f)); |
| 1793 | root->SetDrawsContent(true); |
| 1794 | root->test_properties()->background_filters = filters; |
| 1795 | |
| 1796 | // Really far left. |
| 1797 | child1->SetPosition(gfx::PointF(std::numeric_limits<int>::min() + 100, 0)); |
| 1798 | child1->SetBounds(gfx::Size(1, 1)); |
| 1799 | |
| 1800 | // Really far right. |
| 1801 | child2->SetPosition(gfx::PointF(std::numeric_limits<int>::max() - 100, 0)); |
| 1802 | child2->SetBounds(gfx::Size(1, 1)); |
| 1803 | |
| 1804 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1805 | float device_scale_factor = 1.f; |
jaydasika | 3a6b1443 | 2017-03-21 23:11:19 | [diff] [blame] | 1806 | EmulateDrawingOneFrame(root, device_scale_factor); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1807 | |
| 1808 | // The expected damage would be too large to store in a gfx::Rect, so we |
| 1809 | // should damage everything (ie, we don't have a valid rect). |
| 1810 | gfx::Rect damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1811 | EXPECT_FALSE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1812 | &damage_rect)); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1813 | EXPECT_EQ(GetRenderSurface(root)->content_rect(), |
| 1814 | GetRenderSurface(root)->GetDamageRect()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1815 | EXPECT_TRUE(GetRenderSurface(root) |
| 1816 | ->damage_tracker() |
| 1817 | ->has_damage_from_contributing_content()); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1818 | } |
| 1819 | |
| 1820 | TEST_F(DamageTrackerTest, DamageRectTooBigInRenderSurface) { |
| 1821 | LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
| 1822 | LayerImpl* child1 = root->test_properties()->children[0]; |
| 1823 | LayerImpl* grandchild1 = child1->test_properties()->children[0]; |
| 1824 | LayerImpl* grandchild2 = child1->test_properties()->children[1]; |
| 1825 | |
| 1826 | // Really far left. |
| 1827 | grandchild1->SetPosition( |
| 1828 | gfx::PointF(std::numeric_limits<int>::min() + 500, 0)); |
| 1829 | grandchild1->SetBounds(gfx::Size(1, 1)); |
| 1830 | grandchild1->SetDrawsContent(true); |
| 1831 | |
| 1832 | // Really far right. |
| 1833 | grandchild2->SetPosition( |
| 1834 | gfx::PointF(std::numeric_limits<int>::max() - 500, 0)); |
| 1835 | grandchild2->SetBounds(gfx::Size(1, 1)); |
| 1836 | grandchild2->SetDrawsContent(true); |
| 1837 | |
| 1838 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1839 | float device_scale_factor = 1.f; |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 1840 | RenderSurfaceList render_surface_list; |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1841 | ExecuteCalculateDrawProperties(root, device_scale_factor, |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 1842 | &render_surface_list); |
ajuma | 9c92fa02 | 2017-04-18 19:53:08 | [diff] [blame] | 1843 | // Avoid the descendant-only property change path that skips unioning damage |
| 1844 | // from descendant layers. |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1845 | GetRenderSurface(child1)->NoteAncestorPropertyChanged(); |
ajuma | 9c92fa02 | 2017-04-18 19:53:08 | [diff] [blame] | 1846 | DamageTracker::UpdateDamageTracking(host_impl_.active_tree(), |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 1847 | render_surface_list); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1848 | |
| 1849 | // The expected damage would be too large to store in a gfx::Rect, so we |
| 1850 | // should damage everything on child1. |
| 1851 | gfx::Rect damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1852 | EXPECT_FALSE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( |
| 1853 | &damage_rect)); |
| 1854 | EXPECT_EQ(GetRenderSurface(child1)->content_rect(), |
| 1855 | GetRenderSurface(child1)->GetDamageRect()); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1856 | |
| 1857 | // However, the root should just use the child1 render surface's content rect |
| 1858 | // as damage. |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1859 | ASSERT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1860 | &damage_rect)); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1861 | EXPECT_TRUE(damage_rect.Contains(GetRenderSurface(root)->content_rect())); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1862 | EXPECT_TRUE(damage_rect.Contains( |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1863 | gfx::ToEnclosingRect(GetRenderSurface(child1)->DrawableContentRect()))); |
| 1864 | EXPECT_EQ(damage_rect, GetRenderSurface(root)->GetDamageRect()); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1865 | |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1866 | EXPECT_TRUE(GetRenderSurface(root) |
| 1867 | ->damage_tracker() |
| 1868 | ->has_damage_from_contributing_content()); |
| 1869 | EXPECT_TRUE(GetRenderSurface(child1) |
| 1870 | ->damage_tracker() |
| 1871 | ->has_damage_from_contributing_content()); |
| 1872 | |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1873 | // Add new damage, without changing properties, which goes down a different |
| 1874 | // path in the damage tracker. |
| 1875 | root->layer_tree_impl()->ResetAllChangeTracking(); |
| 1876 | grandchild1->AddDamageRect(gfx::Rect(grandchild1->bounds())); |
| 1877 | grandchild2->AddDamageRect(gfx::Rect(grandchild1->bounds())); |
| 1878 | |
| 1879 | // Recompute all damage / properties. |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 1880 | render_surface_list.clear(); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1881 | ExecuteCalculateDrawProperties(root, device_scale_factor, |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 1882 | &render_surface_list); |
ajuma | 9c92fa02 | 2017-04-18 19:53:08 | [diff] [blame] | 1883 | DamageTracker::UpdateDamageTracking(host_impl_.active_tree(), |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 1884 | render_surface_list); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1885 | |
| 1886 | // Child1 should still not have a valid rect, since the union of the damage of |
| 1887 | // its children is not representable by a single rect. |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1888 | EXPECT_FALSE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( |
| 1889 | &damage_rect)); |
| 1890 | EXPECT_EQ(GetRenderSurface(child1)->content_rect(), |
| 1891 | GetRenderSurface(child1)->GetDamageRect()); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1892 | |
| 1893 | // Root should have valid damage and contain both its content rect and the |
| 1894 | // drawable content rect of child1. |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1895 | ASSERT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1896 | &damage_rect)); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1897 | EXPECT_TRUE(damage_rect.Contains(GetRenderSurface(root)->content_rect())); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1898 | EXPECT_TRUE(damage_rect.Contains( |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1899 | gfx::ToEnclosingRect(GetRenderSurface(child1)->DrawableContentRect()))); |
| 1900 | EXPECT_EQ(damage_rect, GetRenderSurface(root)->GetDamageRect()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1901 | |
| 1902 | EXPECT_TRUE(GetRenderSurface(root) |
| 1903 | ->damage_tracker() |
| 1904 | ->has_damage_from_contributing_content()); |
| 1905 | EXPECT_TRUE(GetRenderSurface(child1) |
| 1906 | ->damage_tracker() |
| 1907 | ->has_damage_from_contributing_content()); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1908 | } |
| 1909 | |
| 1910 | TEST_F(DamageTrackerTest, DamageRectTooBigInRenderSurfaceWithFilter) { |
| 1911 | LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
| 1912 | LayerImpl* child1 = root->test_properties()->children[0]; |
| 1913 | LayerImpl* grandchild1 = child1->test_properties()->children[0]; |
| 1914 | LayerImpl* grandchild2 = child1->test_properties()->children[1]; |
| 1915 | |
| 1916 | // Set up a moving pixels filter on the child. |
| 1917 | FilterOperations filters; |
| 1918 | filters.Append(FilterOperation::CreateBlurFilter(5.f)); |
| 1919 | child1->SetDrawsContent(true); |
| 1920 | child1->test_properties()->background_filters = filters; |
| 1921 | |
| 1922 | // Really far left. |
| 1923 | grandchild1->SetPosition( |
| 1924 | gfx::PointF(std::numeric_limits<int>::min() + 500, 0)); |
| 1925 | grandchild1->SetBounds(gfx::Size(1, 1)); |
| 1926 | grandchild1->SetDrawsContent(true); |
| 1927 | |
| 1928 | // Really far right. |
| 1929 | grandchild2->SetPosition( |
| 1930 | gfx::PointF(std::numeric_limits<int>::max() - 500, 0)); |
| 1931 | grandchild2->SetBounds(gfx::Size(1, 1)); |
| 1932 | grandchild2->SetDrawsContent(true); |
| 1933 | |
| 1934 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1935 | float device_scale_factor = 1.f; |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 1936 | RenderSurfaceList render_surface_list; |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1937 | ExecuteCalculateDrawProperties(root, device_scale_factor, |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 1938 | &render_surface_list); |
ajuma | 9c92fa02 | 2017-04-18 19:53:08 | [diff] [blame] | 1939 | // Avoid the descendant-only property change path that skips unioning damage |
| 1940 | // from descendant layers. |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1941 | GetRenderSurface(child1)->NoteAncestorPropertyChanged(); |
ajuma | 9c92fa02 | 2017-04-18 19:53:08 | [diff] [blame] | 1942 | DamageTracker::UpdateDamageTracking(host_impl_.active_tree(), |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 1943 | render_surface_list); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1944 | |
| 1945 | // The expected damage would be too large to store in a gfx::Rect, so we |
| 1946 | // should damage everything on child1. |
| 1947 | gfx::Rect damage_rect; |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1948 | EXPECT_FALSE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( |
| 1949 | &damage_rect)); |
| 1950 | EXPECT_EQ(GetRenderSurface(child1)->content_rect(), |
| 1951 | GetRenderSurface(child1)->GetDamageRect()); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1952 | |
| 1953 | // However, the root should just use the child1 render surface's content rect |
| 1954 | // as damage. |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1955 | ASSERT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1956 | &damage_rect)); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1957 | EXPECT_TRUE(damage_rect.Contains(GetRenderSurface(root)->content_rect())); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1958 | EXPECT_TRUE(damage_rect.Contains( |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1959 | gfx::ToEnclosingRect(GetRenderSurface(child1)->DrawableContentRect()))); |
| 1960 | EXPECT_EQ(damage_rect, GetRenderSurface(root)->GetDamageRect()); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1961 | |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1962 | EXPECT_TRUE(GetRenderSurface(root) |
| 1963 | ->damage_tracker() |
| 1964 | ->has_damage_from_contributing_content()); |
| 1965 | EXPECT_TRUE(GetRenderSurface(child1) |
| 1966 | ->damage_tracker() |
| 1967 | ->has_damage_from_contributing_content()); |
| 1968 | |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1969 | // Add new damage, without changing properties, which goes down a different |
| 1970 | // path in the damage tracker. |
| 1971 | root->layer_tree_impl()->ResetAllChangeTracking(); |
| 1972 | grandchild1->AddDamageRect(gfx::Rect(grandchild1->bounds())); |
| 1973 | grandchild2->AddDamageRect(gfx::Rect(grandchild1->bounds())); |
| 1974 | |
| 1975 | // Recompute all damage / properties. |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 1976 | render_surface_list.clear(); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1977 | ExecuteCalculateDrawProperties(root, device_scale_factor, |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 1978 | &render_surface_list); |
ajuma | 9c92fa02 | 2017-04-18 19:53:08 | [diff] [blame] | 1979 | DamageTracker::UpdateDamageTracking(host_impl_.active_tree(), |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 1980 | render_surface_list); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1981 | |
| 1982 | // Child1 should still not have a valid rect, since the union of the damage of |
| 1983 | // its children is not representable by a single rect. |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1984 | EXPECT_FALSE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( |
| 1985 | &damage_rect)); |
| 1986 | EXPECT_EQ(GetRenderSurface(child1)->content_rect(), |
| 1987 | GetRenderSurface(child1)->GetDamageRect()); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1988 | |
| 1989 | // Root should have valid damage and contain both its content rect and the |
| 1990 | // drawable content rect of child1. |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1991 | ASSERT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1992 | &damage_rect)); |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1993 | EXPECT_TRUE(damage_rect.Contains(GetRenderSurface(root)->content_rect())); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 1994 | EXPECT_TRUE(damage_rect.Contains( |
chrishtr | 7e3aaf2 | 2017-05-04 15:04:01 | [diff] [blame] | 1995 | gfx::ToEnclosingRect(GetRenderSurface(child1)->DrawableContentRect()))); |
| 1996 | EXPECT_EQ(damage_rect, GetRenderSurface(root)->GetDamageRect()); |
wutao | 3685073 | 2017-07-29 20:24:07 | [diff] [blame] | 1997 | |
| 1998 | EXPECT_TRUE(GetRenderSurface(root) |
| 1999 | ->damage_tracker() |
| 2000 | ->has_damage_from_contributing_content()); |
| 2001 | EXPECT_TRUE(GetRenderSurface(child1) |
| 2002 | ->damage_tracker() |
| 2003 | ->has_damage_from_contributing_content()); |
vmpstr | efb8e7e | 2017-01-20 23:36:15 | [diff] [blame] | 2004 | } |
| 2005 | |
[email protected] | ba56574 | 2012-11-10 09:29:48 | [diff] [blame] | 2006 | } // namespace |
| 2007 | } // namespace cc |