From 7b54dcd2ffbe1fcf802fd1eea67727f9a448f8a8 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Thu, 8 Mar 2012 18:41:28 -0500 Subject: [PATCH] Back out 2175db811fad (bug 734081) due to Android reftest failures. --- gfx/gl/GLContextProviderEGL.cpp | 78 +++++++++++++---------- widget/android/nsScreenManagerAndroid.cpp | 2 +- widget/gonk/nsWindow.cpp | 4 +- 3 files changed, 48 insertions(+), 36 deletions(-) diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp index c269923ea9e4..d321f6e5c6f8 100644 --- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -42,9 +42,6 @@ #include "mozilla/Preferences.h" #include "mozilla/Util.h" -#include "nsIScreen.h" -#include "nsIScreenManager.h" - #if defined(XP_UNIX) #ifdef MOZ_WIDGET_GTK2 @@ -2193,6 +2190,13 @@ static const EGLint kEGLConfigAttribsRGBA32[] = { LOCAL_EGL_NONE }; +// This struct is used only by CreateConfig below, but ISO C++98 forbids +// instantiating a template dependent on a locally-defined type. Boo-urns! +struct EGLAttribs { + gfxASurface::gfxImageFormat mFormat; + const EGLint* mAttribs; +}; + // Return true if a suitable EGLConfig was found and pass it out // through aConfig. Return false otherwise. // @@ -2201,41 +2205,47 @@ static const EGLint kEGLConfigAttribsRGBA32[] = { static bool CreateConfig(EGLConfig* aConfig) { - nsCOMPtr screenMgr = do_GetService("@mozilla.org/gfx/screenmanager;1"); - nsCOMPtr screen; - screenMgr->GetPrimaryScreen(getter_AddRefs(screen)); - PRInt32 depth = 24; - screen->GetColorDepth(&depth); + EGLAttribs attribsToTry[] = { +#ifdef MOZ_GFX_OPTIMIZE_MOBILE + // Prefer r5g6b5 for potential savings in memory bandwidth. + // This needs to be reevaluated for newer devices. + { gfxASurface::ImageFormatRGB16_565, kEGLConfigAttribsRGB16 }, +#endif + { gfxASurface::ImageFormatARGB32, kEGLConfigAttribsRGBA32 }, + }; EGLConfig configs[64]; - gfxASurface::gfxImageFormat format; - const EGLint* attribs = depth == 16 ? kEGLConfigAttribsRGB16 : - kEGLConfigAttribsRGBA32; - EGLint ncfg = ArrayLength(configs); + for (unsigned i = 0; i < ArrayLength(attribsToTry); ++i) { + const EGLAttribs& attribs = attribsToTry[i]; + EGLint ncfg = ArrayLength(configs); - if (!sEGLLibrary.fChooseConfig(EGL_DISPLAY(), attribs, - configs, ncfg, &ncfg) || - ncfg < 1) { - return false; - } - - for (int j = 0; j < ncfg; ++j) { - EGLConfig config = configs[j]; - EGLint r, g, b, a; - - if (sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config, - LOCAL_EGL_RED_SIZE, &r) && - sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config, - LOCAL_EGL_GREEN_SIZE, &g) && - sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config, - LOCAL_EGL_BLUE_SIZE, &b) && - sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config, - LOCAL_EGL_ALPHA_SIZE, &a) && - ((depth == 16 && r == 5 && g == 6 && b == 5) || - (depth == 24 && r == 8 && g == 8 && b == 8 && a == 8))) + if (!sEGLLibrary.fChooseConfig(EGL_DISPLAY(), attribs.mAttribs, + configs, ncfg, &ncfg) || + ncfg < 1) { - *aConfig = config; - return true; + continue; + } + + for (int j = 0; j < ncfg; ++j) { + EGLConfig config = configs[j]; + EGLint r, g, b, a; + + if (sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config, + LOCAL_EGL_RED_SIZE, &r) && + sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config, + LOCAL_EGL_GREEN_SIZE, &g) && + sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config, + LOCAL_EGL_BLUE_SIZE, &b) && + sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config, + LOCAL_EGL_ALPHA_SIZE, &a) && + ((gfxASurface::ImageFormatRGB16_565 == attribs.mFormat && + r == 5 && g == 6 && b == 5) || + (gfxASurface::ImageFormatARGB32 == attribs.mFormat && + r == 8 && g == 8 && b == 8 && a == 8))) + { + *aConfig = config; + return true; + } } } return false; diff --git a/widget/android/nsScreenManagerAndroid.cpp b/widget/android/nsScreenManagerAndroid.cpp index 4242d4b7ec7b..079b6dc66338 100644 --- a/widget/android/nsScreenManagerAndroid.cpp +++ b/widget/android/nsScreenManagerAndroid.cpp @@ -78,7 +78,7 @@ nsScreenAndroid::GetPixelDepth(PRInt32 *aPixelDepth) { // XXX do we need to lie here about 16bpp? Or // should we actually check and return the right thing? - *aPixelDepth = 16; + *aPixelDepth = 24; return NS_OK; } diff --git a/widget/gonk/nsWindow.cpp b/widget/gonk/nsWindow.cpp index afe5d9fab028..4bc61b0840fe 100644 --- a/widget/gonk/nsWindow.cpp +++ b/widget/gonk/nsWindow.cpp @@ -510,7 +510,9 @@ nsScreenGonk::GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, NS_IMETHODIMP nsScreenGonk::GetPixelDepth(PRInt32 *aPixelDepth) { - *aPixelDepth = gNativeWindow->getDevice()->format == GGL_PIXEL_FORMAT_RGB_565 ? 16 : 24; + // XXX do we need to lie here about 16bpp? Or + // should we actually check and return the right thing? + *aPixelDepth = 24; return NS_OK; }