summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorbsalomon@google.com <bsalomon@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-21 14:55:20 +0000
committerbsalomon@google.com <bsalomon@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-21 14:55:20 +0000
commit976f356d20fef409a45fb350b92eda093dc22bd5 (patch)
tree04761ce715c2d9d527bd34a34e233624d33624eb /gpu
parent96fa62bf80bd1cbe7988ce7078f7df08742b6b67 (diff)
downloadchromium_src-976f356d20fef409a45fb350b92eda093dc22bd5.zip
chromium_src-976f356d20fef409a45fb350b92eda093dc22bd5.tar.gz
chromium_src-976f356d20fef409a45fb350b92eda093dc22bd5.tar.bz2
Fix for GL_CHROMIUM_flipy in TexSubImage2D and unit test
TEST=none BUG=none Review URL: http://codereview.chromium.org/8587040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110923 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/client/gles2_implementation.cc6
-rw-r--r--gpu/command_buffer/client/gles2_implementation_unittest.cc68
2 files changed, 71 insertions, 3 deletions
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index 6d402c5..99eac94 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -1569,7 +1569,7 @@ void GLES2Implementation::TexSubImage2DImpl(
return;
}
- GLsizei original_height = height;
+ GLint original_yoffset = yoffset;
if (padded_row_size <= max_size) {
// Transfer by rows.
GLint max_rows = max_size / std::max(padded_row_size,
@@ -1584,7 +1584,7 @@ void GLES2Implementation::TexSubImage2DImpl(
CopyRectToBufferFlipped(
source, width, num_rows, format, type, buffer);
// GPU_DCHECK(copy_success); // can't check this because bot fails!
- y = original_height - yoffset - num_rows;
+ y = original_yoffset + height - num_rows;
} else {
memcpy(buffer, source, part_size);
y = yoffset;
@@ -1614,7 +1614,7 @@ void GLES2Implementation::TexSubImage2DImpl(
GLsizeiptr part_size = num_pixels * element_size;
void* buffer = transfer_buffer_.Alloc(part_size);
memcpy(buffer, row_source, part_size);
- GLint y = unpack_flip_y_ ? (original_height - yoffset - 1) : yoffset;
+ GLint y = unpack_flip_y_ ? (original_yoffset + height - 1) : yoffset;
helper_->TexSubImage2D(
target, level, temp_xoffset, y, num_pixels, 1, format, type,
transfer_buffer_id_, transfer_buffer_.GetOffset(buffer), internal);
diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc
index dc2f419..33098d1 100644
--- a/gpu/command_buffer/client/gles2_implementation_unittest.cc
+++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc
@@ -1755,6 +1755,74 @@ TEST_F(GLES2ImplementationTest, TexImage2DSubRows) {
GetTransferAddressFromOffsetAs<uint8>(offset4, part_size)));
}
+// Test TexSubImage2D with GL_PACK_FLIP_Y set and partial multirow transfers
+TEST_F(GLES2ImplementationTest, TexSubImage2DFlipY) {
+ const GLsizei kTextureWidth = MaxTransferBufferSize() / 4;
+ const GLsizei kTextureHeight = 7;
+ const GLsizei kSubImageWidth = MaxTransferBufferSize() / 8;
+ const GLsizei kSubImageHeight = 4;
+ const GLint kSubImageXOffset = 1;
+ const GLint kSubImageYOffset = 2;
+ const GLenum kFormat = GL_RGBA;
+ const GLenum kType = GL_UNSIGNED_BYTE;
+ const GLenum kTarget = GL_TEXTURE_2D;
+ const GLint kLevel = 0;
+ const GLint kBorder = 0;
+ const GLint kPixelStoreUnpackAlignment = 4;
+
+ struct Cmds {
+ PixelStorei pixel_store_i1;
+ TexImage2D tex_image_2d;
+ TexSubImage2D tex_sub_image_2d1;
+ cmd::SetToken set_token1;
+ TexSubImage2D tex_sub_image_2d2;
+ cmd::SetToken set_token2;
+ };
+
+ uint32 sub_2_high_size = 0;
+ ASSERT_TRUE(GLES2Util::ComputeImageDataSize(
+ kSubImageWidth, 2, kFormat, kType, kPixelStoreUnpackAlignment,
+ &sub_2_high_size));
+ uint32 offset1 = AllocateTransferBuffer(sub_2_high_size);
+ uint32 offset2 = AllocateTransferBuffer(sub_2_high_size);
+
+ Cmds expected;
+ expected.pixel_store_i1.Init(GL_UNPACK_ALIGNMENT, kPixelStoreUnpackAlignment);
+ expected.tex_image_2d.Init(
+ kTarget, kLevel, kFormat, kTextureWidth, kTextureHeight, kBorder, kFormat,
+ kType, 0, NULL);
+ expected.tex_sub_image_2d1.Init(kTarget, kLevel, kSubImageXOffset,
+ kSubImageYOffset + 2, kSubImageWidth, 2, kFormat, kType,
+ kTransferBufferId, offset1, false);
+ expected.set_token1.Init(GetNextToken());
+ expected.tex_sub_image_2d2.Init(kTarget, kLevel, kSubImageXOffset,
+ kSubImageYOffset, kSubImageWidth , 2, kFormat, kType, kTransferBufferId,
+ offset2, false);
+ expected.set_token2.Init(GetNextToken());
+
+ gl_->PixelStorei(GL_UNPACK_ALIGNMENT, kPixelStoreUnpackAlignment);
+ gl_->TexImage2D(
+ kTarget, kLevel, kFormat, kTextureWidth, kTextureHeight, kBorder, kFormat,
+ kType, NULL);
+ // this call should not emit commands (handled client-side)
+ gl_->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE);
+ scoped_array<uint32> pixels(new uint32[kSubImageWidth * kSubImageHeight]);
+ for (int y = 0; y < kSubImageHeight; ++y) {
+ for (int x = 0; x < kSubImageWidth; ++x) {
+ pixels.get()[kSubImageWidth * y + x] = x | (y << 16);
+ }
+ }
+ gl_->TexSubImage2D(
+ GL_TEXTURE_2D, 0, kSubImageXOffset, kSubImageYOffset, kSubImageWidth,
+ kSubImageHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get());
+
+ EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
+ EXPECT_TRUE(CheckRect(
+ kSubImageWidth, 2, kFormat, kType, kPixelStoreUnpackAlignment, true,
+ reinterpret_cast<uint8*>(pixels.get() + 2 * kSubImageWidth),
+ GetTransferAddressFromOffsetAs<uint8>(offset2, sub_2_high_size)));
+}
+
// Test that GenBuffer does not call GenSharedIds.
// This is because with client side arrays on we know the StrictSharedIdHandler
// for buffers has already gotten a set of ids