#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <stdint.h>
#include "base/compiler_specific.h"
#include "gpu/command_buffer/tests/gl_manager.h"
#include "gpu/command_buffer/tests/gl_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace gpu {
class GLBGRAMipMapTest : public testing::Test {
protected:
void SetUp() override { gl_.Initialize(GLManager::Options()); }
void TearDown() override { gl_.Destroy(); }
bool ShouldSkipBGRA() const {
return !gl_.decoder()
->GetFeatureInfo()
->feature_flags()
.ext_texture_format_bgra8888;
}
GLManager gl_;
};
TEST_F(GLBGRAMipMapTest, GenerateMipmapsSucceeds) {
if (ShouldSkipBGRA()) {
return;
}
static const int kWidth = 100;
static const int kHeight = 50;
uint8_t pixels[kWidth * kHeight * 4];
GLuint tex = 0;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
UNSAFE_TODO(memset(pixels, 128, sizeof(pixels)));
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, kWidth, kHeight, 0,
GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels);
EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
glGenerateMipmap(GL_TEXTURE_2D);
EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
}
}