| 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 1e5ef1325f03c42c0d02258295f13c21188a44bd..44aa677c1b1889481bd8fd8d785116d3dc5c2011 100644
|
| --- a/ui/gl/gl_image_ozone_native_pixmap_unittest.cc
|
| +++ b/ui/gl/gl_image_ozone_native_pixmap_unittest.cc
|
| @@ -8,14 +8,20 @@
|
| #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.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"
|
|
|
| namespace gl {
|
| namespace {
|
|
|
| +template <gfx::BufferUsage usage>
|
| class GLImageOzoneNativePixmapTestDelegate {
|
| public:
|
| + GLImageOzoneNativePixmapTestDelegate() {
|
| + client_pixmap_factory_ = ui::ClientNativePixmapFactory::Create();
|
| + }
|
| scoped_refptr<gl::GLImage> CreateSolidColorImage(
|
| const gfx::Size& size,
|
| const uint8_t color[4]) const {
|
| @@ -23,9 +29,20 @@ class GLImageOzoneNativePixmapTestDelegate {
|
| ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone();
|
| scoped_refptr<ui::NativePixmap> pixmap =
|
| surface_factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size,
|
| - gfx::BufferFormat::RGBA_8888,
|
| - gfx::BufferUsage::SCANOUT);
|
| - EXPECT_TRUE(pixmap);
|
| + gfx::BufferFormat::BGRA_8888,
|
| + usage);
|
| + DCHECK(pixmap);
|
| + if (usage == gfx::BufferUsage::GPU_READ_CPU_READ_WRITE) {
|
| + auto client_pixmap = client_pixmap_factory_->ImportFromHandle(
|
| + pixmap->ExportHandle(), size, usage);
|
| + void* data = client_pixmap->Map();
|
| + EXPECT_TRUE(data);
|
| + GLImageTestSupport::SetBufferDataToColor(
|
| + size.width(), size.height(), pixmap->GetDmaBufPitch(0), 0,
|
| + pixmap->GetBufferFormat(), color, static_cast<uint8_t*>(data));
|
| + client_pixmap->Unmap();
|
| + }
|
| +
|
| scoped_refptr<gfx::GLImageOzoneNativePixmap> image(
|
| new gfx::GLImageOzoneNativePixmap(size, GL_RGBA));
|
| EXPECT_TRUE(image->Initialize(pixmap.get(), pixmap->GetBufferFormat()));
|
| @@ -33,11 +50,23 @@ class GLImageOzoneNativePixmapTestDelegate {
|
| }
|
|
|
| unsigned GetTextureTarget() const { return GL_TEXTURE_2D; }
|
| +
|
| + private:
|
| + std::unique_ptr<ui::ClientNativePixmapFactory> client_pixmap_factory_;
|
| };
|
|
|
| -INSTANTIATE_TYPED_TEST_CASE_P(GLImageOzoneNativePixmap,
|
| - GLImageTest,
|
| - GLImageOzoneNativePixmapTestDelegate);
|
| +INSTANTIATE_TYPED_TEST_CASE_P(
|
| + GLImageOzoneNativePixmap,
|
| + GLImageTest,
|
| + GLImageOzoneNativePixmapTestDelegate<gfx::BufferUsage::SCANOUT>);
|
| +
|
| +// This test is disabled since the trybots are running with Ozone X11
|
| +// implementation that doesn't support creating ClientNativePixmap.
|
| +// TODO(dcastagna): Implement ClientNativePixmapFactory on Ozone X11.
|
| +INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageOzoneNativePixmap,
|
| + GLImageBindTest,
|
| + GLImageOzoneNativePixmapTestDelegate<
|
| + gfx::BufferUsage::GPU_READ_CPU_READ_WRITE>);
|
|
|
| } // namespace
|
| } // namespace gl
|
|
|