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

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: build fix for win and mac, but cros need crrev.com/1208603002 Created 4 years, 11 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
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 a678415214522356e3a8adac1daeabe3a35d34fd..b405f97cf187d5c157e833080ab107b7126ac158 100644
--- a/ui/gl/gl_image_ozone_native_pixmap_unittest.cc
+++ b/ui/gl/gl_image_ozone_native_pixmap_unittest.cc
@@ -7,35 +7,82 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/buffer_types.h"
#include "ui/gl/gl_image_ozone_native_pixmap.h"
+#include "ui/gl/gl_utils.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 {
+template <gfx::BufferUsage usage>
class GLImageOzoneNativePixmapTestDelegate {
public:
scoped_refptr<gl::GLImage> CreateSolidColorImage(
const gfx::Size& size,
+ gfx::BufferFormat format,
const uint8_t color[4]) const {
+ DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u);
ui::SurfaceFactoryOzone* surface_factory =
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);
+ 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_RGBA));
- EXPECT_TRUE(image->Initialize(pixmap.get(), pixmap->GetBufferFormat()));
+ new gfx::GLImageOzoneNativePixmap(size,
+ gl::GetTextureFormatFrom(format)));
+ EXPECT_TRUE(image->Initialize(pixmap.get(), format));
return image;
}
+
+ static bool IsSupported(gfx::BufferFormat format) {
+ return ui::ClientNativePixmapFactory::GetInstance()
+ ->IsConfigurationSupported(format, usage);
+ }
};
+using GLImageTestTypesForGLImageTest = testing::Types<
+ GLImageOzoneNativePixmapTestDelegate<gfx::BufferUsage::GPU_READ>,
+ GLImageOzoneNativePixmapTestDelegate<gfx::BufferUsage::SCANOUT>,
+ GLImageOzoneNativePixmapTestDelegate<
+ gfx::BufferUsage::GPU_READ_CPU_READ_WRITE>,
+ GLImageOzoneNativePixmapTestDelegate<
+ gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT>>;
+
INSTANTIATE_TYPED_TEST_CASE_P(GLImageOzoneNativePixmap,
GLImageTest,
- GLImageOzoneNativePixmapTestDelegate);
+ 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

Powered by Google App Engine
This is Rietveld 408576698