| 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 "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
| 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 }; | 637 }; |
| 638 | 638 |
| 639 for (size_t tt = 0; tt < arraysize(tests); ++tt) { | 639 for (size_t tt = 0; tt < arraysize(tests); ++tt) { |
| 640 CheckReadPixelsOutOfRange( | 640 CheckReadPixelsOutOfRange( |
| 641 tests[tt][0], tests[tt][1], tests[tt][2], tests[tt][3], tt == 0); | 641 tests[tt][0], tests[tt][1], tests[tt][2], tests[tt][3], tt == 0); |
| 642 } | 642 } |
| 643 } | 643 } |
| 644 | 644 |
| 645 TEST_P(GLES2DecoderTest, ReadPixelsInvalidArgs) { | 645 TEST_P(GLES2DecoderTest, ReadPixelsInvalidArgs) { |
| 646 typedef ReadPixels::Result Result; | 646 typedef ReadPixels::Result Result; |
| 647 Result* result = GetSharedMemoryAs<Result*>(); | |
| 648 uint32 result_shm_id = kSharedMemoryId; | 647 uint32 result_shm_id = kSharedMemoryId; |
| 649 uint32 result_shm_offset = kSharedMemoryOffset; | 648 uint32 result_shm_offset = kSharedMemoryOffset; |
| 650 uint32 pixels_shm_id = kSharedMemoryId; | 649 uint32 pixels_shm_id = kSharedMemoryId; |
| 651 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); | 650 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(Result); |
| 652 EXPECT_CALL(*gl_, ReadPixels(_, _, _, _, _, _, _)).Times(0); | 651 EXPECT_CALL(*gl_, ReadPixels(_, _, _, _, _, _, _)).Times(0); |
| 653 ReadPixels cmd; | 652 ReadPixels cmd; |
| 654 cmd.Init(0, | 653 cmd.Init(0, |
| 655 0, | 654 0, |
| 656 -1, | 655 -1, |
| 657 1, | 656 1, |
| 658 GL_RGB, | 657 GL_RGB, |
| 659 GL_UNSIGNED_BYTE, | 658 GL_UNSIGNED_BYTE, |
| 660 pixels_shm_id, | 659 pixels_shm_id, |
| 661 pixels_shm_offset, | 660 pixels_shm_offset, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 TEST_P(GLES2DecoderManualInitTest, ReadPixelsAsyncError) { | 742 TEST_P(GLES2DecoderManualInitTest, ReadPixelsAsyncError) { |
| 744 InitState init; | 743 InitState init; |
| 745 init.extensions = "GL_ARB_sync"; | 744 init.extensions = "GL_ARB_sync"; |
| 746 init.gl_version = "opengl es 3.0"; | 745 init.gl_version = "opengl es 3.0"; |
| 747 init.has_alpha = true; | 746 init.has_alpha = true; |
| 748 init.request_alpha = true; | 747 init.request_alpha = true; |
| 749 init.bind_generates_resource = true; | 748 init.bind_generates_resource = true; |
| 750 InitDecoder(init); | 749 InitDecoder(init); |
| 751 | 750 |
| 752 typedef ReadPixels::Result Result; | 751 typedef ReadPixels::Result Result; |
| 753 Result* result = GetSharedMemoryAs<Result*>(); | |
| 754 | 752 |
| 755 const GLsizei kWidth = 4; | 753 const GLsizei kWidth = 4; |
| 756 const GLsizei kHeight = 4; | 754 const GLsizei kHeight = 4; |
| 757 uint32 result_shm_id = kSharedMemoryId; | 755 uint32 result_shm_id = kSharedMemoryId; |
| 758 uint32 result_shm_offset = kSharedMemoryOffset; | 756 uint32 result_shm_offset = kSharedMemoryOffset; |
| 759 uint32 pixels_shm_id = kSharedMemoryId; | 757 uint32 pixels_shm_id = kSharedMemoryId; |
| 760 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); | 758 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(Result); |
| 761 | 759 |
| 762 EXPECT_CALL(*gl_, GetError()) | 760 EXPECT_CALL(*gl_, GetError()) |
| 763 // first error check must pass to get to the test | 761 // first error check must pass to get to the test |
| 764 .WillOnce(Return(GL_NO_ERROR)) | 762 .WillOnce(Return(GL_NO_ERROR)) |
| 765 // second check is after BufferData, simulate fail here | 763 // second check is after BufferData, simulate fail here |
| 766 .WillOnce(Return(GL_INVALID_OPERATION)) | 764 .WillOnce(Return(GL_INVALID_OPERATION)) |
| 767 // third error check is fall-through call to sync ReadPixels | 765 // third error check is fall-through call to sync ReadPixels |
| 768 .WillOnce(Return(GL_NO_ERROR)) | 766 .WillOnce(Return(GL_NO_ERROR)) |
| 769 .RetiresOnSaturation(); | 767 .RetiresOnSaturation(); |
| 770 | 768 |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1630 true); | 1628 true); |
| 1631 } | 1629 } |
| 1632 | 1630 |
| 1633 TEST_P(GLES2DecoderTest, ReadPixelsGLError) { | 1631 TEST_P(GLES2DecoderTest, ReadPixelsGLError) { |
| 1634 GLenum kFormat = GL_RGBA; | 1632 GLenum kFormat = GL_RGBA; |
| 1635 GLint x = 0; | 1633 GLint x = 0; |
| 1636 GLint y = 0; | 1634 GLint y = 0; |
| 1637 GLsizei width = 2; | 1635 GLsizei width = 2; |
| 1638 GLsizei height = 4; | 1636 GLsizei height = 4; |
| 1639 typedef ReadPixels::Result Result; | 1637 typedef ReadPixels::Result Result; |
| 1640 Result* result = GetSharedMemoryAs<Result*>(); | |
| 1641 uint32 result_shm_id = kSharedMemoryId; | 1638 uint32 result_shm_id = kSharedMemoryId; |
| 1642 uint32 result_shm_offset = kSharedMemoryOffset; | 1639 uint32 result_shm_offset = kSharedMemoryOffset; |
| 1643 uint32 pixels_shm_id = kSharedMemoryId; | 1640 uint32 pixels_shm_id = kSharedMemoryId; |
| 1644 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); | 1641 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(Result); |
| 1645 EXPECT_CALL(*gl_, GetError()) | 1642 EXPECT_CALL(*gl_, GetError()) |
| 1646 .WillOnce(Return(GL_NO_ERROR)) | 1643 .WillOnce(Return(GL_NO_ERROR)) |
| 1647 .WillOnce(Return(GL_OUT_OF_MEMORY)) | 1644 .WillOnce(Return(GL_OUT_OF_MEMORY)) |
| 1648 .RetiresOnSaturation(); | 1645 .RetiresOnSaturation(); |
| 1649 EXPECT_CALL(*gl_, | 1646 EXPECT_CALL(*gl_, |
| 1650 ReadPixels(x, y, width, height, kFormat, GL_UNSIGNED_BYTE, _)) | 1647 ReadPixels(x, y, width, height, kFormat, GL_UNSIGNED_BYTE, _)) |
| 1651 .Times(1) | 1648 .Times(1) |
| 1652 .RetiresOnSaturation(); | 1649 .RetiresOnSaturation(); |
| 1653 ReadPixels cmd; | 1650 ReadPixels cmd; |
| 1654 cmd.Init(x, | 1651 cmd.Init(x, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1758 false); // scissor test | 1755 false); // scissor test |
| 1759 | 1756 |
| 1760 EXPECT_CALL(*gl_, GetError()) | 1757 EXPECT_CALL(*gl_, GetError()) |
| 1761 .WillOnce(Return(GL_NO_ERROR)) | 1758 .WillOnce(Return(GL_NO_ERROR)) |
| 1762 .WillOnce(Return(GL_NO_ERROR)) | 1759 .WillOnce(Return(GL_NO_ERROR)) |
| 1763 .RetiresOnSaturation(); | 1760 .RetiresOnSaturation(); |
| 1764 EXPECT_CALL(*gl_, ReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, _)) | 1761 EXPECT_CALL(*gl_, ReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, _)) |
| 1765 .Times(1) | 1762 .Times(1) |
| 1766 .RetiresOnSaturation(); | 1763 .RetiresOnSaturation(); |
| 1767 typedef ReadPixels::Result Result; | 1764 typedef ReadPixels::Result Result; |
| 1768 Result* result = GetSharedMemoryAs<Result*>(); | |
| 1769 uint32 result_shm_id = kSharedMemoryId; | 1765 uint32 result_shm_id = kSharedMemoryId; |
| 1770 uint32 result_shm_offset = kSharedMemoryOffset; | 1766 uint32 result_shm_offset = kSharedMemoryOffset; |
| 1771 uint32 pixels_shm_id = kSharedMemoryId; | 1767 uint32 pixels_shm_id = kSharedMemoryId; |
| 1772 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); | 1768 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(Result); |
| 1773 ReadPixels cmd; | 1769 ReadPixels cmd; |
| 1774 cmd.Init(0, | 1770 cmd.Init(0, |
| 1775 0, | 1771 0, |
| 1776 1, | 1772 1, |
| 1777 1, | 1773 1, |
| 1778 GL_RGBA, | 1774 GL_RGBA, |
| 1779 GL_UNSIGNED_BYTE, | 1775 GL_UNSIGNED_BYTE, |
| 1780 pixels_shm_id, | 1776 pixels_shm_id, |
| 1781 pixels_shm_offset, | 1777 pixels_shm_offset, |
| 1782 result_shm_id, | 1778 result_shm_id, |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2395 EXPECT_EQ(1, result->GetNumResults()); | 2391 EXPECT_EQ(1, result->GetNumResults()); |
| 2396 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2392 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2397 } | 2393 } |
| 2398 | 2394 |
| 2399 // TODO(gman): PixelStorei | 2395 // TODO(gman): PixelStorei |
| 2400 | 2396 |
| 2401 // TODO(gman): SwapBuffers | 2397 // TODO(gman): SwapBuffers |
| 2402 | 2398 |
| 2403 } // namespace gles2 | 2399 } // namespace gles2 |
| 2404 } // namespace gpu | 2400 } // namespace gpu |
| OLD | NEW |