diff --git a/gfx/thebes/gfxAndroidPlatform.cpp b/gfx/thebes/gfxAndroidPlatform.cpp index 0a1d788a5d4..1540b5eddbc 100644 --- a/gfx/thebes/gfxAndroidPlatform.cpp +++ b/gfx/thebes/gfxAndroidPlatform.cpp @@ -42,6 +42,8 @@ #include "gfxFT2FontList.h" #include "gfxImageSurface.h" #include "nsXULAppAPI.h" +#include "nsIScreen.h" +#include "nsIScreenManager.h" #include "cairo.h" @@ -57,6 +59,15 @@ static FT_Library gPlatformFTLibrary = NULL; gfxAndroidPlatform::gfxAndroidPlatform() { FT_Init_FreeType(&gPlatformFTLibrary); + + nsCOMPtr screenMgr = do_GetService("@mozilla.org/gfx/screenmanager;1"); + nsCOMPtr screen; + screenMgr->GetPrimaryScreen(getter_AddRefs(screen)); + PRInt32 depth = 24; + screen->GetColorDepth(&depth); + + mOffscreenFormat = depth == 16 ? gfxASurface::ImageFormatRGB16_565 : + gfxASurface::ImageFormatARGB32; } gfxAndroidPlatform::~gfxAndroidPlatform() diff --git a/gfx/thebes/gfxAndroidPlatform.h b/gfx/thebes/gfxAndroidPlatform.h index 851525895f6..0b85749f10f 100644 --- a/gfx/thebes/gfxAndroidPlatform.h +++ b/gfx/thebes/gfxAndroidPlatform.h @@ -68,7 +68,7 @@ public: virtual bool SupportsAzure(mozilla::gfx::BackendType& aBackend) { aBackend = mozilla::gfx::BACKEND_SKIA; return true; } - virtual gfxImageFormat GetOffscreenFormat() { return gfxASurface::ImageFormatRGB16_565; } + virtual gfxImageFormat GetOffscreenFormat() { return mOffscreenFormat; } mozilla::RefPtr GetScaledFontForFont(gfxFont *aFont); @@ -102,6 +102,9 @@ public: virtual bool FontHintingEnabled() MOZ_OVERRIDE; FT_Library GetFTLibrary(); + +private: + gfxImageFormat mOffscreenFormat; }; #endif /* GFX_PLATFORM_ANDROID_H */