| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // Tests for GLES2Implementation. | 5 // Tests for GLES2Implementation. | 
| 6 | 6 | 
| 7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" | 
| 8 | 8 | 
| 9 #include <limits> | 9 #include <limits> | 
| 10 | 10 | 
| (...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1669       mem1.id, mem1.offset, result1.id, result1.offset, | 1669       mem1.id, mem1.offset, result1.id, result1.offset, | 
| 1670       false); | 1670       false); | 
| 1671   expected.set_token1.Init(GetNextToken()); | 1671   expected.set_token1.Init(GetNextToken()); | 
| 1672   expected.read2.Init( | 1672   expected.read2.Init( | 
| 1673       0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, | 1673       0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, | 
| 1674       mem2.id, mem2.offset, result2.id, result2.offset, false); | 1674       mem2.id, mem2.offset, result2.id, result2.offset, false); | 
| 1675   expected.set_token2.Init(GetNextToken()); | 1675   expected.set_token2.Init(GetNextToken()); | 
| 1676   scoped_ptr<int8[]> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); | 1676   scoped_ptr<int8[]> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); | 
| 1677 | 1677 | 
| 1678   EXPECT_CALL(*command_buffer(), OnFlush()) | 1678   EXPECT_CALL(*command_buffer(), OnFlush()) | 
| 1679       .WillOnce(SetMemory(result1.ptr, static_cast<uint32>(1))) | 1679       .WillOnce(SetMemory(result1.ptr, static_cast<uint32>(GL_NO_ERROR))) | 
| 1680       .WillOnce(SetMemory(result2.ptr, static_cast<uint32>(1))) | 1680       .WillOnce(SetMemory(result2.ptr, static_cast<uint32>(GL_NO_ERROR))) | 
| 1681       .RetiresOnSaturation(); | 1681       .RetiresOnSaturation(); | 
| 1682 | 1682 | 
| 1683   gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); | 1683   gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); | 
| 1684   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1684   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 
| 1685 } | 1685 } | 
| 1686 | 1686 | 
| 1687 TEST_F(GLES2ImplementationTest, ReadPixelsBadFormatType) { | 1687 TEST_F(GLES2ImplementationTest, ReadPixelsBadFormatType) { | 
| 1688   struct Cmds { | 1688   struct Cmds { | 
| 1689     cmds::ReadPixels read; | 1689     cmds::ReadPixels read; | 
| 1690     cmd::SetToken set_token; | 1690     cmd::SetToken set_token; | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 1701       GetExpectedResultMemory(sizeof(cmds::ReadPixels::Result)); | 1701       GetExpectedResultMemory(sizeof(cmds::ReadPixels::Result)); | 
| 1702 | 1702 | 
| 1703   Cmds expected; | 1703   Cmds expected; | 
| 1704   expected.read.Init( | 1704   expected.read.Init( | 
| 1705       0, 0, kWidth, kHeight, kFormat, kType, | 1705       0, 0, kWidth, kHeight, kFormat, kType, | 
| 1706       mem1.id, mem1.offset, result1.id, result1.offset, false); | 1706       mem1.id, mem1.offset, result1.id, result1.offset, false); | 
| 1707   expected.set_token.Init(GetNextToken()); | 1707   expected.set_token.Init(GetNextToken()); | 
| 1708   scoped_ptr<int8[]> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); | 1708   scoped_ptr<int8[]> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); | 
| 1709 | 1709 | 
| 1710   EXPECT_CALL(*command_buffer(), OnFlush()) | 1710   EXPECT_CALL(*command_buffer(), OnFlush()) | 
| 1711       .Times(1) | 1711       .WillOnce(SetMemory(result1.ptr, | 
|  | 1712                           static_cast<uint32>(GL_INVALID_ENUM))) | 
| 1712       .RetiresOnSaturation(); | 1713       .RetiresOnSaturation(); | 
| 1713 | 1714 | 
| 1714   gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); | 1715   gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); | 
| 1715 } | 1716 } | 
| 1716 | 1717 | 
|  | 1718 TEST_F(GLES2ImplementationTest, MapBufferErrorPropagation) { | 
|  | 1719   const GLsizeiptr kBufferSize = 64; | 
|  | 1720 | 
|  | 1721   // Create a buffer for readback purposes. | 
|  | 1722   GLuint buffer = 0; | 
|  | 1723   gl_->GenBuffers(1, &buffer); | 
|  | 1724   gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, buffer); | 
|  | 1725   gl_->BufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | 
|  | 1726                   kBufferSize, | 
|  | 1727                   NULL, | 
|  | 1728                   GL_STREAM_READ); | 
|  | 1729 | 
|  | 1730   // Expect to successfully map the buffer that was just created. | 
|  | 1731   EXPECT_CALL(*command_buffer(), OnFlush()) | 
|  | 1732       .Times(1) | 
|  | 1733       .RetiresOnSaturation(); | 
|  | 1734   void* data = gl_->MapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | 
|  | 1735                                       GL_READ_ONLY); | 
|  | 1736   EXPECT_TRUE(data); | 
|  | 1737   gl_->UnmapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM); | 
|  | 1738 | 
|  | 1739   // Simulate the service encountering a GL_OUT_OF_MEMORY error during a | 
|  | 1740   // readback into the service-side buffer.  The GL error code is internally | 
|  | 1741   // stored in the 4 bytes following the end of the buffer. | 
|  | 1742   *(reinterpret_cast<uint32_t*>(static_cast<uint8_t*>(data) + kBufferSize)) = | 
|  | 1743       GL_OUT_OF_MEMORY; | 
|  | 1744 | 
|  | 1745   // Now, try to map the buffer again and expect failure. | 
|  | 1746   data = gl_->MapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | 
|  | 1747                                 GL_READ_ONLY); | 
|  | 1748   EXPECT_FALSE(data); | 
|  | 1749   EXPECT_EQ(GL_OUT_OF_MEMORY, gl_->GetError()); | 
|  | 1750 | 
|  | 1751   // Clean up. | 
|  | 1752   gl_->UnmapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM); | 
|  | 1753   gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0); | 
|  | 1754   gl_->DeleteBuffers(1, &buffer); | 
|  | 1755 } | 
|  | 1756 | 
| 1717 TEST_F(GLES2ImplementationTest, FreeUnusedSharedMemory) { | 1757 TEST_F(GLES2ImplementationTest, FreeUnusedSharedMemory) { | 
| 1718   struct Cmds { | 1758   struct Cmds { | 
| 1719     cmds::BufferSubData buf; | 1759     cmds::BufferSubData buf; | 
| 1720     cmd::SetToken set_token; | 1760     cmd::SetToken set_token; | 
| 1721   }; | 1761   }; | 
| 1722   const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; | 1762   const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; | 
| 1723   const GLintptr kOffset = 15; | 1763   const GLintptr kOffset = 15; | 
| 1724   const GLsizeiptr kSize = 16; | 1764   const GLsizeiptr kSize = 16; | 
| 1725 | 1765 | 
| 1726   ExpectedMemoryInfo mem1 = GetExpectedMemory(kSize); | 1766   ExpectedMemoryInfo mem1 = GetExpectedMemory(kSize); | 
| (...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3407   ContextInitOptions init_options; | 3447   ContextInitOptions init_options; | 
| 3408   init_options.bind_generates_resource_client = true; | 3448   init_options.bind_generates_resource_client = true; | 
| 3409   init_options.bind_generates_resource_service = false; | 3449   init_options.bind_generates_resource_service = false; | 
| 3410   EXPECT_FALSE(Initialize(init_options)); | 3450   EXPECT_FALSE(Initialize(init_options)); | 
| 3411 } | 3451 } | 
| 3412 | 3452 | 
| 3413 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 3453 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 
| 3414 | 3454 | 
| 3415 }  // namespace gles2 | 3455 }  // namespace gles2 | 
| 3416 }  // namespace gpu | 3456 }  // namespace gpu | 
| OLD | NEW | 
|---|