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

Unified Diff: ui/gl/gl_image_ozone_native_pixmap_unittest.cc

Issue 1576353007: gl, ozone: add new GLImageBindTest unittests and make ozone run it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | ui/gl/test/gl_image_test_support.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 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
« no previous file with comments | « no previous file | ui/gl/test/gl_image_test_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698