| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 std::string json_data = "["; | 117 std::string json_data = "["; |
| 118 base::trace_event::TraceLog::GetInstance()->SetDisabled(); | 118 base::trace_event::TraceLog::GetInstance()->SetDisabled(); |
| 119 base::RunLoop run_loop; | 119 base::RunLoop run_loop; |
| 120 base::trace_event::TraceLog::GetInstance()->Flush( | 120 base::trace_event::TraceLog::GetInstance()->Flush( |
| 121 base::Bind(&GLHelperTest::TraceDataCB, run_loop.QuitClosure(), | 121 base::Bind(&GLHelperTest::TraceDataCB, run_loop.QuitClosure(), |
| 122 base::Unretained(&json_data))); | 122 base::Unretained(&json_data))); |
| 123 run_loop.Run(); | 123 run_loop.Run(); |
| 124 json_data.append("]"); | 124 json_data.append("]"); |
| 125 | 125 |
| 126 std::string error_msg; | 126 std::string error_msg; |
| 127 scoped_ptr<base::Value> trace_data = | 127 std::unique_ptr<base::Value> trace_data = |
| 128 base::JSONReader::ReadAndReturnError(json_data, 0, NULL, &error_msg); | 128 base::JSONReader::ReadAndReturnError(json_data, 0, NULL, &error_msg); |
| 129 CHECK(trace_data) << "JSON parsing failed (" << error_msg | 129 CHECK(trace_data) << "JSON parsing failed (" << error_msg |
| 130 << ") JSON data:" << std::endl | 130 << ") JSON data:" << std::endl |
| 131 << json_data; | 131 << json_data; |
| 132 | 132 |
| 133 base::ListValue* list; | 133 base::ListValue* list; |
| 134 CHECK(trace_data->GetAsList(&list)); | 134 CHECK(trace_data->GetAsList(&list)); |
| 135 for (size_t i = 0; i < list->GetSize(); i++) { | 135 for (size_t i = 0; i < list->GetSize(); i++) { |
| 136 base::Value* item = NULL; | 136 base::Value* item = NULL; |
| 137 if (list->Get(i, &item)) { | 137 if (list->Get(i, &item)) { |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 } | 667 } |
| 668 | 668 |
| 669 SkBitmap tmp; | 669 SkBitmap tmp; |
| 670 tmp.allocN32Pixels(xtmp, ytmp); | 670 tmp.allocN32Pixels(xtmp, ytmp); |
| 671 | 671 |
| 672 ScaleSlowRecursive(input, &tmp, quality); | 672 ScaleSlowRecursive(input, &tmp, quality); |
| 673 ScaleSlowRecursive(&tmp, output, quality); | 673 ScaleSlowRecursive(&tmp, output, quality); |
| 674 } | 674 } |
| 675 | 675 |
| 676 // Creates an RGBA SkBitmap | 676 // Creates an RGBA SkBitmap |
| 677 scoped_ptr<SkBitmap> CreateTestBitmap(int width, | 677 std::unique_ptr<SkBitmap> CreateTestBitmap(int width, |
| 678 int height, | 678 int height, |
| 679 int test_pattern) { | 679 int test_pattern) { |
| 680 scoped_ptr<SkBitmap> bitmap(new SkBitmap); | 680 std::unique_ptr<SkBitmap> bitmap(new SkBitmap); |
| 681 bitmap->allocPixels(SkImageInfo::Make(width, height, kRGBA_8888_SkColorType, | 681 bitmap->allocPixels(SkImageInfo::Make(width, height, kRGBA_8888_SkColorType, |
| 682 kPremul_SkAlphaType)); | 682 kPremul_SkAlphaType)); |
| 683 | 683 |
| 684 for (int x = 0; x < width; ++x) { | 684 for (int x = 0; x < width; ++x) { |
| 685 for (int y = 0; y < height; ++y) { | 685 for (int y = 0; y < height; ++y) { |
| 686 switch (test_pattern) { | 686 switch (test_pattern) { |
| 687 case 0: // Smooth test pattern | 687 case 0: // Smooth test pattern |
| 688 SetChannel(bitmap.get(), x, y, 0, x * 10); | 688 SetChannel(bitmap.get(), x, y, 0, x * 10); |
| 689 SetChannel(bitmap.get(), x, y, 0, y == 0 ? x * 50 : x * 10); | 689 SetChannel(bitmap.get(), x, y, 0, y == 0 ? x * 50 : x * 10); |
| 690 SetChannel(bitmap.get(), x, y, 1, y * 10); | 690 SetChannel(bitmap.get(), x, y, 1, y * 10); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 SkColorType out_color_type, | 732 SkColorType out_color_type, |
| 733 bool swizzle, | 733 bool swizzle, |
| 734 size_t quality_index) { | 734 size_t quality_index) { |
| 735 DCHECK(out_color_type == kAlpha_8_SkColorType || | 735 DCHECK(out_color_type == kAlpha_8_SkColorType || |
| 736 out_color_type == kRGBA_8888_SkColorType || | 736 out_color_type == kRGBA_8888_SkColorType || |
| 737 out_color_type == kBGRA_8888_SkColorType); | 737 out_color_type == kBGRA_8888_SkColorType); |
| 738 GLuint src_texture; | 738 GLuint src_texture; |
| 739 gl_->GenTextures(1, &src_texture); | 739 gl_->GenTextures(1, &src_texture); |
| 740 GLuint framebuffer; | 740 GLuint framebuffer; |
| 741 gl_->GenFramebuffers(1, &framebuffer); | 741 gl_->GenFramebuffers(1, &framebuffer); |
| 742 scoped_ptr<SkBitmap> input_pixels = | 742 std::unique_ptr<SkBitmap> input_pixels = |
| 743 CreateTestBitmap(xsize, ysize, test_pattern); | 743 CreateTestBitmap(xsize, ysize, test_pattern); |
| 744 BindTextureAndFrameBuffer(src_texture, framebuffer, input_pixels.get(), | 744 BindTextureAndFrameBuffer(src_texture, framebuffer, input_pixels.get(), |
| 745 xsize, ysize); | 745 xsize, ysize); |
| 746 | 746 |
| 747 std::string message = base::StringPrintf( | 747 std::string message = base::StringPrintf( |
| 748 "input size: %dx%d " | 748 "input size: %dx%d " |
| 749 "output size: %dx%d " | 749 "output size: %dx%d " |
| 750 "pattern: %d , quality: %s, " | 750 "pattern: %d , quality: %s, " |
| 751 "out_color_type: %d", | 751 "out_color_type: %d", |
| 752 xsize, ysize, scaled_xsize, scaled_ysize, test_pattern, | 752 xsize, ysize, scaled_xsize, scaled_ysize, test_pattern, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 int ysize, | 811 int ysize, |
| 812 int scaled_xsize, | 812 int scaled_xsize, |
| 813 int scaled_ysize, | 813 int scaled_ysize, |
| 814 int test_pattern, | 814 int test_pattern, |
| 815 size_t quality_index, | 815 size_t quality_index, |
| 816 bool flip) { | 816 bool flip) { |
| 817 GLuint src_texture; | 817 GLuint src_texture; |
| 818 gl_->GenTextures(1, &src_texture); | 818 gl_->GenTextures(1, &src_texture); |
| 819 GLuint framebuffer; | 819 GLuint framebuffer; |
| 820 gl_->GenFramebuffers(1, &framebuffer); | 820 gl_->GenFramebuffers(1, &framebuffer); |
| 821 scoped_ptr<SkBitmap> input_pixels = | 821 std::unique_ptr<SkBitmap> input_pixels = |
| 822 CreateTestBitmap(xsize, ysize, test_pattern); | 822 CreateTestBitmap(xsize, ysize, test_pattern); |
| 823 BindTextureAndFrameBuffer(src_texture, framebuffer, input_pixels.get(), | 823 BindTextureAndFrameBuffer(src_texture, framebuffer, input_pixels.get(), |
| 824 xsize, ysize); | 824 xsize, ysize); |
| 825 | 825 |
| 826 std::string message = base::StringPrintf( | 826 std::string message = base::StringPrintf( |
| 827 "input size: %dx%d " | 827 "input size: %dx%d " |
| 828 "output size: %dx%d " | 828 "output size: %dx%d " |
| 829 "pattern: %d quality: %s", | 829 "pattern: %d quality: %s", |
| 830 xsize, ysize, scaled_xsize, scaled_ysize, test_pattern, | 830 xsize, ysize, scaled_xsize, scaled_ysize, test_pattern, |
| 831 kQualityNames[quality_index]); | 831 kQualityNames[quality_index]); |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1299 gpu::SyncToken sync_token; | 1299 gpu::SyncToken sync_token; |
| 1300 gl_->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 1300 gl_->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 1301 | 1301 |
| 1302 std::string message = base::StringPrintf( | 1302 std::string message = base::StringPrintf( |
| 1303 "input size: %dx%d " | 1303 "input size: %dx%d " |
| 1304 "output size: %dx%d " | 1304 "output size: %dx%d " |
| 1305 "margin: %dx%d " | 1305 "margin: %dx%d " |
| 1306 "pattern: %d %s %s", | 1306 "pattern: %d %s %s", |
| 1307 xsize, ysize, output_xsize, output_ysize, xmargin, ymargin, | 1307 xsize, ysize, output_xsize, output_ysize, xmargin, ymargin, |
| 1308 test_pattern, flip ? "flip" : "noflip", flip ? "mrt" : "nomrt"); | 1308 test_pattern, flip ? "flip" : "noflip", flip ? "mrt" : "nomrt"); |
| 1309 scoped_ptr<ReadbackYUVInterface> yuv_reader( | 1309 std::unique_ptr<ReadbackYUVInterface> yuv_reader( |
| 1310 helper_->CreateReadbackPipelineYUV( | 1310 helper_->CreateReadbackPipelineYUV( |
| 1311 quality, gfx::Size(xsize, ysize), gfx::Rect(0, 0, xsize, ysize), | 1311 quality, gfx::Size(xsize, ysize), gfx::Rect(0, 0, xsize, ysize), |
| 1312 gfx::Size(xsize, ysize), flip, use_mrt)); | 1312 gfx::Size(xsize, ysize), flip, use_mrt)); |
| 1313 | 1313 |
| 1314 scoped_refptr<media::VideoFrame> output_frame = | 1314 scoped_refptr<media::VideoFrame> output_frame = |
| 1315 media::VideoFrame::CreateFrame( | 1315 media::VideoFrame::CreateFrame( |
| 1316 media::PIXEL_FORMAT_YV12, | 1316 media::PIXEL_FORMAT_YV12, |
| 1317 // 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 |
| 1318 // 16-byte boundary. This tests that the readback is being | 1318 // 16-byte boundary. This tests that the readback is being |
| 1319 // positioned inside the frame's visible region, and not dependent | 1319 // positioned inside the frame's visible region, and not dependent |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 y_ops_.push_back(GLHelperScaling::ScaleOp(2, false, 2)); | 1566 y_ops_.push_back(GLHelperScaling::ScaleOp(2, false, 2)); |
| 1567 y_ops_.push_back(GLHelperScaling::ScaleOp(2, false, 1)); | 1567 y_ops_.push_back(GLHelperScaling::ScaleOp(2, false, 1)); |
| 1568 CheckPipeline2(100, 100, 1, 1, | 1568 CheckPipeline2(100, 100, 1, 1, |
| 1569 "100x100 -> 100x32 bilinear4 Y\n" | 1569 "100x100 -> 100x32 bilinear4 Y\n" |
| 1570 "100x32 -> 100x4 bilinear4 Y\n" | 1570 "100x32 -> 100x4 bilinear4 Y\n" |
| 1571 "100x4 -> 64x1 bilinear2x2\n" | 1571 "100x4 -> 64x1 bilinear2x2\n" |
| 1572 "64x1 -> 8x1 bilinear4 X\n" | 1572 "64x1 -> 8x1 bilinear4 X\n" |
| 1573 "8x1 -> 1x1 bilinear4 X\n"); | 1573 "8x1 -> 1x1 bilinear4 X\n"); |
| 1574 } | 1574 } |
| 1575 | 1575 |
| 1576 scoped_ptr<gpu::GLInProcessContext> context_; | 1576 std::unique_ptr<gpu::GLInProcessContext> context_; |
| 1577 gpu::gles2::GLES2Interface* gl_; | 1577 gpu::gles2::GLES2Interface* gl_; |
| 1578 scoped_ptr<content::GLHelper> helper_; | 1578 std::unique_ptr<content::GLHelper> helper_; |
| 1579 scoped_ptr<content::GLHelperScaling> helper_scaling_; | 1579 std::unique_ptr<content::GLHelperScaling> helper_scaling_; |
| 1580 std::deque<GLHelperScaling::ScaleOp> x_ops_, y_ops_; | 1580 std::deque<GLHelperScaling::ScaleOp> x_ops_, y_ops_; |
| 1581 }; | 1581 }; |
| 1582 | 1582 |
| 1583 class GLHelperPixelTest : public GLHelperTest { | 1583 class GLHelperPixelTest : public GLHelperTest { |
| 1584 private: | 1584 private: |
| 1585 gfx::DisableNullDrawGLBindings enable_pixel_output_; | 1585 gfx::DisableNullDrawGLBindings enable_pixel_output_; |
| 1586 }; | 1586 }; |
| 1587 | 1587 |
| 1588 TEST_F(GLHelperTest, RGBASyncReadbackTest) { | 1588 TEST_F(GLHelperTest, RGBASyncReadbackTest) { |
| 1589 const int kTestSize = 64; | 1589 const int kTestSize = 64; |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1819 } | 1819 } |
| 1820 } | 1820 } |
| 1821 } | 1821 } |
| 1822 | 1822 |
| 1823 TEST_F(GLHelperTest, CheckOptimizations) { | 1823 TEST_F(GLHelperTest, CheckOptimizations) { |
| 1824 // Test in baseclass since it is friends with GLHelperScaling | 1824 // Test in baseclass since it is friends with GLHelperScaling |
| 1825 CheckOptimizationsTest(); | 1825 CheckOptimizationsTest(); |
| 1826 } | 1826 } |
| 1827 | 1827 |
| 1828 } // namespace content | 1828 } // namespace content |
| OLD | NEW |