Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Side by Side Diff: cc/trees/occlusion_tracker_unittest.cc

Issue 2124983003: cc: Remove uses of FilterOperations::GetOutsets in unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/damage_tracker_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/occlusion_tracker.h" 5 #include "cc/trees/occlusion_tracker.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
10 #include "cc/layers/layer.h" 10 #include "cc/layers/layer.h"
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 explicit OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter( 1430 explicit OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter(
1431 bool opaque_layers) 1431 bool opaque_layers)
1432 : OcclusionTrackerTest(opaque_layers) {} 1432 : OcclusionTrackerTest(opaque_layers) {}
1433 void RunMyTest() override { 1433 void RunMyTest() override {
1434 gfx::Transform scale_by_half; 1434 gfx::Transform scale_by_half;
1435 scale_by_half.Scale(0.5, 0.5); 1435 scale_by_half.Scale(0.5, 0.5);
1436 1436
1437 FilterOperations filters; 1437 FilterOperations filters;
1438 filters.Append(FilterOperation::CreateBlurFilter(10.f)); 1438 filters.Append(FilterOperation::CreateBlurFilter(10.f));
1439 1439
1440 // Save the distance of influence for the blur effect.
1441 int outset_top, outset_right, outset_bottom, outset_left;
1442 filters.GetOutsets(
1443 &outset_top, &outset_right, &outset_bottom, &outset_left);
1444
1445 enum Direction { 1440 enum Direction {
1446 LEFT, 1441 LEFT,
1447 RIGHT, 1442 RIGHT,
1448 TOP, 1443 TOP,
1449 BOTTOM, 1444 BOTTOM,
1450 LAST_DIRECTION = BOTTOM, 1445 LAST_DIRECTION = BOTTOM,
1451 }; 1446 };
1452 1447
1453 for (int i = 0; i <= LAST_DIRECTION; ++i) { 1448 for (int i = 0; i <= LAST_DIRECTION; ++i) {
1454 SCOPED_TRACE(i); 1449 SCOPED_TRACE(i);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 EXPECT_EQ(occlusion_inside_surface.ToString(), 1500 EXPECT_EQ(occlusion_inside_surface.ToString(),
1506 occlusion.occlusion_from_outside_target().ToString()); 1501 occlusion.occlusion_from_outside_target().ToString());
1507 1502
1508 // The surface has a background blur, so it needs pixels that are 1503 // The surface has a background blur, so it needs pixels that are
1509 // currently considered occluded in order to be drawn. So the pixels it 1504 // currently considered occluded in order to be drawn. So the pixels it
1510 // needs should be removed some the occluded area so that when we get to 1505 // needs should be removed some the occluded area so that when we get to
1511 // the parent they are drawn. 1506 // the parent they are drawn.
1512 this->VisitContributingSurface(filtered_surface, &occlusion); 1507 this->VisitContributingSurface(filtered_surface, &occlusion);
1513 this->EnterLayer(parent, &occlusion); 1508 this->EnterLayer(parent, &occlusion);
1514 1509
1510 // The spread due to a 10px blur is 30px.
1515 gfx::Rect expected_occlusion = occlusion_rect; 1511 gfx::Rect expected_occlusion = occlusion_rect;
1516 switch (i) { 1512 switch (i) {
1517 case LEFT: 1513 case LEFT:
1518 expected_occlusion.Inset(0, 0, outset_right, 0); 1514 expected_occlusion.Inset(0, 0, 30, 0);
1519 break; 1515 break;
1520 case RIGHT: 1516 case RIGHT:
1521 expected_occlusion.Inset(outset_right, 0, 0, 0); 1517 expected_occlusion.Inset(30, 0, 0, 0);
1522 break; 1518 break;
1523 case TOP: 1519 case TOP:
1524 expected_occlusion.Inset(0, 0, 0, outset_right); 1520 expected_occlusion.Inset(0, 0, 0, 30);
1525 break; 1521 break;
1526 case BOTTOM: 1522 case BOTTOM:
1527 expected_occlusion.Inset(0, outset_right, 0, 0); 1523 expected_occlusion.Inset(0, 30, 0, 0);
1528 break; 1524 break;
1529 } 1525 }
1530 1526
1531 EXPECT_EQ(expected_occlusion.ToString(), 1527 EXPECT_EQ(expected_occlusion.ToString(),
1532 occlusion.occlusion_from_inside_target().ToString()); 1528 occlusion.occlusion_from_inside_target().ToString());
1533 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); 1529 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
1534 1530
1535 this->DestroyLayers(); 1531 this->DestroyLayers();
1536 } 1532 }
1537 } 1533 }
(...skipping 28 matching lines...) Expand all
1566 gfx::Size(50, 50), true); 1562 gfx::Size(50, 50), true);
1567 1563
1568 // Filters make the layers own surfaces. 1564 // Filters make the layers own surfaces.
1569 filtered_surface1->test_properties()->force_render_surface = true; 1565 filtered_surface1->test_properties()->force_render_surface = true;
1570 filtered_surface2->test_properties()->force_render_surface = true; 1566 filtered_surface2->test_properties()->force_render_surface = true;
1571 FilterOperations filters; 1567 FilterOperations filters;
1572 filters.Append(FilterOperation::CreateBlurFilter(1.f)); 1568 filters.Append(FilterOperation::CreateBlurFilter(1.f));
1573 filtered_surface1->test_properties()->background_filters = filters; 1569 filtered_surface1->test_properties()->background_filters = filters;
1574 filtered_surface2->test_properties()->background_filters = filters; 1570 filtered_surface2->test_properties()->background_filters = filters;
1575 1571
1576 // Save the distance of influence for the blur effect.
1577 int outset_top, outset_right, outset_bottom, outset_left;
1578 filters.GetOutsets(
1579 &outset_top, &outset_right, &outset_bottom, &outset_left);
1580
1581 this->CalcDrawEtc(root); 1572 this->CalcDrawEtc(root);
1582 1573
1583 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); 1574 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
1584 1575
1585 this->VisitLayer(occluding_layer_above, &occlusion); 1576 this->VisitLayer(occluding_layer_above, &occlusion);
1586 EXPECT_EQ(gfx::Rect().ToString(), 1577 EXPECT_EQ(gfx::Rect().ToString(),
1587 occlusion.occlusion_from_outside_target().ToString()); 1578 occlusion.occlusion_from_outside_target().ToString());
1588 EXPECT_EQ(gfx::Rect(100 / 2, 100 / 2, 50 / 2, 50 / 2).ToString(), 1579 EXPECT_EQ(gfx::Rect(100 / 2, 100 / 2, 50 / 2, 50 / 2).ToString(),
1589 occlusion.occlusion_from_inside_target().ToString()); 1580 occlusion.occlusion_from_inside_target().ToString());
1590 1581
1591 this->VisitLayer(filtered_surface2, &occlusion); 1582 this->VisitLayer(filtered_surface2, &occlusion);
1592 this->VisitContributingSurface(filtered_surface2, &occlusion); 1583 this->VisitContributingSurface(filtered_surface2, &occlusion);
1593 this->VisitLayer(filtered_surface1, &occlusion); 1584 this->VisitLayer(filtered_surface1, &occlusion);
1594 this->VisitContributingSurface(filtered_surface1, &occlusion); 1585 this->VisitContributingSurface(filtered_surface1, &occlusion);
1595 1586
1596 // Test expectations in the target. 1587 // Test expectations in the target.
1588 int blur_outset = 3;
1597 gfx::Rect expected_occlusion = 1589 gfx::Rect expected_occlusion =
1598 gfx::Rect(100 / 2 + outset_right * 2, 1590 gfx::Rect(100 / 2 + blur_outset * 2, 100 / 2 + blur_outset * 2,
1599 100 / 2 + outset_bottom * 2, 1591 50 / 2 - blur_outset * 4, 50 / 2 - blur_outset * 4);
1600 50 / 2 - (outset_left + outset_right) * 2,
1601 50 / 2 - (outset_top + outset_bottom) * 2);
1602 EXPECT_EQ(expected_occlusion.ToString(), 1592 EXPECT_EQ(expected_occlusion.ToString(),
1603 occlusion.occlusion_from_inside_target().ToString()); 1593 occlusion.occlusion_from_inside_target().ToString());
1604 1594
1605 // Test expectations in the screen are the same as in the target, as the 1595 // Test expectations in the screen are the same as in the target, as the
1606 // render surface is 1:1 with the screen. 1596 // render surface is 1:1 with the screen.
1607 EXPECT_EQ(expected_occlusion.ToString(), 1597 EXPECT_EQ(expected_occlusion.ToString(),
1608 occlusion.occlusion_from_outside_target().ToString()); 1598 occlusion.occlusion_from_outside_target().ToString());
1609 } 1599 }
1610 }; 1600 };
1611 1601
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 LayerImpl* beside_replica_layer = this->CreateDrawingLayer( 1777 LayerImpl* beside_replica_layer = this->CreateDrawingLayer(
1788 parent, this->identity_matrix, gfx::PointF(200.f, 40.f), 1778 parent, this->identity_matrix, gfx::PointF(200.f, 40.f),
1789 gfx::Size(10, 10), true); 1779 gfx::Size(10, 10), true);
1790 1780
1791 // Filters make the layer own a surface. 1781 // Filters make the layer own a surface.
1792 filtered_surface->test_properties()->force_render_surface = true; 1782 filtered_surface->test_properties()->force_render_surface = true;
1793 FilterOperations filters; 1783 FilterOperations filters;
1794 filters.Append(FilterOperation::CreateBlurFilter(3.f)); 1784 filters.Append(FilterOperation::CreateBlurFilter(3.f));
1795 filtered_surface->test_properties()->background_filters = filters; 1785 filtered_surface->test_properties()->background_filters = filters;
1796 1786
1797 // Save the distance of influence for the blur effect.
1798 int outset_top, outset_right, outset_bottom, outset_left;
1799 filters.GetOutsets(
1800 &outset_top, &outset_right, &outset_bottom, &outset_left);
1801
1802 this->CalcDrawEtc(parent); 1787 this->CalcDrawEtc(parent);
1803 1788
1804 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); 1789 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
1805 1790
1806 this->VisitLayer(beside_replica_layer, &occlusion); 1791 this->VisitLayer(beside_replica_layer, &occlusion);
1807 this->VisitLayer(beside_surface_layer, &occlusion); 1792 this->VisitLayer(beside_surface_layer, &occlusion);
1808 this->VisitLayer(above_replica_layer, &occlusion); 1793 this->VisitLayer(above_replica_layer, &occlusion);
1809 this->VisitLayer(above_surface_layer, &occlusion); 1794 this->VisitLayer(above_surface_layer, &occlusion);
1810 1795
1811 // The surface has a background blur, so it blurs non-opaque pixels below 1796 // The surface has a background blur, so it blurs non-opaque pixels below
1812 // it. 1797 // it.
1813 this->VisitLayer(filtered_surface, &occlusion); 1798 this->VisitLayer(filtered_surface, &occlusion);
1814 this->VisitContributingSurface(filtered_surface, &occlusion); 1799 this->VisitContributingSurface(filtered_surface, &occlusion);
1815 1800
1816 // The filter in the surface and replica are partially unoccluded. Only the 1801 // The filter in the surface and replica are partially unoccluded. Only the
1817 // unoccluded parts should reduce occlusion. This means it will push back 1802 // unoccluded parts should reduce occlusion. This means it will push back
1818 // the occlusion that touches the unoccluded part (occlusion_above___), but 1803 // the occlusion that touches the unoccluded part (occlusion_above___), but
1819 // it will not touch occlusion_beside____ since that is not beside the 1804 // it will not touch occlusion_beside____ since that is not beside the
1820 // unoccluded part of the surface, even though it is beside the occluded 1805 // unoccluded part of the surface, even though it is beside the occluded
1821 // part of the surface. 1806 // part of the surface.
1807 int blur_outset = 9;
1822 gfx::Rect occlusion_above_surface = 1808 gfx::Rect occlusion_above_surface =
1823 gfx::Rect(70 + outset_right, 50, 30 - outset_right, 50); 1809 gfx::Rect(70 + blur_outset, 50, 30 - blur_outset, 50);
1824 gfx::Rect occlusion_above_replica = 1810 gfx::Rect occlusion_above_replica =
1825 gfx::Rect(200, 50, 30 - outset_left, 50); 1811 gfx::Rect(200, 50, 30 - blur_outset, 50);
1826 gfx::Rect occlusion_beside_surface = gfx::Rect(90, 40, 10, 10); 1812 gfx::Rect occlusion_beside_surface = gfx::Rect(90, 40, 10, 10);
1827 gfx::Rect occlusion_beside_replica = gfx::Rect(200, 40, 10, 10); 1813 gfx::Rect occlusion_beside_replica = gfx::Rect(200, 40, 10, 10);
1828 1814
1829 SimpleEnclosedRegion expected_occlusion; 1815 SimpleEnclosedRegion expected_occlusion;
1830 expected_occlusion.Union(occlusion_beside_replica); 1816 expected_occlusion.Union(occlusion_beside_replica);
1831 expected_occlusion.Union(occlusion_beside_surface); 1817 expected_occlusion.Union(occlusion_beside_surface);
1832 expected_occlusion.Union(occlusion_above_replica); 1818 expected_occlusion.Union(occlusion_above_replica);
1833 expected_occlusion.Union(occlusion_above_surface); 1819 expected_occlusion.Union(occlusion_above_surface);
1834 1820
1835 EXPECT_EQ(expected_occlusion.ToString(), 1821 EXPECT_EQ(expected_occlusion.ToString(),
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 EXPECT_EQ(gfx::Rect(), 2501 EXPECT_EQ(gfx::Rect(),
2516 occlusion.UnoccludedSurfaceContentRect( 2502 occlusion.UnoccludedSurfaceContentRect(
2517 surface, gfx::Rect(80, 70, 50, 50))); 2503 surface, gfx::Rect(80, 70, 50, 50)));
2518 } 2504 }
2519 }; 2505 };
2520 2506
2521 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) 2507 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery)
2522 2508
2523 } // namespace 2509 } // namespace
2524 } // namespace cc 2510 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/damage_tracker_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698