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

Unified Diff: ui/gl/gl_image_ozone_native_pixmap_unittest.cc

Issue 1484473003: gl, ozone: enable GLImageBindTest unittests Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase based on crrev.com/1879243002 Created 4 years, 8 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_io_surface_unittest.cc ('k') | ui/gl/gl_image_ref_counted_memory_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 223ba6980265d186830c794424e9700dbfece1f5..59e4d2a5b000fed6d5c62702bbe980bc006efed7 100644
--- a/ui/gl/gl_image_ozone_native_pixmap_unittest.cc
+++ b/ui/gl/gl_image_ozone_native_pixmap_unittest.cc
@@ -8,14 +8,58 @@
#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"
namespace gl {
namespace {
+GLenum TextureFormat(gfx::BufferFormat format) {
+ switch (format) {
+ case gfx::BufferFormat::R_8:
+ return GL_RED;
+ case gfx::BufferFormat::RGBA_8888:
+ return GL_RGBA;
+ case gfx::BufferFormat::BGRA_8888:
+ return GL_BGRA_EXT;
+ case gfx::BufferFormat::RGBX_8888:
+ case gfx::BufferFormat::BGRX_8888:
+ return GL_RGB;
+ case gfx::BufferFormat::ATC:
+ case gfx::BufferFormat::ATCIA:
+ case gfx::BufferFormat::DXT1:
+ case gfx::BufferFormat::DXT5:
+ case gfx::BufferFormat::ETC1:
+ case gfx::BufferFormat::RGBA_4444:
+ case gfx::BufferFormat::YUV_420:
+ case gfx::BufferFormat::YUV_420_BIPLANAR:
+ case gfx::BufferFormat::UYVY_422:
+ NOTREACHED();
+ return 0;
+ }
+
+ NOTREACHED();
+ return 0;
+}
+
+template <gfx::BufferFormat format, gfx::BufferUsage usage>
class GLImageOzoneNativePixmapTestDelegate {
public:
+ scoped_refptr<GLImage> CreateImage(const gfx::Size& size) const {
+ ui::SurfaceFactoryOzone* surface_factory =
+ ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone();
+ scoped_refptr<ui::NativePixmap> pixmap =
+ surface_factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size,
+ format, usage);
+ EXPECT_TRUE(pixmap != nullptr);
+
+ scoped_refptr<gfx::GLImageOzoneNativePixmap> image(
+ new gfx::GLImageOzoneNativePixmap(size, TextureFormat(format)));
+ EXPECT_TRUE(image->Initialize(pixmap.get(), pixmap->GetBufferFormat()));
+ return image;
+ }
+
scoped_refptr<gl::GLImage> CreateSolidColorImage(
const gfx::Size& size,
const uint8_t color[4]) const {
@@ -23,21 +67,67 @@ class GLImageOzoneNativePixmapTestDelegate {
ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone();
scoped_refptr<ui::NativePixmap> pixmap =
surface_factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size,
- gfx::BufferFormat::RGBA_8888,
- gfx::BufferUsage::SCANOUT);
+ format, usage);
EXPECT_TRUE(pixmap != nullptr);
+
+ if (usage == gfx::BufferUsage::GPU_READ_CPU_READ_WRITE ||
+ usage == gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT) {
+ gfx::NativePixmapHandle handle = pixmap->ExportHandle();
+ std::unique_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_RGBA));
+ new gfx::GLImageOzoneNativePixmap(size, TextureFormat(format)));
EXPECT_TRUE(image->Initialize(pixmap.get(), pixmap->GetBufferFormat()));
return image;
}
unsigned GetTextureTarget() const { return GL_TEXTURE_2D; }
+
+ gfx::BufferFormat GetBufferFormat() const { return format; }
+
+ bool IsSupported() {
+ return ui::ClientNativePixmapFactory::GetInstance()
+ ->IsConfigurationSupported(format, usage);
+ }
};
+using GLImageTestTypes = testing::Types<
+ GLImageOzoneNativePixmapTestDelegate<gfx::BufferFormat::RGBA_8888,
+ gfx::BufferUsage::SCANOUT>,
+ GLImageOzoneNativePixmapTestDelegate<gfx::BufferFormat::RGBX_8888,
+ gfx::BufferUsage::SCANOUT>,
+ GLImageOzoneNativePixmapTestDelegate<gfx::BufferFormat::BGRA_8888,
+ gfx::BufferUsage::SCANOUT>,
+ GLImageOzoneNativePixmapTestDelegate<gfx::BufferFormat::BGRX_8888,
+ gfx::BufferUsage::SCANOUT>>;
+
INSTANTIATE_TYPED_TEST_CASE_P(GLImageOzoneNativePixmap,
GLImageTest,
- GLImageOzoneNativePixmapTestDelegate);
+ GLImageTestTypes);
+
+using GLImageBindTestTypes =
+ testing::Types<GLImageOzoneNativePixmapTestDelegate<
+ gfx::BufferFormat::R_8,
+ gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT>,
+ GLImageOzoneNativePixmapTestDelegate<
+ gfx::BufferFormat::BGRA_8888,
+ gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT>>;
dshwang 2016/05/03 11:40:25 R_8 and BGRA_8888 bind test passes on only ozone g
+
+INSTANTIATE_TYPED_TEST_CASE_P(GLImageOzoneNativePixmap,
+ GLImageBindTest,
+ GLImageBindTestTypes);
} // namespace
} // namespace gl
« no previous file with comments | « ui/gl/gl_image_io_surface_unittest.cc ('k') | ui/gl/gl_image_ref_counted_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698