b=767064; use 4444/565 GL context format for WebGL on mobile; r=jgilbert

This commit is contained in:
Vladimir Vukicevic 2012-07-06 09:19:27 -04:00
parent 412176e299
commit 4c6ced282f
3 changed files with 57 additions and 27 deletions

View File

@ -407,16 +407,33 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
}
if (!mOptions.alpha) {
// Select 565; we won't/shouldn't hit this on the desktop,
// but let mobile know we're ok with it.
format.red = 5;
format.green = 6;
format.blue = 5;
format.alpha = 0;
format.minAlpha = 0;
}
// Don't do this on Windows, since we might get a 565 config from ANGLE
// and end up causing problems with a surface depth mismatch
#ifndef XP_WIN
if (gfxPlatform::GetPlatform()->GetScreenDepth() == 16) {
// Select 4444 or 565 on 16-bit displays; we won't/shouldn't
// hit this on the desktop, but let mobile know we're ok with
// it. Note that we don't just set this to 4440 if no alpha,
// because that might cause us to choose 4444 anyway and we
// don't want that.
if (mOptions.alpha) {
format.red = 4;
format.green = 4;
format.blue = 4;
format.alpha = 4;
} else {
format.red = 5;
format.green = 6;
format.blue = 5;
format.alpha = 0;
}
}
#endif
bool forceMSAA =
Preferences::GetBool("webgl.msaa-force", false);

View File

@ -1278,35 +1278,48 @@ GLContext::ChooseGLFormats(ContextFormat& aCF)
{
GLFormats formats;
if (aCF.alpha) {
if (mIsGLES2 && IsExtensionSupported(EXT_texture_format_BGRA8888)) {
formats.texColor = LOCAL_GL_BGRA;
} else {
// If we're on ES2 hardware and we have an explicit request for 16 bits of color or less
// OR we don't support full 8-bit color, return a 4444 or 565 format.
if (mIsGLES2 && (aCF.colorBits() <= 16 || !IsExtensionSupported(OES_rgb8_rgba8))) {
if (aCF.alpha) {
formats.texColor = LOCAL_GL_RGBA;
}
if (mIsGLES2 && !IsExtensionSupported(OES_rgb8_rgba8)) {
formats.texColorType = LOCAL_GL_UNSIGNED_SHORT_4_4_4_4;
formats.rbColor = LOCAL_GL_RGBA4;
aCF.red = aCF.green = aCF.blue = aCF.alpha = 4;
} else {
formats.rbColor = LOCAL_GL_RGBA8;
aCF.red = aCF.green = aCF.blue = aCF.alpha = 8;
}
} else {
formats.texColor = LOCAL_GL_RGB;
if (mIsGLES2 && !IsExtensionSupported(OES_rgb8_rgba8)) {
formats.texColor = LOCAL_GL_RGB;
formats.texColorType = LOCAL_GL_UNSIGNED_SHORT_5_6_5;
formats.rbColor = LOCAL_GL_RGB565;
aCF.red = 5;
aCF.green = 6;
aCF.blue = 5;
} else {
formats.rbColor = LOCAL_GL_RGB8;
aCF.red = aCF.green = aCF.blue = 8;
}
aCF.alpha = 0;
}
formats.texColorType = LOCAL_GL_UNSIGNED_BYTE;
aCF.alpha = 0;
}
} else {
formats.texColorType = LOCAL_GL_UNSIGNED_BYTE;
if (aCF.alpha) {
// prefer BGRA8888 on ES2 hardware; if the extension is supported, it
// should be faster.
if (mIsGLES2 && IsExtensionSupported(EXT_texture_format_BGRA8888)) {
formats.texColor = LOCAL_GL_BGRA;
} else {
formats.texColor = LOCAL_GL_RGBA;
}
formats.rbColor = LOCAL_GL_RGBA8;
aCF.red = aCF.green = aCF.blue = aCF.alpha = 8;
} else {
formats.texColor = LOCAL_GL_RGB;
formats.rbColor = LOCAL_GL_RGB8;
aCF.red = aCF.green = aCF.blue = 8;
aCF.alpha = 0;
}
}
GLsizei samples = aCF.samples;

View File

@ -1458,7 +1458,7 @@ gfxPlatform::GetLog(eGfxLog aWhichLog)
int
gfxPlatform::GetScreenDepth() const
{
MOZ_ASSERT(false, "Not implemented on this platform");
NS_WARNING("GetScreenDepth not implemented on this platform -- returning 0!");
return 0;
}