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

Unified Diff: ui/gl/test/gl_image_test_template.h

Issue 1484473003: gl, ozone: enable GLImageBindTest unittests Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add new GLImageBindTest unittests. add R_8 test. give up dynamic way 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
Index: ui/gl/test/gl_image_test_template.h
diff --git a/ui/gl/test/gl_image_test_template.h b/ui/gl/test/gl_image_test_template.h
index e10c64c77396624d3dda5c5e1faa97e01c202787..9b8a346f79df11eccfc9661bb7c24146b0194388 100644
--- a/ui/gl/test/gl_image_test_template.h
+++ b/ui/gl/test/gl_image_test_template.h
@@ -145,6 +145,9 @@ class GLImageTest : public testing::Test {
TYPED_TEST_CASE_P(GLImageTest);
TYPED_TEST_P(GLImageTest, CreateAndDestroy) {
+ if (!this->delegate_.IsSupported())
+ return;
+
const gfx::Size small_image_size(4, 4);
const gfx::Size large_image_size(512, 512);
const uint8_t image_color[] = {0, 0xff, 0, 0xff};
@@ -183,6 +186,9 @@ class GLImageZeroInitializeTest : public GLImageTest<GLImageTestDelegate> {};
TYPED_TEST_CASE_P(GLImageZeroInitializeTest);
TYPED_TEST_P(GLImageZeroInitializeTest, ZeroInitialize) {
+ // Ozone platform knows the supported format in runtime.
+ if (!this->delegate_.IsSupported())
dshwang 2016/04/08 13:16:31 reveman suggested to keep static way, while ozone
+ return;
#if defined(OS_MACOSX)
// This functionality is disabled on Mavericks because it breaks PDF
// rendering. https://crbug.com/594343.
@@ -235,11 +241,17 @@ class GLImageCopyTest : public GLImageTest<GLImageTestDelegate> {};
TYPED_TEST_CASE_P(GLImageCopyTest);
TYPED_TEST_P(GLImageCopyTest, CopyTexImage) {
+ if (!this->delegate_.IsSupported())
+ return;
+
const gfx::Size image_size(256, 256);
// These values are picked so that RGB -> YUV on the CPU converted
// back to RGB on the GPU produces the original RGB values without
// any error.
- const uint8_t image_color[] = {0x10, 0x20, 0, 0xff};
+ uint8_t image_color[] = {0x10, 0x20, 0x00, 0xff};
+ // glReadPixels(.., GL_RGBA, ..) for RED texture returns (R, 0x00, 0x00, 0xff)
+ if (gfx::BufferFormat::R_8 == this->delegate_.GetBufferFormat())
+ image_color[1] = 0x00;
const uint8_t texture_color[] = {0, 0, 0xff, 0xff};
GLuint framebuffer =
@@ -289,6 +301,59 @@ TYPED_TEST_P(GLImageCopyTest, CopyTexImage) {
// handles CopyTexImage correctly.
REGISTER_TYPED_TEST_CASE_P(GLImageCopyTest, CopyTexImage);
+template <typename GLImageTestDelegate>
+class GLImageBindTest : public GLImageTest<GLImageTestDelegate> {};
+
+TYPED_TEST_CASE_P(GLImageBindTest);
+
+TYPED_TEST_P(GLImageBindTest, BindTexImage) {
dshwang 2016/04/08 13:16:31 android can reuse this test also.
+ if (!this->delegate_.IsSupported())
+ return;
+
+ const gfx::Size image_size(256, 256);
+ // These values are picked so that RGB -> YUV on the CPU converted
+ // back to RGB on the GPU produces the original RGB values without
+ // any error.
+ uint8_t image_color[] = {0x10, 0x20, 0x00, 0xff};
+ // glReadPixels(.., GL_RGBA, ..) for RED texture returns (R, 0x00, 0x00, 0xff)
+ if (gfx::BufferFormat::R_8 == this->delegate_.GetBufferFormat())
+ image_color[1] = 0x00;
+
+ GLuint framebuffer =
+ GLTestHelper::SetupFramebuffer(image_size.width(), image_size.height());
+ ASSERT_TRUE(framebuffer);
+ glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer);
+ glViewport(0, 0, image_size.width(), image_size.height());
+
+ // Create a solid color green image of preferred format. This must succeed
+ // in order for a GLImage to be conformant.
+ scoped_refptr<gl::GLImage> image =
+ this->delegate_.CreateSolidColorImage(image_size, image_color);
+ ASSERT_TRUE(image);
+
+ // Bind |image| to |texture|.
+ unsigned target = this->delegate_.GetTextureTarget();
+ GLuint texture = GLTestHelper::CreateTexture(target);
+ bool rv = image->BindTexImage(target);
+ EXPECT_TRUE(rv);
+
+ // Draw |texture| to viewport.
+ DrawTextureQuad(target, image_size);
+
+ // Read back pixels to check expectations.
+ GLTestHelper::CheckPixels(0, 0, image_size.width(), image_size.height(),
+ image_color);
+
+ // Clean up.
+ glDeleteTextures(1, &texture);
+ glDeleteFramebuffersEXT(1, &framebuffer);
+ image->Destroy(true /* have_context */);
+}
+
+// The GLImageBindTest test case verifies that the GLImage implementation
+// handles BindTexImage correctly.
+REGISTER_TYPED_TEST_CASE_P(GLImageBindTest, BindTexImage);
+
} // namespace gl
#endif // UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_

Powered by Google App Engine
This is Rietveld 408576698