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 57371ad289c2ed0afef80ac4ea5262b0a624cc78..d74a5ea56e68d666f0fc5ec6688d0a34aa567532 100644 |
--- a/ui/gl/gl_image_shared_memory_unittest.cc |
+++ b/ui/gl/gl_image_shared_memory_unittest.cc |
@@ -9,16 +9,17 @@ |
#include "base/sys_info.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "ui/gl/gl_image_shared_memory.h" |
+#include "ui/gl/gl_utils.h" |
#include "ui/gl/test/gl_image_test_template.h" |
namespace gl { |
namespace { |
-template <gfx::BufferFormat format> |
class GLImageSharedMemoryTestDelegate { |
public: |
scoped_refptr<gl::GLImage> CreateSolidColorImage( |
const gfx::Size& size, |
+ gfx::BufferFormat format, |
const uint8_t color[4]) const { |
DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u); |
base::SharedMemory shared_memory; |
@@ -29,8 +30,8 @@ class GLImageSharedMemoryTestDelegate { |
size.width(), size.height(), |
static_cast<int>(RowSizeForBufferFormat(size.width(), format, 0)), 0, |
format, color, reinterpret_cast<uint8_t*>(shared_memory.memory())); |
- scoped_refptr<gl::GLImageSharedMemory> image(new gl::GLImageSharedMemory( |
- size, gl::GLImageMemory::GetInternalFormatForTesting(format))); |
+ scoped_refptr<gl::GLImageSharedMemory> image( |
+ new gl::GLImageSharedMemory(size, gl::GetTextureFormatFrom(format))); |
rv = image->Initialize( |
base::SharedMemory::DuplicateHandle(shared_memory.handle()), |
gfx::GenericSharedMemoryId(0), format, 0, |
@@ -38,32 +39,39 @@ class GLImageSharedMemoryTestDelegate { |
EXPECT_TRUE(rv); |
return image; |
} |
-}; |
-using GLImageTestTypes = testing::Types< |
- GLImageSharedMemoryTestDelegate<gfx::BufferFormat::RGBX_8888>, |
- GLImageSharedMemoryTestDelegate<gfx::BufferFormat::RGBA_8888>, |
- GLImageSharedMemoryTestDelegate<gfx::BufferFormat::BGRX_8888>, |
- GLImageSharedMemoryTestDelegate<gfx::BufferFormat::BGRA_8888>>; |
+ static bool IsSupported(gfx::BufferFormat format) { |
+ switch (format) { |
+ case gfx::BufferFormat::RGBX_8888: |
+ case gfx::BufferFormat::RGBA_8888: |
+ case gfx::BufferFormat::BGRX_8888: |
+ case gfx::BufferFormat::BGRA_8888: |
+ return true; |
+ default: |
+ return false; |
+ } |
+ NOTREACHED(); |
+ return false; |
+ } |
+}; |
INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemory, |
GLImageTest, |
- GLImageTestTypes); |
+ GLImageSharedMemoryTestDelegate); |
INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemory, |
GLImageCopyTest, |
- GLImageTestTypes); |
+ GLImageSharedMemoryTestDelegate); |
class GLImageSharedMemoryPoolTestDelegate { |
public: |
scoped_refptr<gl::GLImage> CreateSolidColorImage( |
const gfx::Size& size, |
+ gfx::BufferFormat format, |
const uint8_t color[4]) const { |
// 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 stride = gfx::RowSizeForBufferFormat(size.width(), format, 0) * 2; |
size_t pool_size = |
stride * size.height() + base::SysInfo::VMAllocationGranularity() * 3; |
base::SharedMemory shared_memory; |
@@ -74,18 +82,27 @@ 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>(stride), 0, |
- gfx::BufferFormat::RGBA_8888, color, |
+ size.width(), size.height(), static_cast<int>(stride), 0, format, color, |
reinterpret_cast<uint8_t*>(shared_memory.memory()) + buffer_offset); |
scoped_refptr<gl::GLImageSharedMemory> image( |
- new gl::GLImageSharedMemory(size, GL_RGBA)); |
+ new gl::GLImageSharedMemory(size, gl::GetTextureFormatFrom(format))); |
rv = image->Initialize( |
base::SharedMemory::DuplicateHandle(shared_memory.handle()), |
- gfx::GenericSharedMemoryId(0), gfx::BufferFormat::RGBA_8888, |
- buffer_offset, stride); |
+ gfx::GenericSharedMemoryId(0), format, buffer_offset, stride); |
EXPECT_TRUE(rv); |
return image; |
} |
+ |
+ static bool IsSupported(gfx::BufferFormat format) { |
+ switch (format) { |
+ case gfx::BufferFormat::RGBA_8888: |
+ return true; |
+ default: |
+ return false; |
+ } |
+ NOTREACHED(); |
+ return false; |
+ } |
}; |
INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemoryPool, |