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

Unified Diff: ui/gl/gl_image_shared_memory_unittest.cc

Issue 1403283007: Re-land: ui: Add custom stride support to GLImageMemory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more missing static_casts Created 5 years, 1 month 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
« no previous file with comments | « ui/gl/gl_image_shared_memory.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_image_shared_memory_unittest.cc
diff --git a/ui/gl/gl_image_shared_memory_unittest.cc b/ui/gl/gl_image_shared_memory_unittest.cc
index 276996078eb0c20630301d103ca46122192cc7cc..da6feac37d4040512eafc5fa1b290c9312c5a82b 100644
--- a/ui/gl/gl_image_shared_memory_unittest.cc
+++ b/ui/gl/gl_image_shared_memory_unittest.cc
@@ -30,7 +30,8 @@ class GLImageSharedMemoryTestDelegate {
size, gl::GLImageMemory::GetInternalFormatForTesting(format)));
rv = image->Initialize(
base::SharedMemory::DuplicateHandle(shared_memory.handle()),
- gfx::GenericSharedMemoryId(0), format, 0);
+ gfx::GenericSharedMemoryId(0), format, 0,
+ gfx::RowSizeForBufferFormat(size.width(), format, 0));
EXPECT_TRUE(rv);
return image;
}
@@ -55,10 +56,13 @@ class GLImageSharedMemoryPoolTestDelegate {
scoped_refptr<gl::GLImage> CreateSolidColorImage(
const gfx::Size& size,
const uint8_t color[4]) const {
- // Create a shared memory segment that is 2 pages larger than image.
+ // Create a shared memory segment that holds an image with a stride that is
+ // twice the row size and 2 pages larger than image.
+ size_t stride = gfx::RowSizeForBufferFormat(
+ size.width(), gfx::BufferFormat::RGBA_8888, 0) *
+ 2;
size_t pool_size =
- gfx::BufferSizeForBufferFormat(size, gfx::BufferFormat::RGBA_8888) +
- base::SysInfo::VMAllocationGranularity() * 3;
+ stride * size.height() + base::SysInfo::VMAllocationGranularity() * 3;
base::SharedMemory shared_memory;
bool rv = shared_memory.CreateAndMapAnonymous(pool_size);
DCHECK(rv);
@@ -67,9 +71,7 @@ class GLImageSharedMemoryPoolTestDelegate {
// Place buffer at a non-zero non-page-aligned offset in shared memory.
size_t buffer_offset = 3 * base::SysInfo::VMAllocationGranularity() / 2;
GLImageTestSupport::SetBufferDataToColor(
- size.width(), size.height(),
- static_cast<int>(RowSizeForBufferFormat(
- size.width(), gfx::BufferFormat::RGBA_8888, 0)),
+ size.width(), size.height(), static_cast<int>(stride),
gfx::BufferFormat::RGBA_8888, color,
reinterpret_cast<uint8_t*>(shared_memory.memory()) + buffer_offset);
scoped_refptr<gl::GLImageSharedMemory> image(
@@ -77,7 +79,7 @@ class GLImageSharedMemoryPoolTestDelegate {
rv = image->Initialize(
base::SharedMemory::DuplicateHandle(shared_memory.handle()),
gfx::GenericSharedMemoryId(0), gfx::BufferFormat::RGBA_8888,
- buffer_offset);
+ buffer_offset, stride);
EXPECT_TRUE(rv);
return image;
}
« no previous file with comments | « ui/gl/gl_image_shared_memory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698