src/third_party/angle/src/tests/gl_tests/PixmapTest.cpp
TEST_P(PixmapTest, BindTexImageAndRedefineTexture)
{
    // Test skipped because pixmaps are not supported or Pixmaps do not support binding to RGBA
    // textures.
    ANGLE_SKIP_TEST_IF(!mSupportsPixmaps || !mSupportsBindTexImage);

    EGLWindow *window = getEGLWindow();

    // Apply the Pixmap and clear it to purple
    eglMakeCurrent(window->getDisplay(), mPixmap, mPixmap, window->getContext());
    ASSERT_EGL_SUCCESS();

    glViewport(0, 0, static_cast<GLsizei>(mPixmapSize), static_cast<GLsizei>(mPixmapSize));
    glClearColor(1.0f, 0.0f, 1.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    ASSERT_GL_NO_ERROR();

    EXPECT_PIXEL_EQ(static_cast<GLint>(mPixmapSize) / 2, static_cast<GLint>(mPixmapSize) / 2, 255,
                    0, 255, 255);

    // Apply the window surface
    window->makeCurrent();

    // Create a texture and bind the Pixmap to it
    GLuint texture = 0;
    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    EXPECT_GL_NO_ERROR();

    eglBindTexImage(window->getDisplay(), mPixmap, EGL_BACK_BUFFER);
    glViewport(0, 0, getWindowWidth(), getWindowHeight());
    ASSERT_EGL_SUCCESS();

    // Redefine the texture
    unsigned int pixelValue = 0xFFFF00FF;
    std::vector<unsigned int> pixelData(getWindowWidth() * getWindowHeight(), pixelValue);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth(), getWindowHeight(), 0, GL_RGBA,
                 GL_UNSIGNED_BYTE, &pixelData[0]);

    // Draw a quad and verify that it is magenta
    glUseProgram(mTextureProgram);
    glUniform1i(mTextureUniformLocation, 0);

    drawQuad(mTextureProgram, essl31_shaders::PositionAttrib(), 0.5f);
    EXPECT_GL_NO_ERROR();

    // Verify that magenta was drawn
    EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 255, 0, 255, 255);

    glDeleteTextures(1, &texture);
}
// Bind a Pixmap, redefine the texture, and verify it renders correctly
Bind a Pixmap, redefine the texture, and verify it renders correctly
Bind a Pixmap redefine the texture and verify it renders correctly
TEST_P(PixmapTest, BindTexImageAndRedefineTexture)
{
    ANGLE_SKIP_TEST_IF(!mSupportsPixmaps || !mSupportsBindTexImage);
    EGLWindow *window = getEGLWindow();
    eglMakeCurrent(window->getDisplay(), mPixmap, mPixmap, window->getContext());
    ASSERT_EGL_SUCCESS();
    glViewport(0, 0, static_cast<GLsizei>(mPixmapSize), static_cast<GLsizei>(mPixmapSize));
    glClearColor(1.0f, 0.0f, 1.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    ASSERT_GL_NO_ERROR();
    EXPECT_PIXEL_EQ(static_cast<GLint>(mPixmapSize) / 2, static_cast<GLint>(mPixmapSize) / 2, 255,
                    0, 255, 255);
    window->makeCurrent();
    GLuint texture = 0;
    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    EXPECT_GL_NO_ERROR();
    eglBindTexImage(window->getDisplay(), mPixmap, EGL_BACK_BUFFER);
    glViewport(0, 0, getWindowWidth(), getWindowHeight());
    ASSERT_EGL_SUCCESS();
    unsigned int pixelValue = 0xFFFF00FF;
    std::vector<unsigned int> pixelData(getWindowWidth() * getWindowHeight(), pixelValue);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth(), getWindowHeight(), 0, GL_RGBA,
                 GL_UNSIGNED_BYTE, &pixelData[0]);
    glUseProgram(mTextureProgram);
    glUniform1i(mTextureUniformLocation, 0);
    drawQuad(mTextureProgram, essl31_shaders::PositionAttrib(), 0.5f);
    EXPECT_GL_NO_ERROR();
    EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 255, 0, 255, 255);
    glDeleteTextures(1, &texture);
}
TEST_P ( PixmapTest , BindTexImageAndRedefineTexture ) { ANGLE_SKIP_TEST_IF ( ! mSupportsPixmaps || ! mSupportsBindTexImage ) ; EGLWindow * window = getEGLWindow ( ) ; eglMakeCurrent ( window -> getDisplay ( ) , mPixmap , mPixmap , window -> getContext ( ) ) ; ASSERT_EGL_SUCCESS ( ) ; glViewport ( 0 , 0 , static_cast < GLsizei > ( mPixmapSize ) , static_cast < GLsizei > ( mPixmapSize ) ) ; glClearColor ( 1.0f , 0.0f , 1.0f , 1.0f ) ; glClear ( GL_COLOR_BUFFER_BIT ) ; ASSERT_GL_NO_ERROR ( ) ; EXPECT_PIXEL_EQ ( static_cast < GLint > ( mPixmapSize ) / 2 , static_cast < GLint > ( mPixmapSize ) / 2 , 255 , 0 , 255 , 255 ) ; window -> makeCurrent ( ) ; GLuint texture = 0 ; glGenTextures ( 1 , & texture ) ; glBindTexture ( GL_TEXTURE_2D , texture ) ; glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_NEAREST ) ; glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_NEAREST ) ; glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_S , GL_CLAMP_TO_EDGE ) ; glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_T , GL_CLAMP_TO_EDGE ) ; EXPECT_GL_NO_ERROR ( ) ; eglBindTexImage ( window -> getDisplay ( ) , mPixmap , EGL_BACK_BUFFER ) ; glViewport ( 0 , 0 , getWindowWidth ( ) , getWindowHeight ( ) ) ; ASSERT_EGL_SUCCESS ( ) ; unsigned int pixelValue = 0xFFFF00FF ; std :: vector < unsigned int > pixelData ( getWindowWidth ( ) * getWindowHeight ( ) , pixelValue ) ; glTexImage2D ( GL_TEXTURE_2D , 0 , GL_RGBA , getWindowWidth ( ) , getWindowHeight ( ) , 0 , GL_RGBA , GL_UNSIGNED_BYTE , & pixelData [ 0 ] ) ; glUseProgram ( mTextureProgram ) ; glUniform1i ( mTextureUniformLocation , 0 ) ; drawQuad ( mTextureProgram , essl31_shaders :: PositionAttrib ( ) , 0.5f ) ; EXPECT_GL_NO_ERROR ( ) ; EXPECT_PIXEL_EQ ( getWindowWidth ( ) / 2 , getWindowHeight ( ) / 2 , 255 , 0 , 255 , 255 ) ; glDeleteTextures ( 1 , & texture ) ; }
Bind a Pixmap, redefine the texture, and verify it renders correctly
Bind a Pixmap redefine the texture and verify it renders correctly
// Test skipped because pixmaps are not supported or Pixmaps do not support binding to RGBA // textures. // Apply the Pixmap and clear it to purple // Apply the window surface // Create a texture and bind the Pixmap to it // Redefine the texture // Draw a quad and verify that it is magenta // Verify that magenta was drawn