Index: gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc |
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc |
index ce6fbb8c83b5e44c6f4c950f7dc0623d7bc65733..f7734a8b2a52461dcc21dee4d1d7e7d3005cdadb 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc |
@@ -660,6 +660,157 @@ TEST_P(GLES2DecoderTest, ReadPixels) { |
} |
} |
+TEST_P(GLES3DecoderTest, ReadPixels2PixelPackBufferNoBufferBound) { |
+ const GLsizei kWidth = 5; |
+ const GLsizei kHeight = 3; |
+ EXPECT_CALL(*gl_, ReadPixels(_, _, _, _, _, _, _)).Times(0); |
+ |
+ ReadPixels cmd; |
+ cmd.Init(0, |
+ 0, |
+ kWidth, |
+ kHeight, |
+ GL_RGBA, |
+ GL_UNSIGNED_BYTE, |
+ 0, |
+ 0, |
+ 0, |
+ 0, |
+ false); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
+} |
+ |
+TEST_P(GLES3DecoderTest, ReadPixelsBufferBound) { |
+ const GLsizei kWidth = 5; |
+ const GLsizei kHeight = 3; |
+ const GLint kBytesPerPixel = 4; |
+ GLint size = kWidth * kHeight * kBytesPerPixel; |
+ EXPECT_CALL(*gl_, ReadPixels(_, _, _, _, _, _, _)).Times(0); |
+ typedef ReadPixels::Result Result; |
+ Result* result = GetSharedMemoryAs<Result*>(); |
+ uint32 result_shm_id = kSharedMemoryId; |
+ uint32 result_shm_offset = kSharedMemoryOffset; |
+ uint32 pixels_shm_id = kSharedMemoryId; |
+ uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); |
+ |
+ DoBindBuffer(GL_PIXEL_PACK_BUFFER, client_buffer_id_, kServiceBufferId); |
+ DoBufferData(GL_PIXEL_PACK_BUFFER, size); |
+ |
+ ReadPixels cmd; |
+ cmd.Init(0, |
+ 0, |
+ kWidth, |
+ kHeight, |
+ GL_RGBA, |
+ GL_UNSIGNED_BYTE, |
+ pixels_shm_id, |
+ pixels_shm_offset, |
+ result_shm_id, |
+ result_shm_offset, |
+ false); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
+} |
+ |
+TEST_P(GLES3DecoderTest, ReadPixels2PixelPackBuffer) { |
+ const GLsizei kWidth = 5; |
+ const GLsizei kHeight = 3; |
+ const GLint kBytesPerPixel = 4; |
+ GLint size = kWidth * kHeight * kBytesPerPixel; |
+ |
+ DoBindBuffer(GL_PIXEL_PACK_BUFFER, client_buffer_id_, kServiceBufferId); |
+ DoBufferData(GL_PIXEL_PACK_BUFFER, size); |
+ |
+ EXPECT_CALL(*gl_, GetError()) |
+ .WillOnce(Return(GL_NO_ERROR)) |
+ .WillOnce(Return(GL_NO_ERROR)) |
+ .RetiresOnSaturation(); |
+ EXPECT_CALL(*gl_, |
+ ReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, _)); |
+ ReadPixels cmd; |
+ cmd.Init(0, |
+ 0, |
+ kWidth, |
+ kHeight, |
+ GL_RGBA, |
+ GL_UNSIGNED_BYTE, |
+ 0, |
+ 0, |
+ 0, |
+ 0, |
+ false); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
+} |
+ |
+TEST_P(GLES3DecoderTest, ReadPixelsPixelPackBufferMapped) { |
+ const GLsizei kWidth = 5; |
+ const GLsizei kHeight = 3; |
+ const GLint kBytesPerPixel = 4; |
+ GLint size = kWidth * kHeight * kBytesPerPixel; |
+ |
+ DoBindBuffer(GL_PIXEL_PACK_BUFFER, client_buffer_id_, kServiceBufferId); |
+ |
+ uint32_t result_shm_id = kSharedMemoryId; |
+ uint32_t result_shm_offset = kSharedMemoryOffset; |
+ uint32_t data_shm_id = kSharedMemoryId; |
+ // uint32_t is Result for both MapBufferRange and UnmapBuffer commands. |
+ uint32_t data_shm_offset = kSharedMemoryOffset + sizeof(uint32_t); |
+ EXPECT_CALL(*gl_, |
+ MapBufferRange(GL_PIXEL_PACK_BUFFER, 0, size, GL_MAP_READ_BIT)) |
+ .RetiresOnSaturation(); |
+ MapBufferRange map_buffer_range; |
+ map_buffer_range.Init(GL_PIXEL_PACK_BUFFER, 0, size, GL_MAP_READ_BIT, |
+ data_shm_id, data_shm_offset, |
+ result_shm_id, result_shm_offset); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(map_buffer_range)); |
+ EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
+ |
+ EXPECT_CALL(*gl_, ReadPixels(_, _, _, _, _, _, _)).Times(0); |
+ ReadPixels cmd; |
+ cmd.Init(0, |
+ 0, |
+ kWidth, |
+ kHeight, |
+ GL_RGBA, |
+ GL_UNSIGNED_BYTE, |
+ 0, |
+ 0, |
+ 0, |
+ 0, |
+ false); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
+} |
+ |
+TEST_P(GLES3DecoderTest, ReadPixelsPixelPackBufferIsNotLargeEnough) { |
+ const GLsizei kWidth = 5; |
+ const GLsizei kHeight = 3; |
+ const GLint kBytesPerPixel = 4; |
+ GLint size = kWidth * kHeight * kBytesPerPixel; |
+ |
+ DoBindBuffer(GL_PIXEL_PACK_BUFFER, client_buffer_id_, kServiceBufferId); |
+ |
+ DoBufferData(GL_PIXEL_PACK_BUFFER, size - 4); |
+ EXPECT_CALL(*gl_, ReadPixels(_, _, _, _, _, _, _)).Times(0); |
+ |
+ ReadPixels cmd; |
+ cmd.Init(0, |
+ 0, |
+ kWidth, |
+ kHeight, |
+ GL_RGBA, |
+ GL_UNSIGNED_BYTE, |
+ 0, |
+ 0, |
+ 0, |
+ 0, |
+ false); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
+} |
+ |
TEST_P(GLES2DecoderRGBBackbufferTest, ReadPixelsNoAlphaBackbuffer) { |
const GLsizei kWidth = 3; |
const GLsizei kHeight = 3; |