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

Unified Diff: ui/gl/gl_image_shared_memory_unittest.cc

Issue 1417363006: ui: Add support for creating GLImage instances from shared memory pools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@usage-rename
Patch Set: static_cast<off_t> to make windows build happy Created 5 years, 2 months 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 98eb20edd5ddf4fc220d8b0e0cfe106ddaf73e27..48dfce6a519bac4ff416364be41d48ff2a35c0bb 100644
--- a/ui/gl/gl_image_shared_memory_unittest.cc
+++ b/ui/gl/gl_image_shared_memory_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/memory/shared_memory.h"
+#include "base/sys_info.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/gl_image_shared_memory.h"
#include "ui/gl/test/gl_image_test_template.h"
@@ -28,7 +29,7 @@ class GLImageSharedMemoryTestDelegate {
size, GLImageMemory::GetInternalFormatForTesting(format)));
rv = image->Initialize(
base::SharedMemory::DuplicateHandle(shared_memory.handle()),
- GenericSharedMemoryId(0), format);
+ GenericSharedMemoryId(0), format, 0);
EXPECT_TRUE(rv);
return image;
}
@@ -48,5 +49,40 @@ INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemory,
GLImageCopyTest,
GLImageTestTypes);
+class GLImageSharedMemoryPoolTestDelegate {
+ public:
+ scoped_refptr<GLImage> CreateSolidColorImage(const Size& size,
+ const uint8_t color[4]) const {
+ // Create a shared memory segment that is 2 pages larger than image.
+ size_t pool_size =
+ BufferSizeForBufferFormat(size, BufferFormat::RGBA_8888) +
+ base::SysInfo::VMAllocationGranularity() * 3;
+ base::SharedMemory shared_memory;
+ bool rv = shared_memory.CreateAndMapAnonymous(pool_size);
+ DCHECK(rv);
+ // Initialize memory to a value that is easy to recognize if test fails.
+ memset(shared_memory.memory(), 0x55, pool_size);
+ // 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(), BufferFormat::RGBA_8888, 0)),
+ BufferFormat::RGBA_8888, color,
+ reinterpret_cast<uint8_t*>(shared_memory.memory()) + buffer_offset);
+ scoped_refptr<GLImageSharedMemory> image(
+ new GLImageSharedMemory(size, GL_RGBA));
+ rv = image->Initialize(
+ base::SharedMemory::DuplicateHandle(shared_memory.handle()),
+ GenericSharedMemoryId(0), BufferFormat::RGBA_8888, buffer_offset);
+ EXPECT_TRUE(rv);
+ return image;
+ }
+};
+
+INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemoryPool,
+ GLImageCopyTest,
+ GLImageSharedMemoryPoolTestDelegate);
+
} // namespace
} // namespace gfx
« 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