| 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 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1247 // with reference implementation and compare to what gl_helper | 1247 // with reference implementation and compare to what gl_helper |
| 1248 // returns. | 1248 // returns. |
| 1249 void TestYUVReadback(int xsize, | 1249 void TestYUVReadback(int xsize, |
| 1250 int ysize, | 1250 int ysize, |
| 1251 int output_xsize, | 1251 int output_xsize, |
| 1252 int output_ysize, | 1252 int output_ysize, |
| 1253 int xmargin, | 1253 int xmargin, |
| 1254 int ymargin, | 1254 int ymargin, |
| 1255 int test_pattern, | 1255 int test_pattern, |
| 1256 bool flip, | 1256 bool flip, |
| 1257 bool use_mrt, | 1257 bool use_mrt) { |
| 1258 content::GLHelper::ScalerQuality quality) { | |
| 1259 GLuint src_texture; | 1258 GLuint src_texture; |
| 1260 gl_->GenTextures(1, &src_texture); | 1259 gl_->GenTextures(1, &src_texture); |
| 1261 SkBitmap input_pixels; | 1260 SkBitmap input_pixels; |
| 1262 input_pixels.allocN32Pixels(xsize, ysize); | 1261 input_pixels.allocN32Pixels(xsize, ysize); |
| 1263 | 1262 |
| 1264 for (int x = 0; x < xsize; ++x) { | 1263 for (int x = 0; x < xsize; ++x) { |
| 1265 for (int y = 0; y < ysize; ++y) { | 1264 for (int y = 0; y < ysize; ++y) { |
| 1266 switch (test_pattern) { | 1265 switch (test_pattern) { |
| 1267 case 0: // Smooth test pattern | 1266 case 0: // Smooth test pattern |
| 1268 SetChannel(&input_pixels, x, y, 0, x * 10); | 1267 SetChannel(&input_pixels, x, y, 0, x * 10); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 | 1301 |
| 1303 std::string message = base::StringPrintf( | 1302 std::string message = base::StringPrintf( |
| 1304 "input size: %dx%d " | 1303 "input size: %dx%d " |
| 1305 "output size: %dx%d " | 1304 "output size: %dx%d " |
| 1306 "margin: %dx%d " | 1305 "margin: %dx%d " |
| 1307 "pattern: %d %s %s", | 1306 "pattern: %d %s %s", |
| 1308 xsize, ysize, output_xsize, output_ysize, xmargin, ymargin, | 1307 xsize, ysize, output_xsize, output_ysize, xmargin, ymargin, |
| 1309 test_pattern, flip ? "flip" : "noflip", flip ? "mrt" : "nomrt"); | 1308 test_pattern, flip ? "flip" : "noflip", flip ? "mrt" : "nomrt"); |
| 1310 scoped_ptr<ReadbackYUVInterface> yuv_reader( | 1309 scoped_ptr<ReadbackYUVInterface> yuv_reader( |
| 1311 helper_->CreateReadbackPipelineYUV( | 1310 helper_->CreateReadbackPipelineYUV( |
| 1312 quality, gfx::Size(xsize, ysize), gfx::Rect(0, 0, xsize, ysize), | 1311 gfx::Size(xsize, ysize), gfx::Rect(0, 0, xsize, ysize), |
| 1313 gfx::Size(xsize, ysize), flip, use_mrt)); | 1312 gfx::Size(xsize, ysize), flip, use_mrt)); |
| 1314 | 1313 |
| 1315 scoped_refptr<media::VideoFrame> output_frame = | 1314 scoped_refptr<media::VideoFrame> output_frame = |
| 1316 media::VideoFrame::CreateFrame( | 1315 media::VideoFrame::CreateFrame( |
| 1317 media::PIXEL_FORMAT_YV12, | 1316 media::PIXEL_FORMAT_YV12, |
| 1318 // The coded size of the output frame is rounded up to the next | 1317 // The coded size of the output frame is rounded up to the next |
| 1319 // 16-byte boundary. This tests that the readback is being | 1318 // 16-byte boundary. This tests that the readback is being |
| 1320 // positioned inside the frame's visible region, and not dependent | 1319 // positioned inside the frame's visible region, and not dependent |
| 1321 // on its coded size. | 1320 // on its coded size. |
| 1322 gfx::Size((output_xsize + 15) & ~15, (output_ysize + 15) & ~15), | 1321 gfx::Size((output_xsize + 15) & ~15, (output_ysize + 15) & ~15), |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1627 kRGB_565_SkColorType, true); | 1626 kRGB_565_SkColorType, true); |
| 1628 EXPECT_EQ(result, true); | 1627 EXPECT_EQ(result, true); |
| 1629 } | 1628 } |
| 1630 | 1629 |
| 1631 TEST_F(GLHelperPixelTest, YUVReadbackOptTest) { | 1630 TEST_F(GLHelperPixelTest, YUVReadbackOptTest) { |
| 1632 // This test uses the gpu.service/gpu_decoder tracing events to detect how | 1631 // This test uses the gpu.service/gpu_decoder tracing events to detect how |
| 1633 // many scaling passes are actually performed by the YUV readback pipeline. | 1632 // many scaling passes are actually performed by the YUV readback pipeline. |
| 1634 StartTracing(TRACE_DISABLED_BY_DEFAULT( | 1633 StartTracing(TRACE_DISABLED_BY_DEFAULT( |
| 1635 "gpu.service") "," TRACE_DISABLED_BY_DEFAULT("gpu_decoder")); | 1634 "gpu.service") "," TRACE_DISABLED_BY_DEFAULT("gpu_decoder")); |
| 1636 | 1635 |
| 1637 TestYUVReadback(800, 400, 800, 400, 0, 0, 1, false, true, | 1636 TestYUVReadback(800, 400, 800, 400, 0, 0, 1, false, true); |
| 1638 content::GLHelper::SCALER_QUALITY_FAST); | |
| 1639 | 1637 |
| 1640 std::map<std::string, int> event_counts; | 1638 std::map<std::string, int> event_counts; |
| 1641 EndTracing(&event_counts); | 1639 EndTracing(&event_counts); |
| 1642 int draw_buffer_calls = event_counts["kDrawBuffersEXTImmediate"]; | 1640 int draw_buffer_calls = event_counts["kDrawBuffersEXTImmediate"]; |
| 1643 int draw_arrays_calls = event_counts["kDrawArrays"]; | 1641 int draw_arrays_calls = event_counts["kDrawArrays"]; |
| 1644 VLOG(1) << "Draw buffer calls: " << draw_buffer_calls; | 1642 VLOG(1) << "Draw buffer calls: " << draw_buffer_calls; |
| 1645 VLOG(1) << "DrawArrays calls: " << draw_arrays_calls; | 1643 VLOG(1) << "DrawArrays calls: " << draw_arrays_calls; |
| 1646 | 1644 |
| 1647 if (draw_buffer_calls) { | 1645 if (draw_buffer_calls) { |
| 1648 // When using MRT, the YUV readback code should only | 1646 // When using MRT, the YUV readback code should only |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1677 for (Margin xm = x < ox ? MarginLeft : MarginRight; xm <= MarginRight; | 1675 for (Margin xm = x < ox ? MarginLeft : MarginRight; xm <= MarginRight; |
| 1678 xm = NextMargin(xm)) { | 1676 xm = NextMargin(xm)) { |
| 1679 for (Margin ym = y < oy ? MarginLeft : MarginRight; ym <= MarginRight; | 1677 for (Margin ym = y < oy ? MarginLeft : MarginRight; ym <= MarginRight; |
| 1680 ym = NextMargin(ym)) { | 1678 ym = NextMargin(ym)) { |
| 1681 for (int pattern = 0; pattern < 3; pattern++) { | 1679 for (int pattern = 0; pattern < 3; pattern++) { |
| 1682 TestYUVReadback( | 1680 TestYUVReadback( |
| 1683 kYUVReadBackSizes[x], kYUVReadBackSizes[y], | 1681 kYUVReadBackSizes[x], kYUVReadBackSizes[y], |
| 1684 kYUVReadBackSizes[ox], kYUVReadBackSizes[oy], | 1682 kYUVReadBackSizes[ox], kYUVReadBackSizes[oy], |
| 1685 compute_margin(kYUVReadBackSizes[x], kYUVReadBackSizes[ox], xm), | 1683 compute_margin(kYUVReadBackSizes[x], kYUVReadBackSizes[ox], xm), |
| 1686 compute_margin(kYUVReadBackSizes[y], kYUVReadBackSizes[oy], ym), | 1684 compute_margin(kYUVReadBackSizes[y], kYUVReadBackSizes[oy], ym), |
| 1687 pattern, flip, use_mrt, content::GLHelper::SCALER_QUALITY_GOOD); | 1685 pattern, flip, use_mrt); |
| 1688 if (HasFailure()) { | 1686 if (HasFailure()) { |
| 1689 return; | 1687 return; |
| 1690 } | 1688 } |
| 1691 } | 1689 } |
| 1692 } | 1690 } |
| 1693 } | 1691 } |
| 1694 } | 1692 } |
| 1695 } | 1693 } |
| 1696 } | 1694 } |
| 1697 | 1695 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1820 } | 1818 } |
| 1821 } | 1819 } |
| 1822 } | 1820 } |
| 1823 | 1821 |
| 1824 TEST_F(GLHelperTest, CheckOptimizations) { | 1822 TEST_F(GLHelperTest, CheckOptimizations) { |
| 1825 // Test in baseclass since it is friends with GLHelperScaling | 1823 // Test in baseclass since it is friends with GLHelperScaling |
| 1826 CheckOptimizationsTest(); | 1824 CheckOptimizationsTest(); |
| 1827 } | 1825 } |
| 1828 | 1826 |
| 1829 } // namespace content | 1827 } // namespace content |
| OLD | NEW |