src/third_party/angle/src/tests/egl_tests/EGLSurfaceTest.cpp
// Test that the backbuffer is correctly resized after calling swapBuffers
Test that the backbuffer is correctly resized after calling swapBuffers
Test that the backbuffer is correctly resized after calling swapBuffers
TEST_P(EGLSurfaceTest, ResizeWindowWithDraw)
{
    ANGLE_SKIP_TEST_IF(IsLinux());
    setWindowVisible(mOSWindow, true);
    initializeDisplay();
    initializeSurfaceWithDefaultConfig(true);
    initializeContext();
    ASSERT_NE(mWindowSurface, EGL_NO_SURFACE);
    int size      = 64;
    EGLint height = 0;
    EGLint width  = 0;
    eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
    eglSwapBuffers(mDisplay, mWindowSurface);
    ASSERT_EGL_SUCCESS();
    glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    eglQuerySurface(mDisplay, mWindowSurface, EGL_HEIGHT, &height);
    eglQuerySurface(mDisplay, mWindowSurface, EGL_WIDTH, &width);
    ASSERT_EGL_SUCCESS();
    EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(size - 1, 0, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(size - 1, size - 1, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(0, size - 1, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(-1, -1, GLColor::transparentBlack);
    EXPECT_PIXEL_COLOR_EQ(size, 0, GLColor::transparentBlack);
    EXPECT_PIXEL_COLOR_EQ(0, size, GLColor::transparentBlack);
    EXPECT_PIXEL_COLOR_EQ(size, size, GLColor::transparentBlack);
    size = 1;
    mOSWindow->resize(size, size);
    eglSwapBuffers(mDisplay, mWindowSurface);
    ASSERT_EGL_SUCCESS();
    glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    eglQuerySurface(mDisplay, mWindowSurface, EGL_HEIGHT, &height);
    eglQuerySurface(mDisplay, mWindowSurface, EGL_WIDTH, &width);
    ASSERT_EGL_SUCCESS();
    EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
    EXPECT_PIXEL_COLOR_EQ(size - 1, 0, GLColor::green);
    EXPECT_PIXEL_COLOR_EQ(size - 1, size - 1, GLColor::green);
    EXPECT_PIXEL_COLOR_EQ(0, size - 1, GLColor::green);
    EXPECT_PIXEL_COLOR_EQ(-1, -1, GLColor::transparentBlack);
    EXPECT_PIXEL_COLOR_EQ(size, 0, GLColor::transparentBlack);
    EXPECT_PIXEL_COLOR_EQ(0, size, GLColor::transparentBlack);
    EXPECT_PIXEL_COLOR_EQ(size, size, GLColor::transparentBlack);
    size = 128;
    mOSWindow->resize(size, size);
    eglSwapBuffers(mDisplay, mWindowSurface);
    ASSERT_EGL_SUCCESS();
    glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    eglQuerySurface(mDisplay, mWindowSurface, EGL_HEIGHT, &height);
    eglQuerySurface(mDisplay, mWindowSurface, EGL_WIDTH, &width);
    ASSERT_EGL_SUCCESS();
    EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(size - 1, 0, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(size - 1, size - 1, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(0, size - 1, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(-1, -1, GLColor::transparentBlack);
    EXPECT_PIXEL_COLOR_EQ(size, 0, GLColor::transparentBlack);
    EXPECT_PIXEL_COLOR_EQ(0, size, GLColor::transparentBlack);
    EXPECT_PIXEL_COLOR_EQ(size, size, GLColor::transparentBlack);
}
TEST_P ( EGLSurfaceTest , ResizeWindowWithDraw ) { ANGLE_SKIP_TEST_IF ( IsLinux ( ) ) ; setWindowVisible ( mOSWindow , true ) ; initializeDisplay ( ) ; initializeSurfaceWithDefaultConfig ( true ) ; initializeContext ( ) ; ASSERT_NE ( mWindowSurface , EGL_NO_SURFACE ) ; int size = 64 ; EGLint height = 0 ; EGLint width = 0 ; eglMakeCurrent ( mDisplay , mWindowSurface , mWindowSurface , mContext ) ; eglSwapBuffers ( mDisplay , mWindowSurface ) ; ASSERT_EGL_SUCCESS ( ) ; glClearColor ( 1.0f , 0.0f , 0.0f , 1.0f ) ; glClear ( GL_COLOR_BUFFER_BIT ) ; eglQuerySurface ( mDisplay , mWindowSurface , EGL_HEIGHT , & height ) ; eglQuerySurface ( mDisplay , mWindowSurface , EGL_WIDTH , & width ) ; ASSERT_EGL_SUCCESS ( ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , 0 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( size - 1 , 0 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( size - 1 , size - 1 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , size - 1 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( -1 , -1 , GLColor :: transparentBlack ) ; EXPECT_PIXEL_COLOR_EQ ( size , 0 , GLColor :: transparentBlack ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , size , GLColor :: transparentBlack ) ; EXPECT_PIXEL_COLOR_EQ ( size , size , GLColor :: transparentBlack ) ; size = 1 ; mOSWindow -> resize ( size , size ) ; eglSwapBuffers ( mDisplay , mWindowSurface ) ; ASSERT_EGL_SUCCESS ( ) ; glClearColor ( 0.0f , 1.0f , 0.0f , 1.0f ) ; glClear ( GL_COLOR_BUFFER_BIT ) ; eglQuerySurface ( mDisplay , mWindowSurface , EGL_HEIGHT , & height ) ; eglQuerySurface ( mDisplay , mWindowSurface , EGL_WIDTH , & width ) ; ASSERT_EGL_SUCCESS ( ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , 0 , GLColor :: green ) ; EXPECT_PIXEL_COLOR_EQ ( size - 1 , 0 , GLColor :: green ) ; EXPECT_PIXEL_COLOR_EQ ( size - 1 , size - 1 , GLColor :: green ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , size - 1 , GLColor :: green ) ; EXPECT_PIXEL_COLOR_EQ ( -1 , -1 , GLColor :: transparentBlack ) ; EXPECT_PIXEL_COLOR_EQ ( size , 0 , GLColor :: transparentBlack ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , size , GLColor :: transparentBlack ) ; EXPECT_PIXEL_COLOR_EQ ( size , size , GLColor :: transparentBlack ) ; size = 128 ; mOSWindow -> resize ( size , size ) ; eglSwapBuffers ( mDisplay , mWindowSurface ) ; ASSERT_EGL_SUCCESS ( ) ; glClearColor ( 0.0f , 0.0f , 1.0f , 1.0f ) ; glClear ( GL_COLOR_BUFFER_BIT ) ; eglQuerySurface ( mDisplay , mWindowSurface , EGL_HEIGHT , & height ) ; eglQuerySurface ( mDisplay , mWindowSurface , EGL_WIDTH , & width ) ; ASSERT_EGL_SUCCESS ( ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , 0 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( size - 1 , 0 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( size - 1 , size - 1 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , size - 1 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( -1 , -1 , GLColor :: transparentBlack ) ; EXPECT_PIXEL_COLOR_EQ ( size , 0 , GLColor :: transparentBlack ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , size , GLColor :: transparentBlack ) ; EXPECT_PIXEL_COLOR_EQ ( size , size , GLColor :: transparentBlack ) ; }
Test that the backbuffer is correctly resized after calling swapBuffers
Test that the backbuffer is correctly resized after calling swapBuffers
// http://anglebug.com/4453 // Necessary for a window resizing test if there is no per-frame window size query // Clear to red // set window's size small // Clear to green // set window's height large // Clear to blue