Chromium Code Reviews| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 blend_mode, sorting_context_id); | 89 blend_mode, sorting_context_id); |
| 90 return shared_state; | 90 return shared_state; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void CreateTestRenderPassDrawQuad(const SharedQuadState* shared_state, | 93 void CreateTestRenderPassDrawQuad(const SharedQuadState* shared_state, |
| 94 const gfx::Rect& rect, | 94 const gfx::Rect& rect, |
| 95 RenderPassId pass_id, | 95 RenderPassId pass_id, |
| 96 RenderPass* render_pass) { | 96 RenderPass* render_pass) { |
| 97 RenderPassDrawQuad* quad = | 97 RenderPassDrawQuad* quad = |
| 98 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 98 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
| 99 quad->SetNew(shared_state, | 99 quad->SetNew(shared_state, rect, rect, pass_id, |
| 100 rect, | |
| 101 rect, | |
| 102 pass_id, | |
| 103 0, // mask_resource_id | 100 0, // mask_resource_id |
| 104 gfx::Vector2dF(), // mask_uv_scale | 101 gfx::Vector2dF(), // mask_uv_scale |
| 105 gfx::Size(), // mask_texture_size | 102 gfx::Size(), // mask_texture_size |
| 106 FilterOperations(), // foreground filters | 103 FilterOperations(), // foreground filters |
| 107 gfx::Vector2dF(), // filters scale | 104 gfx::Vector2dF(), // filters scale |
| 105 gfx::PointF(), // filter origin | |
| 108 FilterOperations()); // background filters | 106 FilterOperations()); // background filters |
| 109 } | 107 } |
| 110 | 108 |
| 111 void CreateTestTwoColoredTextureDrawQuad(const gfx::Rect& rect, | 109 void CreateTestTwoColoredTextureDrawQuad(const gfx::Rect& rect, |
| 112 SkColor texel_color, | 110 SkColor texel_color, |
| 113 SkColor texel_stripe_color, | 111 SkColor texel_stripe_color, |
| 114 SkColor background_color, | 112 SkColor background_color, |
| 115 bool premultiplied_alpha, | 113 bool premultiplied_alpha, |
| 116 const SharedQuadState* shared_state, | 114 const SharedQuadState* shared_state, |
| 117 ResourceProvider* resource_provider, | 115 ResourceProvider* resource_provider, |
| (...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1409 matrix[13] = matrix[14] = 0; | 1407 matrix[13] = matrix[14] = 0; |
| 1410 matrix[15] = matrix[16] = matrix[17] = matrix[19] = 0; | 1408 matrix[15] = matrix[16] = matrix[17] = matrix[19] = 0; |
| 1411 matrix[18] = 1; | 1409 matrix[18] = 1; |
| 1412 FilterOperations filters; | 1410 FilterOperations filters; |
| 1413 filters.Append( | 1411 filters.Append( |
| 1414 FilterOperation::CreateReferenceFilter(SkColorFilterImageFilter::Make( | 1412 FilterOperation::CreateReferenceFilter(SkColorFilterImageFilter::Make( |
| 1415 SkColorFilter::MakeMatrixFilterRowMajor255(matrix), nullptr))); | 1413 SkColorFilter::MakeMatrixFilterRowMajor255(matrix), nullptr))); |
| 1416 | 1414 |
| 1417 RenderPassDrawQuad* render_pass_quad = | 1415 RenderPassDrawQuad* render_pass_quad = |
| 1418 root_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 1416 root_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
| 1419 render_pass_quad->SetNew(pass_shared_state, | 1417 render_pass_quad->SetNew(pass_shared_state, pass_rect, pass_rect, |
| 1420 pass_rect, | 1418 child_pass_id, 0, gfx::Vector2dF(), gfx::Size(), |
| 1421 pass_rect, | 1419 filters, gfx::Vector2dF(), gfx::PointF(), |
| 1422 child_pass_id, | |
| 1423 0, | |
| 1424 gfx::Vector2dF(), | |
| 1425 gfx::Size(), | |
| 1426 filters, | |
| 1427 gfx::Vector2dF(), | |
| 1428 FilterOperations()); | 1420 FilterOperations()); |
| 1429 | 1421 |
| 1430 RenderPassList pass_list; | 1422 RenderPassList pass_list; |
| 1431 pass_list.push_back(std::move(child_pass)); | 1423 pass_list.push_back(std::move(child_pass)); |
| 1432 pass_list.push_back(std::move(root_pass)); | 1424 pass_list.push_back(std::move(root_pass)); |
| 1433 | 1425 |
| 1434 // This test has alpha=254 for the software renderer vs. alpha=255 for the gl | 1426 // This test has alpha=254 for the software renderer vs. alpha=255 for the gl |
| 1435 // renderer so use a fuzzy comparator. | 1427 // renderer so use a fuzzy comparator. |
| 1436 EXPECT_TRUE(this->RunPixelTest( | 1428 EXPECT_TRUE(this->RunPixelTest( |
| 1437 &pass_list, | 1429 &pass_list, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1481 blank_state, viewport_rect, viewport_rect, SK_ColorWHITE, false); | 1473 blank_state, viewport_rect, viewport_rect, SK_ColorWHITE, false); |
| 1482 | 1474 |
| 1483 SharedQuadState* pass_shared_state = | 1475 SharedQuadState* pass_shared_state = |
| 1484 CreateTestSharedQuadState(gfx::Transform(), pass_rect, root_pass.get()); | 1476 CreateTestSharedQuadState(gfx::Transform(), pass_rect, root_pass.get()); |
| 1485 | 1477 |
| 1486 FilterOperations filters; | 1478 FilterOperations filters; |
| 1487 filters.Append(FilterOperation::CreateSaturateFilter(0.5f)); | 1479 filters.Append(FilterOperation::CreateSaturateFilter(0.5f)); |
| 1488 | 1480 |
| 1489 RenderPassDrawQuad* render_pass_quad = | 1481 RenderPassDrawQuad* render_pass_quad = |
| 1490 root_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 1482 root_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
| 1491 render_pass_quad->SetNew(pass_shared_state, | 1483 render_pass_quad->SetNew(pass_shared_state, pass_rect, pass_rect, |
| 1492 pass_rect, | 1484 child_pass_id, 0, gfx::Vector2dF(), gfx::Size(), |
| 1493 pass_rect, | 1485 filters, gfx::Vector2dF(), gfx::PointF(), |
| 1494 child_pass_id, | |
| 1495 0, | |
| 1496 gfx::Vector2dF(), | |
| 1497 gfx::Size(), | |
| 1498 filters, | |
| 1499 gfx::Vector2dF(), | |
| 1500 FilterOperations()); | 1486 FilterOperations()); |
| 1501 | 1487 |
| 1502 RenderPassList pass_list; | 1488 RenderPassList pass_list; |
| 1503 pass_list.push_back(std::move(child_pass)); | 1489 pass_list.push_back(std::move(child_pass)); |
| 1504 pass_list.push_back(std::move(root_pass)); | 1490 pass_list.push_back(std::move(root_pass)); |
| 1505 | 1491 |
| 1506 // This test blends slightly differently with the software renderer vs. the gl | 1492 // This test blends slightly differently with the software renderer vs. the gl |
| 1507 // renderer so use a fuzzy comparator. | 1493 // renderer so use a fuzzy comparator. |
| 1508 EXPECT_TRUE(this->RunPixelTest( | 1494 EXPECT_TRUE(this->RunPixelTest( |
| 1509 &pass_list, base::FilePath(FILE_PATH_LITERAL("blue_yellow_alpha.png")), | 1495 &pass_list, base::FilePath(FILE_PATH_LITERAL("blue_yellow_alpha.png")), |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1553 | 1539 |
| 1554 SharedQuadState* pass_shared_state = | 1540 SharedQuadState* pass_shared_state = |
| 1555 CreateTestSharedQuadState(gfx::Transform(), pass_rect, root_pass.get()); | 1541 CreateTestSharedQuadState(gfx::Transform(), pass_rect, root_pass.get()); |
| 1556 | 1542 |
| 1557 FilterOperations filters; | 1543 FilterOperations filters; |
| 1558 filters.Append(FilterOperation::CreateGrayscaleFilter(1.f)); | 1544 filters.Append(FilterOperation::CreateGrayscaleFilter(1.f)); |
| 1559 filters.Append(FilterOperation::CreateBrightnessFilter(0.5f)); | 1545 filters.Append(FilterOperation::CreateBrightnessFilter(0.5f)); |
| 1560 | 1546 |
| 1561 RenderPassDrawQuad* render_pass_quad = | 1547 RenderPassDrawQuad* render_pass_quad = |
| 1562 root_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 1548 root_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
| 1563 render_pass_quad->SetNew(pass_shared_state, | 1549 render_pass_quad->SetNew(pass_shared_state, pass_rect, pass_rect, |
| 1564 pass_rect, | 1550 child_pass_id, 0, gfx::Vector2dF(), gfx::Size(), |
| 1565 pass_rect, | 1551 filters, gfx::Vector2dF(), gfx::PointF(), |
| 1566 child_pass_id, | |
| 1567 0, | |
| 1568 gfx::Vector2dF(), | |
| 1569 gfx::Size(), | |
| 1570 filters, | |
| 1571 gfx::Vector2dF(), | |
| 1572 FilterOperations()); | 1552 FilterOperations()); |
| 1573 | 1553 |
| 1574 RenderPassList pass_list; | 1554 RenderPassList pass_list; |
| 1575 pass_list.push_back(std::move(child_pass)); | 1555 pass_list.push_back(std::move(child_pass)); |
| 1576 pass_list.push_back(std::move(root_pass)); | 1556 pass_list.push_back(std::move(root_pass)); |
| 1577 | 1557 |
| 1578 // This test blends slightly differently with the software renderer vs. the gl | 1558 // This test blends slightly differently with the software renderer vs. the gl |
| 1579 // renderer so use a fuzzy comparator. | 1559 // renderer so use a fuzzy comparator. |
| 1580 EXPECT_TRUE(this->RunPixelTest( | 1560 EXPECT_TRUE(this->RunPixelTest( |
| 1581 &pass_list, | 1561 &pass_list, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1646 matrix[14] = 1.5f; | 1626 matrix[14] = 1.5f; |
| 1647 matrix[15] = matrix[16] = matrix[17] = matrix[19] = 0; | 1627 matrix[15] = matrix[16] = matrix[17] = matrix[19] = 0; |
| 1648 matrix[18] = 1; | 1628 matrix[18] = 1; |
| 1649 FilterOperations filters; | 1629 FilterOperations filters; |
| 1650 filters.Append( | 1630 filters.Append( |
| 1651 FilterOperation::CreateReferenceFilter(SkColorFilterImageFilter::Make( | 1631 FilterOperation::CreateReferenceFilter(SkColorFilterImageFilter::Make( |
| 1652 SkColorFilter::MakeMatrixFilterRowMajor255(matrix), nullptr))); | 1632 SkColorFilter::MakeMatrixFilterRowMajor255(matrix), nullptr))); |
| 1653 | 1633 |
| 1654 RenderPassDrawQuad* render_pass_quad = | 1634 RenderPassDrawQuad* render_pass_quad = |
| 1655 root_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 1635 root_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
| 1656 render_pass_quad->SetNew(pass_shared_state, | 1636 render_pass_quad->SetNew(pass_shared_state, pass_rect, pass_rect, |
| 1657 pass_rect, | 1637 child_pass_id, 0, gfx::Vector2dF(), gfx::Size(), |
| 1658 pass_rect, | 1638 filters, gfx::Vector2dF(), gfx::PointF(), |
| 1659 child_pass_id, | |
| 1660 0, | |
| 1661 gfx::Vector2dF(), | |
| 1662 gfx::Size(), | |
| 1663 filters, | |
| 1664 gfx::Vector2dF(), | |
| 1665 FilterOperations()); | 1639 FilterOperations()); |
| 1666 | 1640 |
| 1667 RenderPassList pass_list; | 1641 RenderPassList pass_list; |
| 1668 | 1642 |
| 1669 pass_list.push_back(std::move(child_pass)); | 1643 pass_list.push_back(std::move(child_pass)); |
| 1670 pass_list.push_back(std::move(root_pass)); | 1644 pass_list.push_back(std::move(root_pass)); |
| 1671 | 1645 |
| 1672 // This test has alpha=254 for the software renderer vs. alpha=255 for the gl | 1646 // This test has alpha=254 for the software renderer vs. alpha=255 for the gl |
| 1673 // renderer so use a fuzzy comparator. | 1647 // renderer so use a fuzzy comparator. |
| 1674 EXPECT_TRUE(this->RunPixelTest( | 1648 EXPECT_TRUE(this->RunPixelTest( |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1854 // Set up a mask on the RenderPassDrawQuad. | 1828 // Set up a mask on the RenderPassDrawQuad. |
| 1855 RenderPassDrawQuad* mask_quad = | 1829 RenderPassDrawQuad* mask_quad = |
| 1856 root_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 1830 root_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
| 1857 mask_quad->SetNew(root_pass_shared_state, sub_rect, sub_rect, child_pass_id, | 1831 mask_quad->SetNew(root_pass_shared_state, sub_rect, sub_rect, child_pass_id, |
| 1858 mask_resource_id, | 1832 mask_resource_id, |
| 1859 gfx::Vector2dF(2.f / mask_rect.width(), | 1833 gfx::Vector2dF(2.f / mask_rect.width(), |
| 1860 2.f / mask_rect.height()), // mask_uv_scale | 1834 2.f / mask_rect.height()), // mask_uv_scale |
| 1861 gfx::Size(mask_rect.size()), // mask_texture_size | 1835 gfx::Size(mask_rect.size()), // mask_texture_size |
| 1862 FilterOperations(), // foreground filters | 1836 FilterOperations(), // foreground filters |
| 1863 gfx::Vector2dF(), // filters scale | 1837 gfx::Vector2dF(), // filters scale |
| 1838 gfx::PointF(), // filter origin | |
| 1864 FilterOperations()); // background filters | 1839 FilterOperations()); // background filters |
| 1865 | 1840 |
| 1866 // White background behind the masked render pass. | 1841 // White background behind the masked render pass. |
| 1867 SolidColorDrawQuad* white = | 1842 SolidColorDrawQuad* white = |
| 1868 root_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 1843 root_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 1869 white->SetNew(root_pass_shared_state, | 1844 white->SetNew(root_pass_shared_state, |
| 1870 viewport_rect, | 1845 viewport_rect, |
| 1871 viewport_rect, | 1846 viewport_rect, |
| 1872 SK_ColorWHITE, | 1847 SK_ColorWHITE, |
| 1873 false); | 1848 false); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1948 // Set up a mask on the RenderPassDrawQuad. | 1923 // Set up a mask on the RenderPassDrawQuad. |
| 1949 RenderPassDrawQuad* mask_quad = | 1924 RenderPassDrawQuad* mask_quad = |
| 1950 root_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 1925 root_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
| 1951 mask_quad->SetNew(root_pass_shared_state, sub_rect, sub_rect, child_pass_id, | 1926 mask_quad->SetNew(root_pass_shared_state, sub_rect, sub_rect, child_pass_id, |
| 1952 mask_resource_id, | 1927 mask_resource_id, |
| 1953 gfx::Vector2dF(2.f / mask_rect.width(), | 1928 gfx::Vector2dF(2.f / mask_rect.width(), |
| 1954 2.f / mask_rect.height()), // mask_uv_scale | 1929 2.f / mask_rect.height()), // mask_uv_scale |
| 1955 gfx::Size(mask_rect.size()), // mask_texture_size | 1930 gfx::Size(mask_rect.size()), // mask_texture_size |
| 1956 FilterOperations(), // foreground filters | 1931 FilterOperations(), // foreground filters |
| 1957 gfx::Vector2dF(), // filters scale | 1932 gfx::Vector2dF(), // filters scale |
| 1933 gfx::PointF(), // filter origin | |
| 1958 FilterOperations()); // background filters | 1934 FilterOperations()); // background filters |
| 1959 | 1935 |
| 1960 // White background behind the masked render pass. | 1936 // White background behind the masked render pass. |
| 1961 SolidColorDrawQuad* white = | 1937 SolidColorDrawQuad* white = |
| 1962 root_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 1938 root_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 1963 white->SetNew(root_pass_shared_state, viewport_rect, viewport_rect, | 1939 white->SetNew(root_pass_shared_state, viewport_rect, viewport_rect, |
| 1964 SK_ColorWHITE, false); | 1940 SK_ColorWHITE, false); |
| 1965 | 1941 |
| 1966 RenderPassList pass_list; | 1942 RenderPassList pass_list; |
| 1967 pass_list.push_back(std::move(child_pass)); | 1943 pass_list.push_back(std::move(child_pass)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2008 filter_pass_layer_rect_, filter_pass.get()); | 1984 filter_pass_layer_rect_, filter_pass.get()); |
| 2009 RenderPassDrawQuad* filter_pass_quad = | 1985 RenderPassDrawQuad* filter_pass_quad = |
| 2010 root_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 1986 root_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
| 2011 filter_pass_quad->SetNew(shared_state, filter_pass_layer_rect_, | 1987 filter_pass_quad->SetNew(shared_state, filter_pass_layer_rect_, |
| 2012 filter_pass_layer_rect_, filter_pass_id, | 1988 filter_pass_layer_rect_, filter_pass_id, |
| 2013 0, // mask_resource_id | 1989 0, // mask_resource_id |
| 2014 gfx::Vector2dF(), // mask_uv_scale | 1990 gfx::Vector2dF(), // mask_uv_scale |
| 2015 gfx::Size(), // mask_texture_size | 1991 gfx::Size(), // mask_texture_size |
| 2016 FilterOperations(), // filters | 1992 FilterOperations(), // filters |
| 2017 gfx::Vector2dF(1.0f, 1.0f), // filters_scale | 1993 gfx::Vector2dF(1.0f, 1.0f), // filters_scale |
| 1994 gfx::PointF(), // filters_origin | |
| 2018 this->background_filters_); | 1995 this->background_filters_); |
| 2019 } | 1996 } |
| 2020 | 1997 |
| 2021 const int kColumnWidth = device_viewport_rect.width() / 3; | 1998 const int kColumnWidth = device_viewport_rect.width() / 3; |
| 2022 | 1999 |
| 2023 gfx::Rect left_rect = gfx::Rect(0, 0, kColumnWidth, 20); | 2000 gfx::Rect left_rect = gfx::Rect(0, 0, kColumnWidth, 20); |
| 2024 for (int i = 0; left_rect.y() < device_viewport_rect.height(); ++i) { | 2001 for (int i = 0; left_rect.y() < device_viewport_rect.height(); ++i) { |
| 2025 SharedQuadState* shared_state = CreateTestSharedQuadState( | 2002 SharedQuadState* shared_state = CreateTestSharedQuadState( |
| 2026 identity_quad_to_target_transform, left_rect, root_pass.get()); | 2003 identity_quad_to_target_transform, left_rect, root_pass.get()); |
| 2027 SolidColorDrawQuad* color_quad = | 2004 SolidColorDrawQuad* color_quad = |
| (...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3191 } | 3168 } |
| 3192 } | 3169 } |
| 3193 | 3170 |
| 3194 RenderPassList pass_list; | 3171 RenderPassList pass_list; |
| 3195 pass_list.push_back(std::move(pass)); | 3172 pass_list.push_back(std::move(pass)); |
| 3196 | 3173 |
| 3197 EXPECT_TRUE(this->RunPixelTest( | 3174 EXPECT_TRUE(this->RunPixelTest( |
| 3198 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")), | 3175 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")), |
| 3199 FuzzyPixelOffByOneComparator(true))); | 3176 FuzzyPixelOffByOneComparator(true))); |
| 3200 } | 3177 } |
| 3201 | 3178 |
|
ajuma
2016/08/29 20:28:43
Does it make sense to add a new pixel test (or som
Stephen White
2016/08/29 21:10:54
Done. This revealed that I forgot about the softwa
| |
| 3202 #endif // !defined(OS_ANDROID) | 3179 #endif // !defined(OS_ANDROID) |
| 3203 | 3180 |
| 3204 } // namespace | 3181 } // namespace |
| 3205 } // namespace cc | 3182 } // namespace cc |
| OLD | NEW |