Improve eglGetString processing to exclude certain not support extensions
This commit is contained in:
parent
5daf631b5d
commit
dd48136721
1 changed files with 41 additions and 43 deletions
|
|
@ -66,54 +66,52 @@ static EGLint rcQueryEGLString(EGLenum name, void* buffer, EGLint bufferSize)
|
||||||
static EGLint rcGetGLString(EGLenum name, void* buffer, EGLint bufferSize)
|
static EGLint rcGetGLString(EGLenum name, void* buffer, EGLint bufferSize)
|
||||||
{
|
{
|
||||||
RenderThreadInfo *tInfo = RenderThreadInfo::get();
|
RenderThreadInfo *tInfo = RenderThreadInfo::get();
|
||||||
const char *str = NULL;
|
std::string result;
|
||||||
int len = 0;
|
|
||||||
if (tInfo && tInfo->currContext.Ptr()) {
|
if (tInfo && tInfo->currContext) {
|
||||||
if (tInfo->currContext->isGL2()) {
|
const char *str = nullptr;
|
||||||
str = (const char *)s_gles2.glGetString(name);
|
if (tInfo->currContext->isGL2())
|
||||||
}
|
str = reinterpret_cast<const char*>(s_gles2.glGetString(name));
|
||||||
else {
|
else
|
||||||
str = (const char *)s_gles1.glGetString(name);
|
str = reinterpret_cast<const char*>(s_gles1.glGetString(name));
|
||||||
}
|
|
||||||
if (str) {
|
if (str)
|
||||||
len = strlen(str) + 1;
|
result += str;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We add the maximum supported GL protocol number into GL_EXTENSIONS
|
// We're forcing version 2.0 no matter what the host provides as
|
||||||
const char* glProtocolStr = NULL;
|
// our emulation layer isn't prepared for anything newer (yet).
|
||||||
if (name == GL_EXTENSIONS) {
|
// This goes in parallel with filtering the extension set for
|
||||||
glProtocolStr = ChecksumCalculatorThreadInfo::getMaxVersionString();
|
// any unwanted extensions. If we don't force the right version
|
||||||
if (len==0) len = 1; // the last byte
|
// here certain parts of the system will assume API conditions
|
||||||
len += strlen(glProtocolStr) + 1;
|
// which aren't met.
|
||||||
}
|
if (name == GL_VERSION)
|
||||||
|
result = "OpenGL ES 2.0";
|
||||||
|
else if (name == GL_EXTENSIONS) {
|
||||||
|
std::string approved_extensions = result;
|
||||||
|
std::vector<std::string> unsupported_extensions = {
|
||||||
|
// Leaving this enabled gives crippeled text rendering when
|
||||||
|
// using the host mesa GLES drivers.
|
||||||
|
"GL_EXT_unpack_subimage",
|
||||||
|
};
|
||||||
|
|
||||||
if (name == GL_VERSION) {
|
for (const auto &extension : unsupported_extensions) {
|
||||||
// We're forcing version 2.0 no matter what the host provides as
|
size_t start_pos = approved_extensions.find(extension);
|
||||||
// our emulation layer isn't prepared for anything newer (yet).
|
if(start_pos == std::string::npos)
|
||||||
// This goes in parallel with filtering the extension set for
|
continue;
|
||||||
// any unwanted extensions. If we don't force the right version
|
approved_extensions.replace(start_pos, extension.length(), "");
|
||||||
// here certain parts of the system will assume API conditions
|
|
||||||
// which aren't met.
|
|
||||||
static const char *version = "OpenGL ES 2.0";
|
|
||||||
str = version;
|
|
||||||
len = strlen(str) + 1;
|
|
||||||
}
|
|
||||||
if (!buffer || len > bufferSize) {
|
|
||||||
return -len;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name == GL_EXTENSIONS) {
|
|
||||||
snprintf((char *)buffer, bufferSize, "%s%s ", str ? str : "", glProtocolStr);
|
|
||||||
} else if (str) {
|
|
||||||
strcpy((char *)buffer, str);
|
|
||||||
} else {
|
|
||||||
if (bufferSize >= 1) {
|
|
||||||
((char*)buffer)[0] = '\0';
|
|
||||||
}
|
}
|
||||||
len = 0;
|
|
||||||
|
result = approved_extensions;
|
||||||
}
|
}
|
||||||
return len;
|
|
||||||
|
int nextBufferSize = result.size() + 1;
|
||||||
|
|
||||||
|
if (!buffer || nextBufferSize > bufferSize)
|
||||||
|
return -nextBufferSize;
|
||||||
|
|
||||||
|
snprintf(static_cast<char*>(buffer), nextBufferSize, "%s", result.c_str());
|
||||||
|
return nextBufferSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EGLint rcGetNumConfigs(uint32_t* p_numAttribs)
|
static EGLint rcGetNumConfigs(uint32_t* p_numAttribs)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue