src/third_party/angle/src/tests/gl_tests/BlitFramebufferANGLETest.cpp
TEST_P(BlitFramebufferTest, BlitSRGBToRGBOversizedSourceArea)
{
    constexpr const GLsizei kWidth  = 256;
    constexpr const GLsizei kHeight = 256;

    GLRenderbuffer sourceRBO, targetRBO;
    GLFramebuffer sourceFBO, targetFBO;
    initColorFBOWithCheckerPattern(&sourceFBO, &sourceRBO, GL_SRGB8_ALPHA8, kWidth, kHeight);
    initColorFBO(&targetFBO, &targetRBO, GL_RGBA8, kWidth, kHeight);

    EXPECT_GL_NO_ERROR();

    glViewport(0, 0, kWidth, kHeight);

    glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO);
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO);

    glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);

    // Blit so that the source area gets placed at the center of the target FBO.
    // The width of the source area is 1/4 of the width of the target FBO.
    glBlitFramebuffer(-3 * kWidth / 2, -3 * kHeight / 2, 5 * kWidth / 2, 5 * kHeight / 2, 0, 0,
                      kWidth, kHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);

    EXPECT_GL_NO_ERROR();

    glBindFramebuffer(GL_FRAMEBUFFER, targetFBO);

    // Source FBO colors can be found in the middle of the target FBO.
    EXPECT_PIXEL_COLOR_EQ(7 * kWidth / 16, 7 * kHeight / 16, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(7 * kWidth / 16, 9 * kHeight / 16, GLColor::green);
    EXPECT_PIXEL_COLOR_EQ(9 * kWidth / 16, 7 * kHeight / 16, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(9 * kWidth / 16, 9 * kHeight / 16, GLColor::yellow);

    // Clear color should remain around the edges of the target FBO (WebGL 2.0 spec explicitly
    // requires this and ANGLE is expected to follow that).
    EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::blue);
}
// Blit an SRGB framebuffer with an oversized source area (parts outside the source area should be
// clipped out).
Blit an SRGB framebuffer with an oversized source area (parts outside the source area should be
clipped out).
Blit an SRGB framebuffer with an oversized source area ( parts outside the source area should be clipped out ) .
TEST_P(BlitFramebufferTest, BlitSRGBToRGBOversizedSourceArea)
{
    constexpr const GLsizei kWidth  = 256;
    constexpr const GLsizei kHeight = 256;
    GLRenderbuffer sourceRBO, targetRBO;
    GLFramebuffer sourceFBO, targetFBO;
    initColorFBOWithCheckerPattern(&sourceFBO, &sourceRBO, GL_SRGB8_ALPHA8, kWidth, kHeight);
    initColorFBO(&targetFBO, &targetRBO, GL_RGBA8, kWidth, kHeight);
    EXPECT_GL_NO_ERROR();
    glViewport(0, 0, kWidth, kHeight);
    glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO);
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO);
    glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    glBlitFramebuffer(-3 * kWidth / 2, -3 * kHeight / 2, 5 * kWidth / 2, 5 * kHeight / 2, 0, 0,
                      kWidth, kHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
    EXPECT_GL_NO_ERROR();
    glBindFramebuffer(GL_FRAMEBUFFER, targetFBO);
    EXPECT_PIXEL_COLOR_EQ(7 * kWidth / 16, 7 * kHeight / 16, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(7 * kWidth / 16, 9 * kHeight / 16, GLColor::green);
    EXPECT_PIXEL_COLOR_EQ(9 * kWidth / 16, 7 * kHeight / 16, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(9 * kWidth / 16, 9 * kHeight / 16, GLColor::yellow);
    EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::blue);
}
TEST_P ( BlitFramebufferTest , BlitSRGBToRGBOversizedSourceArea ) { constexpr const GLsizei kWidth = 256 ; constexpr const GLsizei kHeight = 256 ; GLRenderbuffer sourceRBO , targetRBO ; GLFramebuffer sourceFBO , targetFBO ; initColorFBOWithCheckerPattern ( & sourceFBO , & sourceRBO , GL_SRGB8_ALPHA8 , kWidth , kHeight ) ; initColorFBO ( & targetFBO , & targetRBO , GL_RGBA8 , kWidth , kHeight ) ; EXPECT_GL_NO_ERROR ( ) ; glViewport ( 0 , 0 , kWidth , kHeight ) ; glBindFramebuffer ( GL_READ_FRAMEBUFFER , sourceFBO ) ; glBindFramebuffer ( GL_DRAW_FRAMEBUFFER , targetFBO ) ; glClearColor ( 0.0f , 0.0f , 1.0f , 1.0f ) ; glClear ( GL_COLOR_BUFFER_BIT ) ; glBlitFramebuffer ( -3 * kWidth / 2 , -3 * kHeight / 2 , 5 * kWidth / 2 , 5 * kHeight / 2 , 0 , 0 , kWidth , kHeight , GL_COLOR_BUFFER_BIT , GL_NEAREST ) ; EXPECT_GL_NO_ERROR ( ) ; glBindFramebuffer ( GL_FRAMEBUFFER , targetFBO ) ; EXPECT_PIXEL_COLOR_EQ ( 7 * kWidth / 16 , 7 * kHeight / 16 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( 7 * kWidth / 16 , 9 * kHeight / 16 , GLColor :: green ) ; EXPECT_PIXEL_COLOR_EQ ( 9 * kWidth / 16 , 7 * kHeight / 16 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( 9 * kWidth / 16 , 9 * kHeight / 16 , GLColor :: yellow ) ; EXPECT_PIXEL_COLOR_EQ ( kWidth / 4 , kHeight / 4 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( kWidth / 4 , 3 * kHeight / 4 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( 3 * kWidth / 4 , kHeight / 4 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( 3 * kWidth / 4 , 3 * kHeight / 4 , GLColor :: blue ) ; }
Blit an SRGB framebuffer with an oversized source area (parts outside the source area should be
clipped out).
Blit an SRGB framebuffer with an oversized source area ( parts outside the source area should be clipped out ) .
// Blit so that the source area gets placed at the center of the target FBO. // The width of the source area is 1/4 of the width of the target FBO. // Source FBO colors can be found in the middle of the target FBO. // Clear color should remain around the edges of the target FBO (WebGL 2.0 spec explicitly // requires this and ANGLE is expected to follow that).