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

Unified Diff: gpu/command_buffer/tests/gl_native_gmb_backbuffer_unittest.cc

Issue 2145643004: Fix preserve backbuffer with native GMBs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « gpu/command_buffer/tests/gl_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/tests/gl_native_gmb_backbuffer_unittest.cc
diff --git a/gpu/command_buffer/tests/gl_native_gmb_backbuffer_unittest.cc b/gpu/command_buffer/tests/gl_native_gmb_backbuffer_unittest.cc
index 2bb44e4fb4598f04bdd42fe6b445466f6721a8b8..cafe0c648798da6e4f743f2eb66e7c389704b966 100644
--- a/gpu/command_buffer/tests/gl_native_gmb_backbuffer_unittest.cc
+++ b/gpu/command_buffer/tests/gl_native_gmb_backbuffer_unittest.cc
@@ -15,21 +15,68 @@
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_image.h"
+#if defined(OS_MACOSX)
+#include "gpu/ipc/service/gpu_memory_buffer_factory_io_surface.h"
+#endif
+
namespace gpu {
class GLNativeGMBTest : public testing::Test {
protected:
void SetUp() override {
gl_.Initialize(GLManager::Options());
- image_factory_.SetRequiredTextureType(GL_TEXTURE_RECTANGLE_ARB);
}
void TearDown() override {
gl_.Destroy();
}
+ // Runs a simple battery of tests.
+ void RunBackbufferTestWithOptions(const GLManager::Options& options) {
+ GLManager gl;
+ gl.Initialize(options);
+ gl.MakeCurrent();
+
+ // Clear the back buffer and check that it has the right values.
+ glClearColor(0.0f, 0.25f, 0.5f, 0.7f);
+ glClear(GL_COLOR_BUFFER_BIT);
+ uint8_t pixel[4];
+ memset(pixel, 0, 4);
+ glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel);
+ EXPECT_NEAR(0u, pixel[0], 2);
+ EXPECT_NEAR(64u, pixel[1], 2);
+ EXPECT_NEAR(127u, pixel[2], 2);
+ uint8_t alpha = options.backbuffer_alpha ? 178 : 255;
+ EXPECT_NEAR(alpha, pixel[3], 2);
+
+ // Resize, then clear the back buffer and check its contents.
+ glResizeCHROMIUM(10, 10, 1, true);
+ glClearColor(0.5f, 0.6f, 0.7f, 0.8f);
+ glClear(GL_COLOR_BUFFER_BIT);
+ memset(pixel, 0, 4);
+ glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel);
+ EXPECT_NEAR(128u, pixel[0], 2);
+ EXPECT_NEAR(153u, pixel[1], 2);
+ EXPECT_NEAR(178u, pixel[2], 2);
+ uint8_t alpha2 = options.backbuffer_alpha ? 204 : 255;
+ EXPECT_NEAR(alpha2, pixel[3], 2);
+
+ // Swap buffers, then clear the back buffer and check its contents.
+ ::gles2::GetGLContext()->SwapBuffers();
+ glClearColor(0.1f, 0.2f, 0.3f, 0.4f);
+ glClear(GL_COLOR_BUFFER_BIT);
+ memset(pixel, 0, 4);
+ glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel);
+ EXPECT_NEAR(25u, pixel[0], 2);
+ EXPECT_NEAR(51u, pixel[1], 2);
+ EXPECT_NEAR(76u, pixel[2], 2);
+ uint8_t alpha3 = options.backbuffer_alpha ? 102 : 255;
+ EXPECT_NEAR(alpha3, pixel[3], 2);
+
+ gl.Destroy();
+ }
+
GLManager gl_;
- TextureImageFactory image_factory_;
};
TEST_F(GLNativeGMBTest, TestNativeGMBBackbufferWithDifferentConfigurations) {
@@ -37,55 +84,25 @@ TEST_F(GLNativeGMBTest, TestNativeGMBBackbufferWithDifferentConfigurations) {
LOG(INFO) << "GL_ARB_texture_rectangle not supported. Skipping test...";
return;
}
+#if defined(OS_MACOSX)
+ GpuMemoryBufferFactoryIOSurface image_factory;
+#else
+ TextureImageFactory image_factory;
+ image_factory.SetRequiredTextureType(GL_TEXTURE_RECTANGLE_ARB);
+#endif
for (int has_alpha = 0; has_alpha <= 1; ++has_alpha) {
for (int msaa = 0; msaa <= 1; ++msaa) {
- GLManager::Options options;
- options.image_factory = &image_factory_;
- options.multisampled = msaa == 1;
- options.backbuffer_alpha = has_alpha == 1;
-
- GLManager gl;
- gl.Initialize(options);
- gl.MakeCurrent();
-
- // Clear the back buffer and check that it has the right values.
- glClearColor(0.0f, 0.25f, 0.5f, 0.7f);
- glClear(GL_COLOR_BUFFER_BIT);
- uint8_t pixel[4];
- memset(pixel, 0, 4);
- glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel);
- EXPECT_NEAR(0u, pixel[0], 2);
- EXPECT_NEAR(64u, pixel[1], 2);
- EXPECT_NEAR(127u, pixel[2], 2);
- uint8_t alpha = has_alpha ? 178 : 255;
- EXPECT_NEAR(alpha, pixel[3], 2);
-
- // Resize, then clear the back buffer and check its contents.
- glResizeCHROMIUM(10, 10, 1, true);
- glClearColor(0.5f, 0.6f, 0.7f, 0.8f);
- glClear(GL_COLOR_BUFFER_BIT);
- memset(pixel, 0, 4);
- glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel);
- EXPECT_NEAR(128u, pixel[0], 2);
- EXPECT_NEAR(153u, pixel[1], 2);
- EXPECT_NEAR(178u, pixel[2], 2);
- uint8_t alpha2 = has_alpha ? 204 : 255;
- EXPECT_NEAR(alpha2, pixel[3], 2);
-
- // Swap buffers, then clear the back buffer and check its contents.
- ::gles2::GetGLContext()->SwapBuffers();
- glClearColor(0.1f, 0.2f, 0.3f, 0.4f);
- glClear(GL_COLOR_BUFFER_BIT);
- memset(pixel, 0, 4);
- glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel);
- EXPECT_NEAR(25u, pixel[0], 2);
- EXPECT_NEAR(51u, pixel[1], 2);
- EXPECT_NEAR(76u, pixel[2], 2);
- uint8_t alpha3 = has_alpha ? 102 : 255;
- EXPECT_NEAR(alpha3, pixel[3], 2);
-
- gl.Destroy();
+ for (int preserve_backbuffer = 0; preserve_backbuffer <= 1;
+ ++preserve_backbuffer) {
+ GLManager::Options options;
+ options.image_factory = &image_factory;
+ options.multisampled = msaa == 1;
+ options.backbuffer_alpha = has_alpha == 1;
+ options.preserve_backbuffer = preserve_backbuffer;
+
+ RunBackbufferTestWithOptions(options);
+ }
}
}
}
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698