Commit 12ed3b6e by Ian Elliott Committed by Commit Bot

Vulkan: Create a pre-rotation BlitFramebuffer test

This test creates a predictable 256x256 pattern in an FBO (i.e. x-axis is red and y-axis is green), and then uses glBlitFramebuffer() to blit all or different halves of that FBO to the default framebuffer (i.e. the Vulkan swapchain). When run on a rotated Android device, the predictable pattern helps to determine if/how anything is wrong. Bug: b/158337857 Change-Id: I858964fcb34b8ee5fbdbeade0e1dacaafaea7fa3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2236994Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarIan Elliott <ianelliott@google.com> Commit-Queue: Ian Elliott <ianelliott@google.com>
parent 7a2bb492
...@@ -965,6 +965,403 @@ TEST_P(EGLPreRotationLargeSurfaceTest, OrientedWindowWithDraw) ...@@ -965,6 +965,403 @@ TEST_P(EGLPreRotationLargeSurfaceTest, OrientedWindowWithDraw)
testDrawingAndReadPixels(); testDrawingAndReadPixels();
} }
// Draw a predictable pattern (for testing pre-rotation) into an FBO, and then use glBlitFramebuffer
// to put that pattern into various places within the 400x300 window
TEST_P(EGLPreRotationLargeSurfaceTest, OrientedWindowWithBlitFramebuffer)
{
// http://anglebug.com/4453
ANGLE_SKIP_TEST_IF(isVulkanRenderer() && IsLinux() && IsIntel());
// Flaky on Linux SwANGLE http://anglebug.com/4453
ANGLE_SKIP_TEST_IF(IsLinux() && isSwiftshader());
constexpr GLuint kCoordMidWayShort = 127;
constexpr GLuint kCoordMidWayLong = 128;
constexpr GLColor kColorMidWayShortShort = GLColor(127, 127, 0, 255);
constexpr GLColor kColorMidWayShortLong = GLColor(127, 128, 0, 255);
constexpr GLColor kColorMidWayLongShort = GLColor(128, 127, 0, 255);
constexpr GLColor kColorMidWayLongLong = GLColor(128, 128, 0, 255);
// When scaling horizontally, the "black" and "green" colors have a 1 in the red component
constexpr GLColor kColorScaleHorizBlack = GLColor(1, 0, 0, 255);
constexpr GLColor kColorScaleHorizGreen = GLColor(1, 255, 0, 255);
// When scaling vertically, the "black" and "red" colors have a 1 in the green component
constexpr GLColor kColorScaleVertBlack = GLColor(0, 1, 0, 255);
constexpr GLColor kColorScaleVertRed = GLColor(255, 1, 0, 255);
// To aid in debugging, we want this window visible
setWindowVisible(mOSWindow, true);
initializeDisplay();
initializeSurfaceWithRGBA8888Config();
initializeContext();
eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
ASSERT_EGL_SUCCESS();
// Init program
constexpr char kVS[] =
"attribute vec2 position;\n"
"attribute vec2 redGreen;\n"
"varying vec2 v_data;\n"
"void main() {\n"
" gl_Position = vec4(position, 0, 1);\n"
" v_data = redGreen;\n"
"}";
constexpr char kFS[] =
"varying highp vec2 v_data;\n"
"void main() {\n"
" gl_FragColor = vec4(v_data, 0, 1);\n"
"}";
GLuint program = CompileProgram(kVS, kFS);
ASSERT_NE(0u, program);
glUseProgram(program);
GLint positionLocation = glGetAttribLocation(program, "position");
ASSERT_NE(-1, positionLocation);
GLint redGreenLocation = glGetAttribLocation(program, "redGreen");
ASSERT_NE(-1, redGreenLocation);
GLuint indexBuffer;
glGenBuffers(1, &indexBuffer);
GLuint vertexArray;
glGenVertexArrays(1, &vertexArray);
std::vector<GLuint> vertexBuffers(2);
glGenBuffers(2, &vertexBuffers[0]);
glBindVertexArray(vertexArray);
std::vector<GLushort> indices = {0, 1, 2, 2, 3, 0};
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLushort) * indices.size(), &indices[0],
GL_STATIC_DRAW);
std::vector<GLfloat> positionData = {// quad vertices
-1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f};
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffers[0]);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * positionData.size(), &positionData[0],
GL_STATIC_DRAW);
glVertexAttribPointer(positionLocation, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 2, nullptr);
glEnableVertexAttribArray(positionLocation);
std::vector<GLfloat> redGreenData = {// green(0,1), black(0,0), red(1,0), yellow(1,1)
0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f};
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffers[1]);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * redGreenData.size(), &redGreenData[0],
GL_STATIC_DRAW);
glVertexAttribPointer(redGreenLocation, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 2, nullptr);
glEnableVertexAttribArray(redGreenLocation);
ASSERT_GL_NO_ERROR();
// Create a texture-backed FBO and render the predictable pattern to it
GLuint framebuffer = 0;
GLuint texture = 0;
glGenFramebuffers(1, &framebuffer);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, mSize, mSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
ASSERT_GL_NO_ERROR();
glViewport(0, 0, mSize, mSize);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, nullptr);
// Ensure the predictable pattern seems correct in the FBO
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::black);
EXPECT_PIXEL_COLOR_EQ(0, mSize - 1, GLColor::green);
EXPECT_PIXEL_COLOR_EQ(mSize - 1, 0, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(mSize - 1, mSize - 1, GLColor::yellow);
EXPECT_PIXEL_COLOR_EQ(kCoordMidWayShort, kCoordMidWayShort, kColorMidWayShortShort);
EXPECT_PIXEL_COLOR_EQ(kCoordMidWayShort, kCoordMidWayLong, kColorMidWayShortLong);
EXPECT_PIXEL_COLOR_EQ(kCoordMidWayLong, kCoordMidWayShort, kColorMidWayLongShort);
EXPECT_PIXEL_COLOR_EQ(kCoordMidWayLong, kCoordMidWayLong, kColorMidWayLongLong);
ASSERT_GL_NO_ERROR();
//
// Test blitting the entire FBO image to a 256x256 part of the default framebuffer (no scaling)
//
// Blit from the FBO to the default framebuffer (i.e. the swapchain)
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glBlitFramebuffer(0, 0, mSize, mSize, 0, 0, mSize, mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
ASSERT_GL_NO_ERROR();
// Swap buffers to put the image in the window (so the test can be visually checked)
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_GL_NO_ERROR();
// Blit again to check the colors in the back buffer
glClear(GL_COLOR_BUFFER_BIT);
glBlitFramebuffer(0, 0, mSize, mSize, 0, 0, mSize, mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::black);
EXPECT_PIXEL_COLOR_EQ(0, mSize - 1, GLColor::green);
EXPECT_PIXEL_COLOR_EQ(mSize - 1, 0, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(mSize - 1, mSize - 1, GLColor::yellow);
EXPECT_PIXEL_COLOR_EQ(kCoordMidWayShort, kCoordMidWayShort, kColorMidWayShortShort);
EXPECT_PIXEL_COLOR_EQ(kCoordMidWayShort, kCoordMidWayLong, kColorMidWayShortLong);
EXPECT_PIXEL_COLOR_EQ(kCoordMidWayLong, kCoordMidWayShort, kColorMidWayLongShort);
EXPECT_PIXEL_COLOR_EQ(kCoordMidWayLong, kCoordMidWayLong, kColorMidWayLongLong);
ASSERT_GL_NO_ERROR();
// Clear to black and blit to a different part of the window
glClear(GL_COLOR_BUFFER_BIT);
GLint xOffset = 40;
GLint yOffset = 30;
glViewport(xOffset, yOffset, mSize, mSize);
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
glBlitFramebuffer(0, 0, mSize, mSize, xOffset, yOffset, xOffset + mSize, yOffset + mSize,
GL_COLOR_BUFFER_BIT, GL_NEAREST);
// Swap buffers to put the image in the window (so the test can be visually checked)
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_GL_NO_ERROR();
// Blit again to check the colors in the back buffer
glClear(GL_COLOR_BUFFER_BIT);
glBlitFramebuffer(0, 0, mSize, mSize, xOffset, yOffset, xOffset + mSize, yOffset + mSize,
GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
EXPECT_PIXEL_COLOR_EQ(xOffset + 0, yOffset + 0, GLColor::black);
EXPECT_PIXEL_COLOR_EQ(xOffset + 0, yOffset + mSize - 1, GLColor::green);
EXPECT_PIXEL_COLOR_EQ(xOffset + mSize - 1, yOffset + 0, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(xOffset + mSize - 1, yOffset + mSize - 1, GLColor::yellow);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayShort, yOffset + kCoordMidWayShort,
kColorMidWayShortShort);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayShort, yOffset + kCoordMidWayLong,
kColorMidWayShortLong);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayLong, yOffset + kCoordMidWayShort,
kColorMidWayLongShort);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayLong, yOffset + kCoordMidWayLong,
kColorMidWayLongLong);
ASSERT_GL_NO_ERROR();
//
// Test blitting half of the FBO image to a 128x256 or 256x128 part of the default framebuffer
// (no scaling)
//
// 1st) Clear to black and blit the left and right halves of the texture to the left and right
// halves of that different part of the window
glClear(GL_COLOR_BUFFER_BIT);
glViewport(xOffset, yOffset, mSize, mSize);
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
glBlitFramebuffer(0, 0, mSize / 2, mSize, xOffset, yOffset, xOffset + (mSize / 2),
yOffset + mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBlitFramebuffer(mSize / 2, 0, mSize, mSize, xOffset + (mSize / 2), yOffset, xOffset + mSize,
yOffset + mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
// Swap buffers to put the image in the window (so the test can be visually checked)
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_GL_NO_ERROR();
// Blit again to check the colors in the back buffer
glClear(GL_COLOR_BUFFER_BIT);
glBlitFramebuffer(0, 0, mSize / 2, mSize, xOffset, yOffset, xOffset + (mSize / 2),
yOffset + mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBlitFramebuffer(mSize / 2, 0, mSize, mSize, xOffset + (mSize / 2), yOffset, xOffset + mSize,
yOffset + mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
EXPECT_PIXEL_COLOR_EQ(xOffset + 0, yOffset + 0, GLColor::black);
EXPECT_PIXEL_COLOR_EQ(xOffset + 0, yOffset + mSize - 1, GLColor::green);
EXPECT_PIXEL_COLOR_EQ(xOffset + mSize - 1, yOffset + 0, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(xOffset + mSize - 1, yOffset + mSize - 1, GLColor::yellow);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayShort, yOffset + kCoordMidWayShort,
kColorMidWayShortShort);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayShort, yOffset + kCoordMidWayLong,
kColorMidWayShortLong);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayLong, yOffset + kCoordMidWayShort,
kColorMidWayLongShort);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayLong, yOffset + kCoordMidWayLong,
kColorMidWayLongLong);
ASSERT_GL_NO_ERROR();
// 2nd) Clear to black and this time blit the left half of the source texture to the right half
// of the destination window, and then blit the right half of the source texture to the left
// half of the destination window
glClear(GL_COLOR_BUFFER_BIT);
glViewport(xOffset, yOffset, mSize, mSize);
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
glBlitFramebuffer(mSize / 2, 0, mSize, mSize, xOffset, yOffset, xOffset + (mSize / 2),
yOffset + mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBlitFramebuffer(0, 0, mSize / 2, mSize, xOffset + (mSize / 2), yOffset, xOffset + mSize,
yOffset + mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
// Swap buffers to put the image in the window (so the test can be visually checked)
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_GL_NO_ERROR();
// Blit again to check the colors in the back buffer
glClear(GL_COLOR_BUFFER_BIT);
glBlitFramebuffer(mSize / 2, 0, mSize, mSize, xOffset, yOffset, xOffset + (mSize / 2),
yOffset + mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBlitFramebuffer(0, 0, mSize / 2, mSize, xOffset + (mSize / 2), yOffset, xOffset + mSize,
yOffset + mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayShort + 1, yOffset + 0, GLColor::black);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayShort + 1, yOffset + mSize - 1, GLColor::green);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayShort, yOffset + 0, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayShort, yOffset + mSize - 1, GLColor::yellow);
EXPECT_PIXEL_COLOR_EQ(xOffset + mSize - 1, yOffset + kCoordMidWayShort, kColorMidWayShortShort);
EXPECT_PIXEL_COLOR_EQ(xOffset + mSize - 1, yOffset + kCoordMidWayLong, kColorMidWayShortLong);
EXPECT_PIXEL_COLOR_EQ(xOffset + 0, yOffset + kCoordMidWayShort, kColorMidWayLongShort);
EXPECT_PIXEL_COLOR_EQ(xOffset + 0, yOffset + kCoordMidWayLong, kColorMidWayLongLong);
ASSERT_GL_NO_ERROR();
// 3rd) Clear to black and blit the top and bottom halves of the texture to the top and bottom
// halves of that different part of the window
glClear(GL_COLOR_BUFFER_BIT);
glViewport(xOffset, yOffset, mSize, mSize);
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
glBlitFramebuffer(0, 0, mSize, mSize / 2, xOffset, yOffset, xOffset + mSize,
yOffset + (mSize / 2), GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBlitFramebuffer(0, mSize / 2, mSize, mSize, xOffset, yOffset + (mSize / 2), xOffset + mSize,
yOffset + mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
// Swap buffers to put the image in the window (so the test can be visually checked)
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_GL_NO_ERROR();
// Blit again to check the colors in the back buffer
glClear(GL_COLOR_BUFFER_BIT);
glBlitFramebuffer(0, 0, mSize, mSize / 2, xOffset, yOffset, xOffset + mSize,
yOffset + (mSize / 2), GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBlitFramebuffer(0, mSize / 2, mSize, mSize, xOffset, yOffset + (mSize / 2), xOffset + mSize,
yOffset + mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
EXPECT_PIXEL_COLOR_EQ(xOffset + 0, yOffset + 0, GLColor::black);
EXPECT_PIXEL_COLOR_EQ(xOffset + 0, yOffset + mSize - 1, GLColor::green);
EXPECT_PIXEL_COLOR_EQ(xOffset + mSize - 1, yOffset + 0, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(xOffset + mSize - 1, yOffset + mSize - 1, GLColor::yellow);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayShort, yOffset + kCoordMidWayShort,
kColorMidWayShortShort);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayShort, yOffset + kCoordMidWayLong,
kColorMidWayShortLong);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayLong, yOffset + kCoordMidWayShort,
kColorMidWayLongShort);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayLong, yOffset + kCoordMidWayLong,
kColorMidWayLongLong);
ASSERT_GL_NO_ERROR();
// 4th) Clear to black and this time blit the top half of the source texture to the bottom half
// of the destination window, and then blit the bottom half of the source texture to the top
// half of the destination window
glClear(GL_COLOR_BUFFER_BIT);
glViewport(xOffset, yOffset, mSize, mSize);
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
glBlitFramebuffer(0, 0, mSize, mSize / 2, xOffset, yOffset + (mSize / 2), xOffset + mSize,
yOffset + mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBlitFramebuffer(0, mSize / 2, mSize, mSize, xOffset, yOffset, xOffset + mSize,
yOffset + (mSize / 2), GL_COLOR_BUFFER_BIT, GL_NEAREST);
// Swap buffers to put the image in the window (so the test can be visually checked)
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_GL_NO_ERROR();
// Blit again to check the colors in the back buffer
glClear(GL_COLOR_BUFFER_BIT);
glBlitFramebuffer(0, 0, mSize, mSize / 2, xOffset, yOffset + (mSize / 2), xOffset + mSize,
yOffset + mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBlitFramebuffer(0, mSize / 2, mSize, mSize, xOffset, yOffset, xOffset + mSize,
yOffset + (mSize / 2), GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
EXPECT_PIXEL_COLOR_EQ(xOffset + 0, yOffset + kCoordMidWayShort + 1, GLColor::black);
EXPECT_PIXEL_COLOR_EQ(xOffset + 0, yOffset + kCoordMidWayShort, GLColor::green);
EXPECT_PIXEL_COLOR_EQ(xOffset + mSize - 1, yOffset + kCoordMidWayShort + 1, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(xOffset + mSize - 1, yOffset + kCoordMidWayShort, GLColor::yellow);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayShort, yOffset + mSize - 1, kColorMidWayShortShort);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayShort, yOffset + 0, kColorMidWayShortLong);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayLong, yOffset + mSize - 1, kColorMidWayLongShort);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayLong, yOffset + 0, kColorMidWayLongLong);
ASSERT_GL_NO_ERROR();
//
// Test blitting the entire FBO image to a 128x256 or 256x128 part of the default framebuffer
// (requires scaling)
//
// 1st) Clear to black and blit the FBO to the left and right halves of that different part of
// the window
glClear(GL_COLOR_BUFFER_BIT);
glViewport(xOffset, yOffset, mSize, mSize);
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
glBlitFramebuffer(0, 0, mSize, mSize, xOffset, yOffset, xOffset + (mSize / 2), yOffset + mSize,
GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBlitFramebuffer(0, 0, mSize, mSize, xOffset + (mSize / 2), yOffset, xOffset + mSize,
yOffset + mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
// Swap buffers to put the image in the window (so the test can be visually checked)
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_GL_NO_ERROR();
// Blit again to check the colors in the back buffer
glClear(GL_COLOR_BUFFER_BIT);
glBlitFramebuffer(0, 0, mSize, mSize, xOffset, yOffset, xOffset + (mSize / 2), yOffset + mSize,
GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBlitFramebuffer(0, 0, mSize, mSize, xOffset + (mSize / 2), yOffset, xOffset + mSize,
yOffset + mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
EXPECT_PIXEL_COLOR_EQ(xOffset + 0, yOffset + 0, kColorScaleHorizBlack);
EXPECT_PIXEL_COLOR_EQ(xOffset + 0, yOffset + mSize - 1, kColorScaleHorizGreen);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayShort, yOffset + 0, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayShort, yOffset + mSize - 1, GLColor::yellow);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayLong, yOffset + 0, kColorScaleHorizBlack);
EXPECT_PIXEL_COLOR_EQ(xOffset + kCoordMidWayLong, yOffset + mSize - 1, kColorScaleHorizGreen);
EXPECT_PIXEL_COLOR_EQ(xOffset + mSize - 1, yOffset + 0, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(xOffset + mSize - 1, yOffset + mSize - 1, GLColor::yellow);
// 2nd) Clear to black and blit the FBO to the top and bottom halves of that different part of
// the window
glClear(GL_COLOR_BUFFER_BIT);
glViewport(xOffset, yOffset, mSize, mSize);
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
glBlitFramebuffer(0, 0, mSize, mSize, xOffset, yOffset, xOffset + mSize, yOffset + (mSize / 2),
GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBlitFramebuffer(0, 0, mSize, mSize, xOffset, yOffset + (mSize / 2), xOffset + mSize,
yOffset + mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
// Swap buffers to put the image in the window (so the test can be visually checked)
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_GL_NO_ERROR();
// Blit again to check the colors in the back buffer
glClear(GL_COLOR_BUFFER_BIT);
glBlitFramebuffer(0, 0, mSize, mSize, xOffset, yOffset, xOffset + mSize, yOffset + (mSize / 2),
GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBlitFramebuffer(0, 0, mSize, mSize, xOffset, yOffset + (mSize / 2), xOffset + mSize,
yOffset + mSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
EXPECT_PIXEL_COLOR_EQ(xOffset + 0, yOffset + 0, kColorScaleVertBlack);
EXPECT_PIXEL_COLOR_EQ(xOffset + mSize - 1, yOffset + 0, kColorScaleVertRed);
EXPECT_PIXEL_COLOR_EQ(xOffset + 0, yOffset + kCoordMidWayShort, GLColor::green);
EXPECT_PIXEL_COLOR_EQ(xOffset + mSize - 1, yOffset + kCoordMidWayShort, GLColor::yellow);
EXPECT_PIXEL_COLOR_EQ(xOffset + 0, yOffset + kCoordMidWayLong, kColorScaleVertBlack);
EXPECT_PIXEL_COLOR_EQ(xOffset + mSize - 1, yOffset + kCoordMidWayLong, kColorScaleVertRed);
EXPECT_PIXEL_COLOR_EQ(xOffset + 0, yOffset + mSize - 1, GLColor::green);
EXPECT_PIXEL_COLOR_EQ(xOffset + mSize - 1, yOffset + mSize - 1, GLColor::yellow);
ASSERT_EGL_SUCCESS();
}
// Test that the window can be reset repeatedly before surface creation. // Test that the window can be reset repeatedly before surface creation.
TEST_P(EGLSurfaceTest, ResetNativeWindow) TEST_P(EGLSurfaceTest, ResetNativeWindow)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment