| OLD | NEW |
| 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 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1454 | 1454 |
| 1455 // Make a 50x50 filtered surface that is adjacent to occluding layers | 1455 // Make a 50x50 filtered surface that is adjacent to occluding layers |
| 1456 // which are above it in the z-order in various configurations. The | 1456 // which are above it in the z-order in various configurations. The |
| 1457 // surface is scaled to test that the pixel moving is done in the target | 1457 // surface is scaled to test that the pixel moving is done in the target |
| 1458 // space, where the background filter is applied. | 1458 // space, where the background filter is applied. |
| 1459 TestContentLayerImpl* parent = this->CreateRoot( | 1459 TestContentLayerImpl* parent = this->CreateRoot( |
| 1460 this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); | 1460 this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
| 1461 LayerImpl* filtered_surface = this->CreateDrawingLayer( | 1461 LayerImpl* filtered_surface = this->CreateDrawingLayer( |
| 1462 parent, scale_by_half, gfx::PointF(50.f, 50.f), gfx::Size(100, 100), | 1462 parent, scale_by_half, gfx::PointF(50.f, 50.f), gfx::Size(100, 100), |
| 1463 false); | 1463 false); |
| 1464 filtered_surface->SetBackgroundFilters(filters); | 1464 filtered_surface->test_properties()->background_filters = filters; |
| 1465 gfx::Rect occlusion_rect; | 1465 gfx::Rect occlusion_rect; |
| 1466 switch (i) { | 1466 switch (i) { |
| 1467 case LEFT: | 1467 case LEFT: |
| 1468 occlusion_rect = gfx::Rect(0, 0, 50, 200); | 1468 occlusion_rect = gfx::Rect(0, 0, 50, 200); |
| 1469 break; | 1469 break; |
| 1470 case RIGHT: | 1470 case RIGHT: |
| 1471 occlusion_rect = gfx::Rect(100, 0, 50, 200); | 1471 occlusion_rect = gfx::Rect(100, 0, 50, 200); |
| 1472 break; | 1472 break; |
| 1473 case TOP: | 1473 case TOP: |
| 1474 occlusion_rect = gfx::Rect(0, 0, 200, 50); | 1474 occlusion_rect = gfx::Rect(0, 0, 200, 50); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 parent, scale_by_half, gfx::PointF(), gfx::Size(300, 300), false); | 1562 parent, scale_by_half, gfx::PointF(), gfx::Size(300, 300), false); |
| 1563 LayerImpl* occluding_layer_above = this->CreateDrawingLayer( | 1563 LayerImpl* occluding_layer_above = this->CreateDrawingLayer( |
| 1564 parent, this->identity_matrix, gfx::PointF(100.f, 100.f), | 1564 parent, this->identity_matrix, gfx::PointF(100.f, 100.f), |
| 1565 gfx::Size(50, 50), true); | 1565 gfx::Size(50, 50), true); |
| 1566 | 1566 |
| 1567 // Filters make the layers own surfaces. | 1567 // Filters make the layers own surfaces. |
| 1568 filtered_surface1->test_properties()->force_render_surface = true; | 1568 filtered_surface1->test_properties()->force_render_surface = true; |
| 1569 filtered_surface2->test_properties()->force_render_surface = true; | 1569 filtered_surface2->test_properties()->force_render_surface = true; |
| 1570 FilterOperations filters; | 1570 FilterOperations filters; |
| 1571 filters.Append(FilterOperation::CreateBlurFilter(1.f)); | 1571 filters.Append(FilterOperation::CreateBlurFilter(1.f)); |
| 1572 filtered_surface1->SetBackgroundFilters(filters); | 1572 filtered_surface1->test_properties()->background_filters = filters; |
| 1573 filtered_surface2->SetBackgroundFilters(filters); | 1573 filtered_surface2->test_properties()->background_filters = filters; |
| 1574 | 1574 |
| 1575 // Save the distance of influence for the blur effect. | 1575 // Save the distance of influence for the blur effect. |
| 1576 int outset_top, outset_right, outset_bottom, outset_left; | 1576 int outset_top, outset_right, outset_bottom, outset_left; |
| 1577 filters.GetOutsets( | 1577 filters.GetOutsets( |
| 1578 &outset_top, &outset_right, &outset_bottom, &outset_left); | 1578 &outset_top, &outset_right, &outset_bottom, &outset_left); |
| 1579 | 1579 |
| 1580 this->CalcDrawEtc(root); | 1580 this->CalcDrawEtc(root); |
| 1581 | 1581 |
| 1582 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); | 1582 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
| 1583 | 1583 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1638 gfx::Size(100, 100), false); | 1638 gfx::Size(100, 100), false); |
| 1639 this->CreateReplicaLayer(filtered_surface, | 1639 this->CreateReplicaLayer(filtered_surface, |
| 1640 this->identity_matrix, | 1640 this->identity_matrix, |
| 1641 gfx::PointF(300.f, 0.f), | 1641 gfx::PointF(300.f, 0.f), |
| 1642 gfx::Size()); | 1642 gfx::Size()); |
| 1643 | 1643 |
| 1644 // Filters make the layer own a surface. | 1644 // Filters make the layer own a surface. |
| 1645 filtered_surface->test_properties()->force_render_surface = true; | 1645 filtered_surface->test_properties()->force_render_surface = true; |
| 1646 FilterOperations filters; | 1646 FilterOperations filters; |
| 1647 filters.Append(FilterOperation::CreateBlurFilter(3.f)); | 1647 filters.Append(FilterOperation::CreateBlurFilter(3.f)); |
| 1648 filtered_surface->SetBackgroundFilters(filters); | 1648 filtered_surface->test_properties()->background_filters = filters; |
| 1649 | 1649 |
| 1650 this->CalcDrawEtc(parent); | 1650 this->CalcDrawEtc(parent); |
| 1651 | 1651 |
| 1652 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); | 1652 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
| 1653 | 1653 |
| 1654 // The surface has a background blur, so it blurs non-opaque pixels below | 1654 // The surface has a background blur, so it blurs non-opaque pixels below |
| 1655 // it. | 1655 // it. |
| 1656 this->VisitLayer(filtered_surface, &occlusion); | 1656 this->VisitLayer(filtered_surface, &occlusion); |
| 1657 this->VisitContributingSurface(filtered_surface, &occlusion); | 1657 this->VisitContributingSurface(filtered_surface, &occlusion); |
| 1658 | 1658 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 this->CreateDrawingLayer(parent, scale_by_half, gfx::PointF(50.f, 50.f), | 1705 this->CreateDrawingLayer(parent, scale_by_half, gfx::PointF(50.f, 50.f), |
| 1706 gfx::Size(100, 100), false); | 1706 gfx::Size(100, 100), false); |
| 1707 LayerImpl* occluding_layer = this->CreateDrawingLayer( | 1707 LayerImpl* occluding_layer = this->CreateDrawingLayer( |
| 1708 parent, this->identity_matrix, gfx::PointF(50.f, 50.f), | 1708 parent, this->identity_matrix, gfx::PointF(50.f, 50.f), |
| 1709 gfx::Size(50, 50), true); | 1709 gfx::Size(50, 50), true); |
| 1710 | 1710 |
| 1711 // Filters make the layer own a surface. | 1711 // Filters make the layer own a surface. |
| 1712 filtered_surface->test_properties()->force_render_surface = true; | 1712 filtered_surface->test_properties()->force_render_surface = true; |
| 1713 FilterOperations filters; | 1713 FilterOperations filters; |
| 1714 filters.Append(FilterOperation::CreateBlurFilter(3.f)); | 1714 filters.Append(FilterOperation::CreateBlurFilter(3.f)); |
| 1715 filtered_surface->SetBackgroundFilters(filters); | 1715 filtered_surface->test_properties()->background_filters = filters; |
| 1716 | 1716 |
| 1717 this->CalcDrawEtc(parent); | 1717 this->CalcDrawEtc(parent); |
| 1718 | 1718 |
| 1719 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); | 1719 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
| 1720 | 1720 |
| 1721 this->VisitLayer(occluding_layer, &occlusion); | 1721 this->VisitLayer(occluding_layer, &occlusion); |
| 1722 | 1722 |
| 1723 this->VisitLayer(filtered_surface, &occlusion); | 1723 this->VisitLayer(filtered_surface, &occlusion); |
| 1724 { | 1724 { |
| 1725 // The layers above the filtered surface occlude from outside. | 1725 // The layers above the filtered surface occlude from outside. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1784 parent, this->identity_matrix, gfx::PointF(90.f, 40.f), | 1784 parent, this->identity_matrix, gfx::PointF(90.f, 40.f), |
| 1785 gfx::Size(10, 10), true); | 1785 gfx::Size(10, 10), true); |
| 1786 LayerImpl* beside_replica_layer = this->CreateDrawingLayer( | 1786 LayerImpl* beside_replica_layer = this->CreateDrawingLayer( |
| 1787 parent, this->identity_matrix, gfx::PointF(200.f, 40.f), | 1787 parent, this->identity_matrix, gfx::PointF(200.f, 40.f), |
| 1788 gfx::Size(10, 10), true); | 1788 gfx::Size(10, 10), true); |
| 1789 | 1789 |
| 1790 // Filters make the layer own a surface. | 1790 // Filters make the layer own a surface. |
| 1791 filtered_surface->test_properties()->force_render_surface = true; | 1791 filtered_surface->test_properties()->force_render_surface = true; |
| 1792 FilterOperations filters; | 1792 FilterOperations filters; |
| 1793 filters.Append(FilterOperation::CreateBlurFilter(3.f)); | 1793 filters.Append(FilterOperation::CreateBlurFilter(3.f)); |
| 1794 filtered_surface->SetBackgroundFilters(filters); | 1794 filtered_surface->test_properties()->background_filters = filters; |
| 1795 | 1795 |
| 1796 // Save the distance of influence for the blur effect. | 1796 // Save the distance of influence for the blur effect. |
| 1797 int outset_top, outset_right, outset_bottom, outset_left; | 1797 int outset_top, outset_right, outset_bottom, outset_left; |
| 1798 filters.GetOutsets( | 1798 filters.GetOutsets( |
| 1799 &outset_top, &outset_right, &outset_bottom, &outset_left); | 1799 &outset_top, &outset_right, &outset_bottom, &outset_left); |
| 1800 | 1800 |
| 1801 this->CalcDrawEtc(parent); | 1801 this->CalcDrawEtc(parent); |
| 1802 | 1802 |
| 1803 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); | 1803 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
| 1804 | 1804 |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2514 EXPECT_EQ(gfx::Rect(), | 2514 EXPECT_EQ(gfx::Rect(), |
| 2515 occlusion.UnoccludedSurfaceContentRect( | 2515 occlusion.UnoccludedSurfaceContentRect( |
| 2516 surface, gfx::Rect(80, 70, 50, 50))); | 2516 surface, gfx::Rect(80, 70, 50, 50))); |
| 2517 } | 2517 } |
| 2518 }; | 2518 }; |
| 2519 | 2519 |
| 2520 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) | 2520 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) |
| 2521 | 2521 |
| 2522 } // namespace | 2522 } // namespace |
| 2523 } // namespace cc | 2523 } // namespace cc |
| OLD | NEW |