Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(786)

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc

Issue 1320093002: Command Buffer: read pixels into pixel pack buffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed zmo@'s feedback Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..c8a7197024e4dc4ffdc1432bfef40c9131b3aff1 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,154 @@ 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::kInvalidArguments, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, 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);
+ uint32 result_shm_id = kSharedMemoryId;
+ uint32 result_shm_offset = kSharedMemoryOffset;
+ uint32 pixels_shm_id = kSharedMemoryId;
+ uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(ReadPixels::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::kInvalidArguments, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, 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))
+ .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;

Powered by Google App Engine
This is Rietveld 408576698