| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdio.h> | 7 #include <stdio.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 // with reference implementation and compare to what gl_helper | 1315 // with reference implementation and compare to what gl_helper |
| 1316 // returns. | 1316 // returns. |
| 1317 void TestYUVReadback(int xsize, | 1317 void TestYUVReadback(int xsize, |
| 1318 int ysize, | 1318 int ysize, |
| 1319 int output_xsize, | 1319 int output_xsize, |
| 1320 int output_ysize, | 1320 int output_ysize, |
| 1321 int xmargin, | 1321 int xmargin, |
| 1322 int ymargin, | 1322 int ymargin, |
| 1323 int test_pattern, | 1323 int test_pattern, |
| 1324 bool flip, | 1324 bool flip, |
| 1325 bool use_mrt, | 1325 bool use_mrt) { |
| 1326 content::GLHelper::ScalerQuality quality) { | |
| 1327 WebGLId src_texture = context_->createTexture(); | 1326 WebGLId src_texture = context_->createTexture(); |
| 1328 SkBitmap input_pixels; | 1327 SkBitmap input_pixels; |
| 1329 input_pixels.allocN32Pixels(xsize, ysize); | 1328 input_pixels.allocN32Pixels(xsize, ysize); |
| 1330 | 1329 |
| 1331 for (int x = 0; x < xsize; ++x) { | 1330 for (int x = 0; x < xsize; ++x) { |
| 1332 for (int y = 0; y < ysize; ++y) { | 1331 for (int y = 0; y < ysize; ++y) { |
| 1333 switch (test_pattern) { | 1332 switch (test_pattern) { |
| 1334 case 0: // Smooth test pattern | 1333 case 0: // Smooth test pattern |
| 1335 SetChannel(&input_pixels, x, y, 0, x * 10); | 1334 SetChannel(&input_pixels, x, y, 0, x * 10); |
| 1336 SetChannel(&input_pixels, x, y, 1, y * 10); | 1335 SetChannel(&input_pixels, x, y, 1, y * 10); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 ysize, | 1383 ysize, |
| 1385 output_xsize, | 1384 output_xsize, |
| 1386 output_ysize, | 1385 output_ysize, |
| 1387 xmargin, | 1386 xmargin, |
| 1388 ymargin, | 1387 ymargin, |
| 1389 test_pattern, | 1388 test_pattern, |
| 1390 flip ? "flip" : "noflip", | 1389 flip ? "flip" : "noflip", |
| 1391 flip ? "mrt" : "nomrt"); | 1390 flip ? "mrt" : "nomrt"); |
| 1392 scoped_ptr<ReadbackYUVInterface> yuv_reader( | 1391 scoped_ptr<ReadbackYUVInterface> yuv_reader( |
| 1393 helper_->CreateReadbackPipelineYUV( | 1392 helper_->CreateReadbackPipelineYUV( |
| 1394 quality, | |
| 1395 gfx::Size(xsize, ysize), | 1393 gfx::Size(xsize, ysize), |
| 1396 gfx::Rect(0, 0, xsize, ysize), | 1394 gfx::Rect(0, 0, xsize, ysize), |
| 1397 gfx::Size(xsize, ysize), | 1395 gfx::Size(xsize, ysize), |
| 1398 flip, | 1396 flip, |
| 1399 use_mrt)); | 1397 use_mrt)); |
| 1400 | 1398 |
| 1401 scoped_refptr<media::VideoFrame> output_frame = | 1399 scoped_refptr<media::VideoFrame> output_frame = |
| 1402 media::VideoFrame::CreateFrame( | 1400 media::VideoFrame::CreateFrame( |
| 1403 media::PIXEL_FORMAT_YV12, | 1401 media::PIXEL_FORMAT_YV12, |
| 1404 // The coded size of the output frame is rounded up to the next | 1402 // The coded size of the output frame is rounded up to the next |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1761 true); | 1759 true); |
| 1762 EXPECT_EQ(result, true); | 1760 EXPECT_EQ(result, true); |
| 1763 } | 1761 } |
| 1764 | 1762 |
| 1765 TEST_F(GLHelperPixelTest, YUVReadbackOptTest) { | 1763 TEST_F(GLHelperPixelTest, YUVReadbackOptTest) { |
| 1766 // This test uses the gpu.service/gpu_decoder tracing events to detect how | 1764 // This test uses the gpu.service/gpu_decoder tracing events to detect how |
| 1767 // many scaling passes are actually performed by the YUV readback pipeline. | 1765 // many scaling passes are actually performed by the YUV readback pipeline. |
| 1768 StartTracing(TRACE_DISABLED_BY_DEFAULT("gpu.service") "," | 1766 StartTracing(TRACE_DISABLED_BY_DEFAULT("gpu.service") "," |
| 1769 TRACE_DISABLED_BY_DEFAULT("gpu_decoder")); | 1767 TRACE_DISABLED_BY_DEFAULT("gpu_decoder")); |
| 1770 | 1768 |
| 1771 TestYUVReadback(800, | 1769 TestYUVReadback(800, 400, 800, 400, 0, 0, 1, false, true); |
| 1772 400, | |
| 1773 800, | |
| 1774 400, | |
| 1775 0, | |
| 1776 0, | |
| 1777 1, | |
| 1778 false, | |
| 1779 true, | |
| 1780 content::GLHelper::SCALER_QUALITY_FAST); | |
| 1781 | 1770 |
| 1782 std::map<std::string, int> event_counts; | 1771 std::map<std::string, int> event_counts; |
| 1783 EndTracing(&event_counts); | 1772 EndTracing(&event_counts); |
| 1784 int draw_buffer_calls = event_counts["kDrawBuffersEXTImmediate"]; | 1773 int draw_buffer_calls = event_counts["kDrawBuffersEXTImmediate"]; |
| 1785 int draw_arrays_calls = event_counts["kDrawArrays"]; | 1774 int draw_arrays_calls = event_counts["kDrawArrays"]; |
| 1786 VLOG(1) << "Draw buffer calls: " << draw_buffer_calls; | 1775 VLOG(1) << "Draw buffer calls: " << draw_buffer_calls; |
| 1787 VLOG(1) << "DrawArrays calls: " << draw_arrays_calls; | 1776 VLOG(1) << "DrawArrays calls: " << draw_arrays_calls; |
| 1788 | 1777 |
| 1789 if (draw_buffer_calls) { | 1778 if (draw_buffer_calls) { |
| 1790 // When using MRT, the YUV readback code should only | 1779 // When using MRT, the YUV readback code should only |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1816 for (unsigned int oy = y; oy < arraysize(kYUVReadBackSizes); oy++) { | 1805 for (unsigned int oy = y; oy < arraysize(kYUVReadBackSizes); oy++) { |
| 1817 // If output is a subsection of the destination frame, (letterbox) | 1806 // If output is a subsection of the destination frame, (letterbox) |
| 1818 // then try different variations of where the subsection goes. | 1807 // then try different variations of where the subsection goes. |
| 1819 for (Margin xm = x < ox ? MarginLeft : MarginRight; | 1808 for (Margin xm = x < ox ? MarginLeft : MarginRight; |
| 1820 xm <= MarginRight; | 1809 xm <= MarginRight; |
| 1821 xm = NextMargin(xm)) { | 1810 xm = NextMargin(xm)) { |
| 1822 for (Margin ym = y < oy ? MarginLeft : MarginRight; | 1811 for (Margin ym = y < oy ? MarginLeft : MarginRight; |
| 1823 ym <= MarginRight; | 1812 ym <= MarginRight; |
| 1824 ym = NextMargin(ym)) { | 1813 ym = NextMargin(ym)) { |
| 1825 for (int pattern = 0; pattern < 3; pattern++) { | 1814 for (int pattern = 0; pattern < 3; pattern++) { |
| 1826 TestYUVReadback(kYUVReadBackSizes[x], | 1815 TestYUVReadback( |
| 1827 kYUVReadBackSizes[y], | 1816 kYUVReadBackSizes[x], kYUVReadBackSizes[y], |
| 1828 kYUVReadBackSizes[ox], | 1817 kYUVReadBackSizes[ox], kYUVReadBackSizes[oy], |
| 1829 kYUVReadBackSizes[oy], | 1818 compute_margin(kYUVReadBackSizes[x], kYUVReadBackSizes[ox], xm), |
| 1830 compute_margin(kYUVReadBackSizes[x], | 1819 compute_margin(kYUVReadBackSizes[y], kYUVReadBackSizes[oy], ym), |
| 1831 kYUVReadBackSizes[ox], xm), | 1820 pattern, flip, use_mrt); |
| 1832 compute_margin(kYUVReadBackSizes[y], | |
| 1833 kYUVReadBackSizes[oy], ym), | |
| 1834 pattern, | |
| 1835 flip, | |
| 1836 use_mrt, | |
| 1837 content::GLHelper::SCALER_QUALITY_GOOD); | |
| 1838 if (HasFailure()) { | 1821 if (HasFailure()) { |
| 1839 return; | 1822 return; |
| 1840 } | 1823 } |
| 1841 } | 1824 } |
| 1842 } | 1825 } |
| 1843 } | 1826 } |
| 1844 } | 1827 } |
| 1845 } | 1828 } |
| 1846 } | 1829 } |
| 1847 | 1830 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2018 base::TestSuite* suite = new content::ContentTestSuite(argc, argv); | 2001 base::TestSuite* suite = new content::ContentTestSuite(argc, argv); |
| 2019 #if defined(OS_MACOSX) | 2002 #if defined(OS_MACOSX) |
| 2020 base::mac::ScopedNSAutoreleasePool pool; | 2003 base::mac::ScopedNSAutoreleasePool pool; |
| 2021 #endif | 2004 #endif |
| 2022 | 2005 |
| 2023 return base::LaunchUnitTestsSerially( | 2006 return base::LaunchUnitTestsSerially( |
| 2024 argc, | 2007 argc, |
| 2025 argv, | 2008 argv, |
| 2026 base::Bind(&RunHelper, base::Unretained(suite))); | 2009 base::Bind(&RunHelper, base::Unretained(suite))); |
| 2027 } | 2010 } |
| OLD | NEW |