src/third_party/angle/src/tests/gl_tests/BlitFramebufferANGLETest.cpp
// Blit a subregion of an SRGB framebuffer to an RGB framebuffer.
Blit a subregion of an SRGB framebuffer to an RGB framebuffer.
Blit a subregion of an SRGB framebuffer to an RGB framebuffer .
TEST_P(BlitFramebufferTest, PartialBlitSRGBToRGB)
{
    constexpr const GLsizei kWidth  = 256;
    constexpr const GLsizei kHeight = 256;
    GLRenderbuffer sourceRBO, targetRBO;
    GLFramebuffer sourceFBO, targetFBO;
    initColorFBOWithCheckerPattern(&sourceFBO, &sourceRBO, GL_SRGB8_ALPHA8, kWidth * 2,
                                   kHeight * 2);
    initColorFBO(&targetFBO, &targetRBO, GL_RGBA8, kWidth, kHeight);
    EXPECT_GL_NO_ERROR();
    glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO);
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO);
    glViewport(0, 0, kWidth, kHeight);
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    glBlitFramebuffer(kWidth, kHeight, kWidth * 2, kHeight * 2, 0, 0, kWidth, kHeight,
                      GL_COLOR_BUFFER_BIT, GL_NEAREST);
    EXPECT_GL_NO_ERROR();
    glBindFramebuffer(GL_FRAMEBUFFER, targetFBO);
    EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::yellow);
    EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::yellow);
    EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::yellow);
    EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::yellow);
    glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO);
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO);
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    glBlitFramebuffer(kWidth * 2, 0, kWidth, kHeight, kWidth, 0, 0, kHeight, GL_COLOR_BUFFER_BIT,
                      GL_NEAREST);
    EXPECT_GL_NO_ERROR();
    glBindFramebuffer(GL_FRAMEBUFFER, targetFBO);
    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 , PartialBlitSRGBToRGB ) { constexpr const GLsizei kWidth = 256 ; constexpr const GLsizei kHeight = 256 ; GLRenderbuffer sourceRBO , targetRBO ; GLFramebuffer sourceFBO , targetFBO ; initColorFBOWithCheckerPattern ( & sourceFBO , & sourceRBO , GL_SRGB8_ALPHA8 , kWidth * 2 , kHeight * 2 ) ; initColorFBO ( & targetFBO , & targetRBO , GL_RGBA8 , kWidth , kHeight ) ; EXPECT_GL_NO_ERROR ( ) ; glBindFramebuffer ( GL_READ_FRAMEBUFFER , sourceFBO ) ; glBindFramebuffer ( GL_DRAW_FRAMEBUFFER , targetFBO ) ; glViewport ( 0 , 0 , kWidth , kHeight ) ; glClearColor ( 0.0f , 0.0f , 0.0f , 0.0f ) ; glClear ( GL_COLOR_BUFFER_BIT ) ; glBlitFramebuffer ( kWidth , kHeight , kWidth * 2 , kHeight * 2 , 0 , 0 , kWidth , kHeight , GL_COLOR_BUFFER_BIT , GL_NEAREST ) ; EXPECT_GL_NO_ERROR ( ) ; glBindFramebuffer ( GL_FRAMEBUFFER , targetFBO ) ; EXPECT_PIXEL_COLOR_EQ ( kWidth / 4 , kHeight / 4 , GLColor :: yellow ) ; EXPECT_PIXEL_COLOR_EQ ( kWidth / 4 , 3 * kHeight / 4 , GLColor :: yellow ) ; EXPECT_PIXEL_COLOR_EQ ( 3 * kWidth / 4 , kHeight / 4 , GLColor :: yellow ) ; EXPECT_PIXEL_COLOR_EQ ( 3 * kWidth / 4 , 3 * kHeight / 4 , GLColor :: yellow ) ; glBindFramebuffer ( GL_READ_FRAMEBUFFER , sourceFBO ) ; glBindFramebuffer ( GL_DRAW_FRAMEBUFFER , targetFBO ) ; glClearColor ( 0.0f , 0.0f , 0.0f , 0.0f ) ; glClear ( GL_COLOR_BUFFER_BIT ) ; glBlitFramebuffer ( kWidth * 2 , 0 , kWidth , kHeight , kWidth , 0 , 0 , kHeight , GL_COLOR_BUFFER_BIT , GL_NEAREST ) ; EXPECT_GL_NO_ERROR ( ) ; glBindFramebuffer ( GL_FRAMEBUFFER , targetFBO ) ; 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 a subregion of an SRGB framebuffer to an RGB framebuffer.
Blit a subregion of an SRGB framebuffer to an RGB framebuffer .
// Blit a part of the source FBO without flipping. // Blit a part of the source FBO and flip in the X direction.