TextureMapperContextAttributes.cpp [plain text]
#include "config.h"
#include "TextureMapperContextAttributes.h"
#if USE(TEXTURE_MAPPER_GL)
#include "TextureMapperGLHeaders.h"
#include <mutex>
#include <wtf/ThreadSpecific.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
static WTF::ThreadSpecific<TextureMapperContextAttributes>& threadSpecificAttributes()
{
static WTF::ThreadSpecific<TextureMapperContextAttributes>* s_textureMapperContextAttributes;
static std::once_flag s_onceFlag;
std::call_once(s_onceFlag,
[] {
s_textureMapperContextAttributes = new WTF::ThreadSpecific<TextureMapperContextAttributes>;
});
return *s_textureMapperContextAttributes;
}
const TextureMapperContextAttributes& TextureMapperContextAttributes::get()
{
auto& attributes = *threadSpecificAttributes();
if (!attributes.initialized) {
attributes.initialized = true;
#if USE(OPENGL_ES)
attributes.isGLES2Compliant = true;
String extensionsString(reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)));
attributes.supportsNPOTTextures = extensionsString.contains("GL_OES_texture_npot"_s);
attributes.supportsUnpackSubimage = extensionsString.contains("GL_EXT_unpack_subimage"_s);
#else
attributes.isGLES2Compliant = false;
attributes.supportsNPOTTextures = true;
attributes.supportsUnpackSubimage = true;
#endif
}
return attributes;
}
}
#endif // USE(TEXTURE_MAPPER_GL)