Commit f684678c authored by gman@chromium.org's avatar gman@chromium.org

Fix 2 Dr. Memory issues

1) Unit tests were incorrectly using TextureInfo
2) GLES2Implementation::TexSubImageImpl was reading 1-7 bytes
   too many.

TEST=ran with Dr.Memory
BUG=91786


Review URL: http://codereview.chromium.org/7541074

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95906 0039d316-1c4b-4281-b951-d872f2087c98
parent 233d67f1
...@@ -1416,7 +1416,8 @@ void GLES2Implementation::TexSubImage2DImpl( ...@@ -1416,7 +1416,8 @@ void GLES2Implementation::TexSubImage2DImpl(
static_cast<GLsizeiptr>(1)); static_cast<GLsizeiptr>(1));
while (height) { while (height) {
GLint num_rows = std::min(height, max_rows); GLint num_rows = std::min(height, max_rows);
GLsizeiptr part_size = num_rows * padded_row_size; GLsizeiptr part_size =
(num_rows - 1) * padded_row_size + unpadded_row_size;
void* buffer = transfer_buffer_.Alloc(part_size); void* buffer = transfer_buffer_.Alloc(part_size);
GLint y; GLint y;
if (unpack_flip_y_) { if (unpack_flip_y_) {
...@@ -1433,7 +1434,7 @@ void GLES2Implementation::TexSubImage2DImpl( ...@@ -1433,7 +1434,7 @@ void GLES2Implementation::TexSubImage2DImpl(
transfer_buffer_id_, transfer_buffer_.GetOffset(buffer), internal); transfer_buffer_id_, transfer_buffer_.GetOffset(buffer), internal);
transfer_buffer_.FreePendingToken(buffer, helper_->InsertToken()); transfer_buffer_.FreePendingToken(buffer, helper_->InsertToken());
yoffset += num_rows; yoffset += num_rows;
source += part_size; source += num_rows * padded_row_size;
height -= num_rows; height -= num_rows;
} }
} else { } else {
...@@ -1805,7 +1806,7 @@ void GLES2Implementation::ReadPixels( ...@@ -1805,7 +1806,7 @@ void GLES2Implementation::ReadPixels(
// Compute how much space those rows will take. The last row will not // Compute how much space those rows will take. The last row will not
// include padding. // include padding.
GLsizeiptr part_size = GLsizeiptr part_size =
unpadded_row_size + (padded_row_size * std::max(num_rows - 1, 0)); unpadded_row_size + padded_row_size * (num_rows - 1);
void* buffer = transfer_buffer_.Alloc(part_size); void* buffer = transfer_buffer_.Alloc(part_size);
*result = 0; // mark as failed. *result = 0; // mark as failed.
helper_->ReadPixels( helper_->ReadPixels(
......
...@@ -308,10 +308,11 @@ class TextureInfoTest : public testing::Test { ...@@ -308,10 +308,11 @@ class TextureInfoTest : public testing::Test {
::gfx::GLInterface::SetGLInterface(gl_.get()); ::gfx::GLInterface::SetGLInterface(gl_.get());
manager_.CreateTextureInfo(&feature_info_, kClient1Id, kService1Id); manager_.CreateTextureInfo(&feature_info_, kClient1Id, kService1Id);
info_ = manager_.GetTextureInfo(kClient1Id); info_ = manager_.GetTextureInfo(kClient1Id);
ASSERT_TRUE(info_ != NULL); ASSERT_TRUE(info_.get() != NULL);
} }
virtual void TearDown() { virtual void TearDown() {
info_ = NULL;
::gfx::GLInterface::SetGLInterface(NULL); ::gfx::GLInterface::SetGLInterface(NULL);
gl_.reset(); gl_.reset();
} }
...@@ -319,7 +320,7 @@ class TextureInfoTest : public testing::Test { ...@@ -319,7 +320,7 @@ class TextureInfoTest : public testing::Test {
// Use StrictMock to make 100% sure we know how GL will be called. // Use StrictMock to make 100% sure we know how GL will be called.
scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_;
TextureManager manager_; TextureManager manager_;
TextureManager::TextureInfo* info_; TextureManager::TextureInfo::Ref info_;
FeatureInfo feature_info_; FeatureInfo feature_info_;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment