Index: ui/gl/gl_image_ozone_native_pixmap_unittest.cc |
diff --git a/ui/gl/gl_image_ozone_native_pixmap_unittest.cc b/ui/gl/gl_image_ozone_native_pixmap_unittest.cc |
index 2fbb941bd5d7debe99085eec4a19cc49b88944bc..6dd42e532d87bd7eeb33fdd177d0ee9378470f8c 100644 |
--- a/ui/gl/gl_image_ozone_native_pixmap_unittest.cc |
+++ b/ui/gl/gl_image_ozone_native_pixmap_unittest.cc |
@@ -8,6 +8,7 @@ |
#include "ui/gfx/buffer_types.h" |
#include "ui/gl/gl_image_ozone_native_pixmap.h" |
#include "ui/gl/test/gl_image_test_template.h" |
+#include "ui/ozone/public/client_native_pixmap_factory.h" |
#include "ui/ozone/public/ozone_platform.h" |
#include "ui/ozone/public/surface_factory_ozone.h" |
@@ -30,6 +31,23 @@ class GLImageOzoneNativePixmapTestDelegate { |
EXPECT_TRUE(pixmap != nullptr); |
EXPECT_EQ(format, pixmap->GetBufferFormat()); |
+ if (usage == gfx::BufferUsage::GPU_READ_CPU_READ_WRITE || |
+ usage == gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT) { |
+ gfx::NativePixmapHandle handle = pixmap->ExportHandle(); |
+ scoped_ptr<ui::ClientNativePixmap> native_pixmap = |
+ ui::ClientNativePixmapFactory::GetInstance()->ImportFromHandle( |
+ handle, size, usage); |
+ EXPECT_TRUE(native_pixmap != nullptr); |
+ |
+ GLImageTestSupport::SetBufferDataToColor( |
+ size.width(), size.height(), handle.stride, 0, format, color, |
+ reinterpret_cast<uint8_t*>(native_pixmap->Map())); |
+ native_pixmap->Unmap(); |
+ } else { |
+ // Cannot paint |color| on GPU_READ and SCANOUT buffer, but GLImageTest |
+ // doesn't check actual color, so it's fine so far. |
+ } |
+ |
scoped_refptr<gfx::GLImageOzoneNativePixmap> image( |
new gfx::GLImageOzoneNativePixmap( |
size, gl::GLImage::GetTextureFormatFrom(format))); |
@@ -38,12 +56,8 @@ class GLImageOzoneNativePixmapTestDelegate { |
} |
static bool IsSupported(gfx::BufferFormat format) { |
- switch (format) { |
- case gfx::BufferFormat::RGBA_8888: |
- return true; |
- default: |
- return false; |
- } |
+ return ui::ClientNativePixmapFactory::GetInstance() |
+ ->IsConfigurationSupported(format, usage); |
} |
}; |
@@ -59,5 +73,15 @@ INSTANTIATE_TYPED_TEST_CASE_P(GLImageOzoneNativePixmap, |
GLImageTest, |
GLImageTestTypesForGLImageTest); |
+using GLImageTestTypesForGLImageBindTest = |
+ testing::Types<GLImageOzoneNativePixmapTestDelegate< |
+ gfx::BufferUsage::GPU_READ_CPU_READ_WRITE>, |
+ GLImageOzoneNativePixmapTestDelegate< |
+ gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT>>; |
+ |
+INSTANTIATE_TYPED_TEST_CASE_P(GLImageOzoneNativePixmap, |
+ GLImageBindTest, |
+ GLImageTestTypesForGLImageBindTest); |
+ |
} // namespace |
} // namespace gl |