src/third_party/angle/src/tests/egl_tests/EGLSurfaceTest.cpp
// Verify switching between a surface with robust resource init and one without still clears alpha.
Verify switching between a surface with robust resource init and one without still clears alpha.
Verify switching between a surface with robust resource init and one without still clears alpha .
TEST_P(EGLSurfaceTest, RobustResourceInitAndEmulatedAlpha)
{
    ANGLE_SKIP_TEST_IF(IsNVIDIA() && isGLRenderer() && IsLinux());
    ANGLE_SKIP_TEST_IF(IsAndroid() && (IsNexus5X() || IsNexus6P()) && isGLESRenderer());
    initializeDisplay();
    ASSERT_NE(mDisplay, EGL_NO_DISPLAY);
    ANGLE_SKIP_TEST_IF(
        !IsEGLDisplayExtensionEnabled(mDisplay, "EGL_ANGLE_robust_resource_initialization"));
    constexpr EGLint kRGBAAttributes[] = {EGL_RED_SIZE,     8,
                                          EGL_GREEN_SIZE,   8,
                                          EGL_BLUE_SIZE,    8,
                                          EGL_ALPHA_SIZE,   8,
                                          EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
                                          EGL_NONE};
    EGLint configCount   = 0;
    EGLConfig rgbaConfig = nullptr;
    ASSERT_EGL_TRUE(eglChooseConfig(mDisplay, kRGBAAttributes, &rgbaConfig, 1, &configCount));
    ASSERT_EQ(configCount, 1);
    ASSERT_NE(rgbaConfig, nullptr);
    std::vector<EGLint> robustInitAttribs;
    robustInitAttribs.push_back(EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE);
    robustInitAttribs.push_back(EGL_TRUE);
    initializeSurfaceWithAttribs(rgbaConfig, robustInitAttribs);
    ASSERT_EGL_SUCCESS();
    ASSERT_NE(mWindowSurface, EGL_NO_SURFACE);
    initializeSingleContext(&mContext);
    ASSERT_EGL_SUCCESS();
    ASSERT_NE(mContext, EGL_NO_CONTEXT);
    eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
    ASSERT_EGL_SUCCESS();
    eglSwapBuffers(mDisplay, mWindowSurface);
    {
        ANGLE_GL_PROGRAM(program, essl1_shaders::vs::Simple(), essl1_shaders::fs::Red());
        glUseProgram(program);
        drawQuad(program, essl1_shaders::PositionAttrib(), 0.5f);
        ASSERT_GL_NO_ERROR();
        EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
        eglSwapBuffers(mDisplay, mWindowSurface);
    }
    tearDownContextAndSurface();
    constexpr EGLint kRGBAttributes[] = {EGL_RED_SIZE,     8,
                                         EGL_GREEN_SIZE,   8,
                                         EGL_BLUE_SIZE,    8,
                                         EGL_ALPHA_SIZE,   0,
                                         EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
                                         EGL_NONE};
    configCount         = 0;
    EGLConfig rgbConfig = nullptr;
    ASSERT_EGL_TRUE(eglChooseConfig(mDisplay, kRGBAttributes, &rgbConfig, 1, &configCount));
    ASSERT_EQ(configCount, 1);
    ASSERT_NE(rgbConfig, nullptr);
    initializeSurface(rgbConfig);
    ASSERT_EGL_SUCCESS();
    ASSERT_NE(mWindowSurface, EGL_NO_SURFACE);
    initializeSingleContext(&mContext);
    ASSERT_EGL_SUCCESS();
    ASSERT_NE(mContext, EGL_NO_CONTEXT);
    eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
    ASSERT_EGL_SUCCESS();
    {
        ANGLE_GL_PROGRAM(program, essl1_shaders::vs::Simple(), essl1_shaders::fs::Red());
        glUseProgram(program);
        drawQuad(program, essl1_shaders::PositionAttrib(), 0.5f);
        ASSERT_GL_NO_ERROR();
        EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
        eglSwapBuffers(mDisplay, mWindowSurface);
    }
}
TEST_P ( EGLSurfaceTest , RobustResourceInitAndEmulatedAlpha ) { ANGLE_SKIP_TEST_IF ( IsNVIDIA ( ) && isGLRenderer ( ) && IsLinux ( ) ) ; ANGLE_SKIP_TEST_IF ( IsAndroid ( ) && ( IsNexus5X ( ) || IsNexus6P ( ) ) && isGLESRenderer ( ) ) ; initializeDisplay ( ) ; ASSERT_NE ( mDisplay , EGL_NO_DISPLAY ) ; ANGLE_SKIP_TEST_IF ( ! IsEGLDisplayExtensionEnabled ( mDisplay , " " ) ) ; constexpr EGLint kRGBAAttributes [ ] = { EGL_RED_SIZE , 8 , EGL_GREEN_SIZE , 8 , EGL_BLUE_SIZE , 8 , EGL_ALPHA_SIZE , 8 , EGL_SURFACE_TYPE , EGL_WINDOW_BIT , EGL_NONE } ; EGLint configCount = 0 ; EGLConfig rgbaConfig = nullptr ; ASSERT_EGL_TRUE ( eglChooseConfig ( mDisplay , kRGBAAttributes , & rgbaConfig , 1 , & configCount ) ) ; ASSERT_EQ ( configCount , 1 ) ; ASSERT_NE ( rgbaConfig , nullptr ) ; std :: vector < EGLint > robustInitAttribs ; robustInitAttribs . push_back ( EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE ) ; robustInitAttribs . push_back ( EGL_TRUE ) ; initializeSurfaceWithAttribs ( rgbaConfig , robustInitAttribs ) ; ASSERT_EGL_SUCCESS ( ) ; ASSERT_NE ( mWindowSurface , EGL_NO_SURFACE ) ; initializeSingleContext ( & mContext ) ; ASSERT_EGL_SUCCESS ( ) ; ASSERT_NE ( mContext , EGL_NO_CONTEXT ) ; eglMakeCurrent ( mDisplay , mWindowSurface , mWindowSurface , mContext ) ; ASSERT_EGL_SUCCESS ( ) ; eglSwapBuffers ( mDisplay , mWindowSurface ) ; { ANGLE_GL_PROGRAM ( program , essl1_shaders :: vs :: Simple ( ) , essl1_shaders :: fs :: Red ( ) ) ; glUseProgram ( program ) ; drawQuad ( program , essl1_shaders :: PositionAttrib ( ) , 0.5f ) ; ASSERT_GL_NO_ERROR ( ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , 0 , GLColor :: red ) ; eglSwapBuffers ( mDisplay , mWindowSurface ) ; } tearDownContextAndSurface ( ) ; constexpr EGLint kRGBAttributes [ ] = { EGL_RED_SIZE , 8 , EGL_GREEN_SIZE , 8 , EGL_BLUE_SIZE , 8 , EGL_ALPHA_SIZE , 0 , EGL_SURFACE_TYPE , EGL_WINDOW_BIT , EGL_NONE } ; configCount = 0 ; EGLConfig rgbConfig = nullptr ; ASSERT_EGL_TRUE ( eglChooseConfig ( mDisplay , kRGBAttributes , & rgbConfig , 1 , & configCount ) ) ; ASSERT_EQ ( configCount , 1 ) ; ASSERT_NE ( rgbConfig , nullptr ) ; initializeSurface ( rgbConfig ) ; ASSERT_EGL_SUCCESS ( ) ; ASSERT_NE ( mWindowSurface , EGL_NO_SURFACE ) ; initializeSingleContext ( & mContext ) ; ASSERT_EGL_SUCCESS ( ) ; ASSERT_NE ( mContext , EGL_NO_CONTEXT ) ; eglMakeCurrent ( mDisplay , mWindowSurface , mWindowSurface , mContext ) ; ASSERT_EGL_SUCCESS ( ) ; { ANGLE_GL_PROGRAM ( program , essl1_shaders :: vs :: Simple ( ) , essl1_shaders :: fs :: Red ( ) ) ; glUseProgram ( program ) ; drawQuad ( program , essl1_shaders :: PositionAttrib ( ) , 0.5f ) ; ASSERT_GL_NO_ERROR ( ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , 0 , GLColor :: red ) ; eglSwapBuffers ( mDisplay , mWindowSurface ) ; } }
Verify switching between a surface with robust resource init and one without still clears alpha.
Verify switching between a surface with robust resource init and one without still clears alpha .
// http://anglebug.com/5279 // http://anglebug.com/5280 // Initialize and draw red to a Surface with robust resource init enabled. // RGBA robust init setup complete. Draw red and verify. // Create second RGB surface with robust resource disabled. // RGB non-robust init setup complete. Draw red and verify.