Commit 2648d929 by Geoff Lang Committed by Commit Bot

Fix scanForWantedComponents not ignoring attribute values of 0.

Slightly refactor scanForWantedComponents to not iterate over every attribute and only check the needed ones. BUG=angleproject:2069 Change-Id: I77bab7764552093f79472809aad3594be351831a Reviewed-on: https://chromium-review.googlesource.com/537132 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 165dcf15
...@@ -165,27 +165,22 @@ class ConfigSorter ...@@ -165,27 +165,22 @@ class ConfigSorter
} }
private: private:
void scanForWantedComponents(const AttributeMap &attributeMap) static bool wantsComponent(const AttributeMap &attributeMap, EGLAttrib component)
{ {
// [EGL 1.5] section 3.4.1.2 page 30 // [EGL 1.5] section 3.4.1.2 page 30
// Sorting rule #3: by larger total number of color bits, not considering // Sorting rule #3: by larger total number of color bits, not considering
// components that are 0 or don't-care. // components that are 0 or don't-care.
for (auto attribIter = attributeMap.begin(); attribIter != attributeMap.end(); attribIter++) EGLAttrib value = attributeMap.get(component, 0);
{ return value != 0 && value != EGL_DONT_CARE;
EGLAttrib attributeKey = attribIter->first; }
EGLAttrib attributeValue = attribIter->second;
if (attributeKey != 0 && attributeValue != EGL_DONT_CARE) void scanForWantedComponents(const AttributeMap &attributeMap)
{ {
switch (attributeKey) mWantRed = wantsComponent(attributeMap, EGL_RED_SIZE);
{ mWantGreen = wantsComponent(attributeMap, EGL_GREEN_SIZE);
case EGL_RED_SIZE: mWantRed = true; break; mWantBlue = wantsComponent(attributeMap, EGL_BLUE_SIZE);
case EGL_GREEN_SIZE: mWantGreen = true; break; mWantAlpha = wantsComponent(attributeMap, EGL_ALPHA_SIZE);
case EGL_BLUE_SIZE: mWantBlue = true; break; mWantLuminance = wantsComponent(attributeMap, EGL_LUMINANCE_SIZE);
case EGL_ALPHA_SIZE: mWantAlpha = true; break;
case EGL_LUMINANCE_SIZE: mWantLuminance = true; break;
}
}
}
} }
EGLint wantedComponentsSize(const Config &config) const EGLint wantedComponentsSize(const Config &config) const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment