Backed out 4 changesets (bug 1182665) for android reftest orange CLOSED TREE
authorWes Kocher <wkocher@mozilla.com>
Fri, 11 Sep 2015 11:21:56 -0700
changeset 294679 6e0f7cb0fc3a70d6d5c4e519495a5f4e37d600d8
parent 294678 fcd8a338f3ada1baa9de23b7d6d94cb9580a84a5
child 294680 f14ff4e13b88eb2b66f6c344ed5cc4867ee25359
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1182665
milestone43.0a1
backs out719a4fbded105758a45503c2cd8240242d924809
9559cead8d0831bb26d15e7e8d94402f19e186ca
4080fb4b9a7f535b71cee23fc5692219e312b16b
c8549221c366b0bab175841af01af1edaeb55f94
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 4 changesets (bug 1182665) for android reftest orange CLOSED TREE Backed out changeset 719a4fbded10 (bug 1182665) Backed out changeset 9559cead8d08 (bug 1182665) Backed out changeset 4080fb4b9a7f (bug 1182665) Backed out changeset c8549221c366 (bug 1182665)
dom/ipc/ScreenManagerParent.cpp
gfx/layers/client/ContentClient.cpp
gfx/thebes/gfxAndroidPlatform.cpp
gfx/thebes/gfxAndroidPlatform.h
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
gfx/thebes/gfxPlatformGtk.cpp
gfx/thebes/gfxPlatformGtk.h
gfx/thebes/gfxQtPlatform.cpp
gfx/thebes/gfxQtPlatform.h
gfx/thebes/gfxWindowsPlatform.cpp
gfx/thebes/gfxWindowsPlatform.h
mobile/android/base/GeckoAppShell.java
widget/android/GeneratedJNIWrappers.cpp
widget/android/GeneratedJNIWrappers.h
widget/android/bindings/AndroidRect-classes.txt
widget/android/bindings/Makefile.in
widget/android/bindings/moz.build
widget/android/nsScreenManagerAndroid.cpp
widget/gtk/nsScreenManagerGtk.cpp
--- a/dom/ipc/ScreenManagerParent.cpp
+++ b/dom/ipc/ScreenManagerParent.cpp
@@ -164,20 +164,16 @@ ScreenManagerParent::RecvScreenForBrowse
   *aRetVal = details;
   *aSuccess = true;
   return true;
 }
 
 bool
 ScreenManagerParent::ExtractScreenDetails(nsIScreen* aScreen, ScreenDetails &aDetails)
 {
-  if (!aScreen) {
-    return false;
-  }
-
   uint32_t id;
   nsresult rv = aScreen->GetId(&id);
   NS_ENSURE_SUCCESS(rv, false);
   aDetails.id() = id;
 
   nsIntRect rect;
   rv = aScreen->GetRect(&rect.x, &rect.y, &rect.width, &rect.height);
   NS_ENSURE_SUCCESS(rv, false);
--- a/gfx/layers/client/ContentClient.cpp
+++ b/gfx/layers/client/ContentClient.cpp
@@ -64,17 +64,37 @@ ContentClient::CreateContentClient(Compo
   LayersBackend backend = aForwarder->GetCompositorBackendType();
   if (backend != LayersBackend::LAYERS_OPENGL &&
       backend != LayersBackend::LAYERS_D3D9 &&
       backend != LayersBackend::LAYERS_D3D11 &&
       backend != LayersBackend::LAYERS_BASIC) {
     return nullptr;
   }
 
-  if (gfxPlatform::GetPlatform()->CanUseDoubleBufferedContent(backend)) {
+  bool useDoubleBuffering = false;
+
+#ifdef XP_WIN
+  if (backend == LayersBackend::LAYERS_D3D11) {
+    useDoubleBuffering = !!gfxWindowsPlatform::GetPlatform()->GetD3D10Device();
+  } else
+#endif
+#ifdef MOZ_WIDGET_GTK
+  // We can't use double buffering when using image content with
+  // Xrender support on Linux, as ContentHostDoubleBuffered is not
+  // suited for direct uploads to the server.
+  if (!gfxPlatformGtk::GetPlatform()->UseImageOffscreenSurfaces() ||
+      !gfxPlatformGtk::GetPlatform()->UseXRender())
+#endif
+  {
+    useDoubleBuffering = (LayerManagerComposite::SupportsDirectTexturing() &&
+                         backend != LayersBackend::LAYERS_D3D9) ||
+                         backend == LayersBackend::LAYERS_BASIC;
+  }
+
+  if (useDoubleBuffering || PR_GetEnv("MOZ_FORCE_DOUBLE_BUFFERING")) {
     return MakeAndAddRef<ContentClientDoubleBuffered>(aForwarder);
   }
   return MakeAndAddRef<ContentClientSingleBuffered>(aForwarder);
 }
 
 void
 ContentClient::EndPaint(nsTArray<ReadbackProcessor::Update>* aReadbackUpdates)
 {
--- a/gfx/thebes/gfxAndroidPlatform.cpp
+++ b/gfx/thebes/gfxAndroidPlatform.cpp
@@ -95,17 +95,23 @@ gfxAndroidPlatform::gfxAndroidPlatform()
 
     // These two calls are equivalent to FT_Init_FreeType(), but allow us to
     // provide a custom memory allocator.
     FT_New_Library(&sFreetypeMemoryRecord, &gPlatformFTLibrary);
     FT_Add_Default_Modules(gPlatformFTLibrary);
 
     RegisterStrongMemoryReporter(new FreetypeReporter());
 
-    mOffscreenFormat = GetScreenDepth() == 16
+    nsCOMPtr<nsIScreenManager> screenMgr = do_GetService("@mozilla.org/gfx/screenmanager;1");
+    nsCOMPtr<nsIScreen> screen;
+    screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
+    mScreenDepth = 24;
+    screen->GetColorDepth(&mScreenDepth);
+
+    mOffscreenFormat = mScreenDepth == 16
                        ? gfxImageFormat::RGB16_565
                        : gfxImageFormat::RGB24;
 
     if (gfxPrefs::AndroidRGB16Force()) {
         mOffscreenFormat = gfxImageFormat::RGB16_565;
     }
 
 #ifdef MOZ_WIDGET_GONK
@@ -407,16 +413,22 @@ gfxAndroidPlatform::RequiresLinearZoom()
     return XRE_IsContentProcess() &&
            ContentChild::GetSingleton()->IsForBrowser();
 #endif
 
     NS_NOTREACHED("oops, what platform is this?");
     return gfxPlatform::RequiresLinearZoom();
 }
 
+int
+gfxAndroidPlatform::GetScreenDepth() const
+{
+    return mScreenDepth;
+}
+
 bool
 gfxAndroidPlatform::UseAcceleratedSkiaCanvas()
 {
     return HaveChoiceOfHWAndSWCanvas() && gfxPlatform::UseAcceleratedSkiaCanvas();
 }
 
 bool gfxAndroidPlatform::HaveChoiceOfHWAndSWCanvas()
 {
--- a/gfx/thebes/gfxAndroidPlatform.h
+++ b/gfx/thebes/gfxAndroidPlatform.h
@@ -75,16 +75,18 @@ public:
                     gfxTextPerfMetrics* aTextPerf,
                     gfxUserFontSet *aUserFontSet) override;
 
     virtual bool FontHintingEnabled() override;
     virtual bool RequiresLinearZoom() override;
 
     FT_Library GetFTLibrary();
 
+    virtual int GetScreenDepth() const;
+
     virtual bool CanRenderContentToDataSurface() const override {
       return true;
     }
 
     virtual bool HaveChoiceOfHWAndSWCanvas() override;
     virtual bool UseAcceleratedSkiaCanvas() override;
     virtual already_AddRefed<mozilla::gfx::VsyncSource> CreateHardwareVsyncSource() override;
 
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/layers/AsyncTransactionTracker.h" // for AsyncTransactionTracker
 #include "mozilla/layers/CompositorChild.h"
 #include "mozilla/layers/CompositorParent.h"
 #include "mozilla/layers/ImageBridgeChild.h"
 #include "mozilla/layers/SharedBufferManagerChild.h"
 #include "mozilla/layers/ISurfaceAllocator.h"     // for GfxMemoryImageReporter
-#include "mozilla/layers/LayerManagerComposite.h"
 
 #include "mozilla/Logging.h"
 #include "mozilla/Services.h"
 #include "prprf.h"
 
 #include "gfxPlatform.h"
 #include "gfxPrefs.h"
 #include "gfxTextRun.h"
@@ -48,17 +47,16 @@
 #include "gfxPlatformFontList.h"
 #include "gfxContext.h"
 #include "gfxImageSurface.h"
 #include "nsUnicodeProperties.h"
 #include "harfbuzz/hb.h"
 #include "gfxGraphiteShaper.h"
 #include "gfx2DGlue.h"
 #include "gfxGradientCache.h"
-#include "gfxUtils.h" // for NextPowerOfTwo
 
 #include "nsUnicodeRange.h"
 #include "nsServiceManagerUtils.h"
 #include "nsTArray.h"
 #include "nsILocaleService.h"
 #include "nsIObserverService.h"
 #include "nsIScreenManager.h"
 #include "MainThreadUtils.h"
@@ -383,17 +381,16 @@ static nsIAtom* PrefLangToLangGroups(uin
 }
 
 gfxPlatform::gfxPlatform()
   : mTileWidth(-1)
   , mTileHeight(-1)
   , mAzureCanvasBackendCollector(this, &gfxPlatform::GetAzureBackendInfo)
   , mApzSupportCollector(this, &gfxPlatform::GetApzSupportInfo)
   , mCompositorBackend(layers::LayersBackend::LAYERS_NONE)
-  , mScreenDepth(0)
 {
     mAllowDownloadableFonts = UNINITIALIZED_VALUE;
     mFallbackUsesCmaps = UNINITIALIZED_VALUE;
 
     mWordCacheCharLimit = UNINITIALIZED_VALUE;
     mWordCacheMaxEntries = UNINITIALIZED_VALUE;
     mGraphiteShapingEnabled = UNINITIALIZED_VALUE;
     mOpenTypeSVGEnabled = UNINITIALIZED_VALUE;
@@ -504,17 +501,16 @@ gfxPlatform::Init()
 
 #ifdef MOZ_GL_DEBUG
     GLContext::StaticInit();
 #endif
 
     InitLayersAccelerationPrefs();
     InitLayersIPC();
 
-    gPlatform->PopulateScreenInfo();
     gPlatform->ComputeTileSize();
 
     nsresult rv;
 
     bool usePlatformFontList = true;
 #if defined(MOZ_WIDGET_GTK)
     usePlatformFontList = gfxPlatformGtk::UseFcFontList();
 #elif defined(MOZ_WIDGET_QT)
@@ -1011,55 +1007,53 @@ gfxPlatform::ComputeTileSize()
   // and sent to the child processes over IPDL GetTileSize.
   if (!XRE_IsParentProcess()) {
     return;
   }
 
   int32_t w = gfxPrefs::LayersTileWidth();
   int32_t h = gfxPrefs::LayersTileHeight();
 
+  // TODO We may want to take the screen size into consideration here.
   if (gfxPrefs::LayersTilesAdjust()) {
-    gfx::IntSize screenSize = GetScreenSize();
-    if (screenSize.width > 0) {
-      w = h = std::max(std::min(NextPowerOfTwo(screenSize.width) / 2, 1024), 256);
-    }
-
 #ifdef MOZ_WIDGET_GONK
+    int32_t format = android::PIXEL_FORMAT_RGBA_8888;
     android::sp<android::GraphicBuffer> alloc =
-          new android::GraphicBuffer(w, h, android::PIXEL_FORMAT_RGBA_8888,
-                                     android::GraphicBuffer::USAGE_SW_READ_OFTEN |
-                                     android::GraphicBuffer::USAGE_SW_WRITE_OFTEN |
-                                     android::GraphicBuffer::USAGE_HW_TEXTURE);
+      new android::GraphicBuffer(gfxPrefs::LayersTileWidth(), gfxPrefs::LayersTileHeight(),
+                                 format,
+                                 android::GraphicBuffer::USAGE_SW_READ_OFTEN |
+                                 android::GraphicBuffer::USAGE_SW_WRITE_OFTEN |
+                                 android::GraphicBuffer::USAGE_HW_TEXTURE);
 
     if (alloc.get()) {
       w = alloc->getStride(); // We want the tiles to be gralloc stride aligned.
+      // No need to adjust the height here.
     }
 #endif
   }
 
-  SetTileSize(w, h);
-}
-
-void
-gfxPlatform::PopulateScreenInfo()
-{
-  nsCOMPtr<nsIScreenManager> manager = do_GetService("@mozilla.org/gfx/screenmanager;1");
-  MOZ_ASSERT(manager, "failed to get nsIScreenManager");
+#ifdef XP_MACOSX
+  // Use double sized tiles for HiDPI screens.
+  nsCOMPtr<nsIScreenManager> screenManager =
+    do_GetService("@mozilla.org/gfx/screenmanager;1");
+  if (screenManager) {
+    nsCOMPtr<nsIScreen> primaryScreen;
+    screenManager->GetPrimaryScreen(getter_AddRefs(primaryScreen));
+    double scaleFactor = 1.0;
+    if (primaryScreen) {
+      primaryScreen->GetContentsScaleFactor(&scaleFactor);
+    }
+    if (scaleFactor > 1.0) {
+      w *= 2;
+      h *= 2;
+    }
+  }
+#endif
 
-  nsCOMPtr<nsIScreen> screen;
-  manager->GetPrimaryScreen(getter_AddRefs(screen));
-  if (!screen) {
-    // This can happen in xpcshell, for instance
-    return;
-  }
-
-  screen->GetColorDepth(&mScreenDepth);
-
-  int left, top;
-  screen->GetRect(&left, &top, &mScreenSize.width, &mScreenSize.height);
+  SetTileSize(w, h);
 }
 
 bool
 gfxPlatform::SupportsAzureContentForDrawTarget(DrawTarget* aTarget)
 {
   if (!aTarget) {
     return false;
   }
@@ -2082,16 +2076,23 @@ gfxPlatform::GetLog(eGfxLog aWhichLog)
     case eGfxLog_textperf:
         return sTextPerfLog;
     }
 
     MOZ_ASSERT_UNREACHABLE("Unexpected log type");
     return nullptr;
 }
 
+int
+gfxPlatform::GetScreenDepth() const
+{
+    NS_WARNING("GetScreenDepth not implemented on this platform -- returning 0!");
+    return 0;
+}
+
 mozilla::gfx::SurfaceFormat
 gfxPlatform::Optimal2DFormatForContent(gfxContentType aContent)
 {
   switch (aContent) {
   case gfxContentType::COLOR:
     switch (GetOffscreenFormat()) {
     case gfxImageFormat::ARGB32:
       return mozilla::gfx::SurfaceFormat::B8G8R8A8;
@@ -2285,43 +2286,16 @@ gfxPlatform::BufferRotationEnabled()
 void
 gfxPlatform::DisableBufferRotation()
 {
   MutexAutoLock autoLock(*gGfxPlatformPrefsLock);
 
   sBufferRotationCheckPref = false;
 }
 
-bool
-gfxPlatform::CanUseDoubleBufferedContent(LayersBackend aBackend) const
-{
-  bool useDoubleBuffering = false;
-
-#ifdef XP_WIN
-  if (aBackend == LayersBackend::LAYERS_D3D11) {
-    useDoubleBuffering = !!gfxWindowsPlatform::GetPlatform()->GetD3D10Device();
-  } else
-#endif
-#ifdef MOZ_WIDGET_GTK
-  // We can't use double buffering when using image content with
-  // Xrender support on Linux, as ContentHostDoubleBuffered is not
-  // suited for direct uploads to the server.
-  if (!gfxPlatformGtk::GetPlatform()->UseImageOffscreenSurfaces() ||
-      !gfxPlatformGtk::GetPlatform()->UseXRender())
-#endif
-  {
-    useDoubleBuffering = (LayerManagerComposite::SupportsDirectTexturing() &&
-                         aBackend != LayersBackend::LAYERS_D3D9) ||
-                         aBackend == LayersBackend::LAYERS_BASIC;
-  }
-
-  return useDoubleBuffering || PR_GetEnv("MOZ_FORCE_DOUBLE_BUFFERING");
-}
-
-
 already_AddRefed<ScaledFont>
 gfxPlatform::GetScaledFontForFontWithCairoSkia(DrawTarget* aTarget, gfxFont* aFont)
 {
     NativeFont nativeFont;
     if (aTarget->GetBackendType() == BackendType::CAIRO || aTarget->GetBackendType() == BackendType::SKIA) {
         nativeFont.mType = NativeFontType::CAIRO_FONT_FACE;
         nativeFont.mFont = aFont->GetCairoScaledFont();
         return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize());
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -492,21 +492,16 @@ public:
      * Is it possible to use buffer rotation.  Note that these
      * check the preference, but also allow for the override to
      * disable it using DisableBufferRotation.
      */
     static bool BufferRotationEnabled();
     static void DisableBufferRotation();
 
     /**
-     * Check to see if we should use double buffered content client
-     */
-    bool CanUseDoubleBufferedContent(mozilla::layers::LayersBackend aBackend) const;
-
-    /**
      * Are we going to try color management?
      */
     static eCMSMode GetCMSMode();
 
     /**
      * Determines the rendering intent for color management.
      *
      * If the value in the pref gfx.color_management.rendering_intent is a
@@ -568,18 +563,17 @@ public:
     virtual gfxImageFormat GetOffscreenFormat()
     { return gfxImageFormat::RGB24; }
 
     /**
      * Returns a logger if one is available and logging is enabled
      */
     static PRLogModuleInfo* GetLog(eGfxLog aWhichLog);
 
-    int GetScreenDepth() const { return mScreenDepth; }
-    mozilla::gfx::IntSize GetScreenSize() const { return mScreenSize; }
+    virtual int GetScreenDepth() const;
 
     /**
      * Return the layer debugging options to use browser-wide.
      */
     mozilla::layers::DiagnosticTypes GetLayerDiagnosticTypes();
 
     static mozilla::gfx::IntRect FrameCounterBounds() {
       int bits = 16;
@@ -763,21 +757,16 @@ private:
 
     /**
      * Calling this function will compute and set the ideal tile size for the
      * platform. This will only have an effect in the parent process; child processes
      * should be updated via SetTileSize to match the value computed in the parent.
      */
     void ComputeTileSize();
 
-    /**
-     * This uses nsIScreenManager to determine the screen size and color depth
-     */
-    void PopulateScreenInfo();
-
     nsRefPtr<gfxASurface> mScreenReferenceSurface;
     nsTArray<uint32_t> mCJKPrefLangs;
     nsCOMPtr<nsIObserver> mSRGBOverrideObserver;
     nsCOMPtr<nsIObserver> mFontPrefsObserver;
     nsCOMPtr<nsIObserver> mMemoryPressureObserver;
 
     // The preferred draw target backend to use for canvas
     mozilla::gfx::BackendType mPreferredCanvasBackend;
@@ -795,14 +784,11 @@ private:
     mozilla::widget::GfxInfoCollector<gfxPlatform> mApzSupportCollector;
 
     mozilla::RefPtr<mozilla::gfx::DrawEventRecorder> mRecorder;
     mozilla::RefPtr<mozilla::gl::SkiaGLGlue> mSkiaGlue;
 
     // Backend that we are compositing with. NONE, if no compositor has been
     // created yet.
     mozilla::layers::LayersBackend mCompositorBackend;
-
-    int32_t mScreenDepth;
-    mozilla::gfx::IntSize mScreenSize;
 };
 
 #endif /* GFX_PLATFORM_H */
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -358,16 +358,34 @@ gfxPlatformGtk::GetOffscreenFormat()
     GdkScreen *screen = gdk_screen_get_default();
     if (screen && gdk_visual_get_depth(gdk_visual_get_system()) == 16) {
         return gfxImageFormat::RGB16_565;
     }
 
     return gfxImageFormat::RGB24;
 }
 
+static int sDepth = 0;
+
+int
+gfxPlatformGtk::GetScreenDepth() const
+{
+    if (!sDepth) {
+        GdkScreen *screen = gdk_screen_get_default();
+        if (screen) {
+            sDepth = gdk_visual_get_depth(gdk_visual_get_system());
+        } else {
+            sDepth = 24;
+        }
+
+    }
+
+    return sDepth;
+}
+
 void
 gfxPlatformGtk::GetPlatformCMSOutputProfile(void *&mem, size_t &size)
 {
     mem = nullptr;
     size = 0;
 
 #ifdef MOZ_X11
     GdkDisplay *display = gdk_display_get_default();
--- a/gfx/thebes/gfxPlatformGtk.h
+++ b/gfx/thebes/gfxPlatformGtk.h
@@ -117,16 +117,18 @@ public:
 #endif
 
     static bool UseFcFontList() { return sUseFcFontList; }
 
     bool UseImageOffscreenSurfaces();
 
     virtual gfxImageFormat GetOffscreenFormat() override;
 
+    virtual int GetScreenDepth() const override;
+
     bool SupportsApzWheelInput() const override {
       return true;
     }
 
 protected:
     static gfxFontconfigUtils *sFontconfigUtils;
 
 private:
--- a/gfx/thebes/gfxQtPlatform.cpp
+++ b/gfx/thebes/gfxQtPlatform.cpp
@@ -48,18 +48,18 @@ gfxFontconfigUtils *gfxQtPlatform::sFont
 
 static gfxImageFormat sOffscreenFormat = gfxImageFormat::RGB24;
 
 gfxQtPlatform::gfxQtPlatform()
 {
     if (!sFontconfigUtils)
         sFontconfigUtils = gfxFontconfigUtils::GetFontconfigUtils();
 
-    int32_t depth = GetScreenDepth();
-    if (depth == 16) {
+    mScreenDepth = qApp->primaryScreen()->depth();
+    if (mScreenDepth == 16) {
         sOffscreenFormat = gfxImageFormat::RGB16_565;
     }
     uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);
     uint32_t contentMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);
     InitBackendPrefs(canvasMask, BackendType::CAIRO,
                      contentMask, BackendType::CAIRO);
 }
 
@@ -190,13 +190,19 @@ gfxQtPlatform::GetDPI()
 }
 
 gfxImageFormat
 gfxQtPlatform::GetOffscreenFormat()
 {
     return sOffscreenFormat;
 }
 
+int
+gfxQtPlatform::GetScreenDepth() const
+{
+    return mScreenDepth;
+}
+
 already_AddRefed<ScaledFont>
 gfxQtPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont* aFont)
 {
     return GetScaledFontForFontWithCairoSkia(aTarget, aFont);
 }
--- a/gfx/thebes/gfxQtPlatform.h
+++ b/gfx/thebes/gfxQtPlatform.h
@@ -77,16 +77,18 @@ public:
     static int32_t GetDPI();
 
     virtual gfxImageFormat GetOffscreenFormat() override;
 #ifdef MOZ_X11
     static Display* GetXDisplay(QWindow* aWindow = 0);
     static Screen* GetXScreen(QWindow* aWindow = 0);
 #endif
 
+    virtual int GetScreenDepth() const override;
+
     bool AccelerateLayersByDefault() override {
       return true;
     }
 
 protected:
     static gfxFontconfigUtils *sFontconfigUtils;
 
 private:
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -1590,16 +1590,36 @@ gfxWindowsPlatform::IsOptimus()
             knowIsOptimus = 1;
         } else {
             knowIsOptimus = 0;
         }
     }
     return knowIsOptimus;
 }
 
+int
+gfxWindowsPlatform::GetScreenDepth() const
+{
+    // if the system doesn't have all displays with the same
+    // pixel format, just return 24 and move on with life.
+    if (!GetSystemMetrics(SM_SAMEDISPLAYFORMAT))
+        return 24;
+
+    HDC hdc = GetDC(nullptr);
+    if (!hdc)
+        return 24;
+
+    int depth = GetDeviceCaps(hdc, BITSPIXEL) *
+                GetDeviceCaps(hdc, PLANES);
+
+    ReleaseDC(nullptr, hdc);
+
+    return depth;
+}
+
 IDXGIAdapter1*
 gfxWindowsPlatform::GetDXGIAdapter()
 {
   if (mAdapter) {
     return mAdapter;
   }
 
   nsModuleHandle dxgiModule(LoadLibrarySystem32(L"dxgi.dll"));
--- a/gfx/thebes/gfxWindowsPlatform.h
+++ b/gfx/thebes/gfxWindowsPlatform.h
@@ -134,16 +134,18 @@ public:
 
         /* Use Direct2D rendering */
         RENDER_DIRECT2D,
 
         /* max */
         RENDER_MODE_MAX
     };
 
+    int GetScreenDepth() const;
+
     RenderMode GetRenderMode() { return mRenderMode; }
     void SetRenderMode(RenderMode rmode) { mRenderMode = rmode; }
 
     /**
      * Updates render mode with relation to the current preferences and
      * available devices.
      */
     void UpdateRenderMode();
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -76,17 +76,16 @@ import android.graphics.Color;
 import android.graphics.ImageFormat;
 import android.graphics.Paint;
 import android.graphics.PixelFormat;
 import android.graphics.Rect;
 import android.graphics.RectF;
 import android.graphics.SurfaceTexture;
 import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
-import android.hardware.display.DisplayManager;
 import android.hardware.Sensor;
 import android.hardware.SensorEventListener;
 import android.hardware.SensorManager;
 import android.location.Criteria;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.net.ConnectivityManager;
@@ -103,17 +102,16 @@ import android.os.Vibrator;
 import android.provider.Browser;
 import android.provider.Settings;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
 import android.util.Base64;
 import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.ContextThemeWrapper;
-import android.view.Display;
 import android.view.HapticFeedbackConstants;
 import android.view.Surface;
 import android.view.SurfaceView;
 import android.view.TextureView;
 import android.view.View;
 import android.view.inputmethod.InputMethodManager;
 import android.webkit.MimeTypeMap;
 import android.webkit.URLUtil;
@@ -2668,15 +2666,9 @@ public class GeckoAppShell
             // 2 fingers
             return 2;
         } else if (pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN)) {
             // 1 finger
             return 1;
         }
         return 0;
     }
-
-    @WrapForJNI
-    static Rect getScreenSize() {
-        Display disp = getGeckoInterface().getActivity().getWindowManager().getDefaultDisplay();
-        return new Rect(0, 0, disp.getWidth(), disp.getHeight());
-    }
 }
--- a/widget/android/GeneratedJNIWrappers.cpp
+++ b/widget/android/GeneratedJNIWrappers.cpp
@@ -388,24 +388,16 @@ auto GeckoAppShell::GetScreenDepthWrappe
 constexpr char GeckoAppShell::GetScreenOrientationWrapper_t::name[];
 constexpr char GeckoAppShell::GetScreenOrientationWrapper_t::signature[];
 
 auto GeckoAppShell::GetScreenOrientationWrapper() -> int16_t
 {
     return mozilla::jni::Method<GetScreenOrientationWrapper_t>::Call(nullptr, nullptr);
 }
 
-constexpr char GeckoAppShell::GetScreenSize_t::name[];
-constexpr char GeckoAppShell::GetScreenSize_t::signature[];
-
-auto GeckoAppShell::GetScreenSize() -> mozilla::jni::Object::LocalRef
-{
-    return mozilla::jni::Method<GetScreenSize_t>::Call(nullptr, nullptr);
-}
-
 constexpr char GeckoAppShell::GetShowPasswordSetting_t::name[];
 constexpr char GeckoAppShell::GetShowPasswordSetting_t::signature[];
 
 auto GeckoAppShell::GetShowPasswordSetting() -> bool
 {
     return mozilla::jni::Method<GetShowPasswordSetting_t>::Call(nullptr, nullptr);
 }
 
--- a/widget/android/GeneratedJNIWrappers.h
+++ b/widget/android/GeneratedJNIWrappers.h
@@ -940,33 +940,16 @@ public:
         static const bool isMultithreaded = false;
         static const mozilla::jni::ExceptionMode exceptionMode =
                 mozilla::jni::ExceptionMode::ABORT;
     };
 
     static auto GetScreenOrientationWrapper() -> int16_t;
 
 public:
-    struct GetScreenSize_t {
-        typedef GeckoAppShell Owner;
-        typedef mozilla::jni::Object::LocalRef ReturnType;
-        typedef mozilla::jni::Object::Param SetterType;
-        typedef mozilla::jni::Args<> Args;
-        static constexpr char name[] = "getScreenSize";
-        static constexpr char signature[] =
-                "()Landroid/graphics/Rect;";
-        static const bool isStatic = true;
-        static const bool isMultithreaded = false;
-        static const mozilla::jni::ExceptionMode exceptionMode =
-                mozilla::jni::ExceptionMode::ABORT;
-    };
-
-    static auto GetScreenSize() -> mozilla::jni::Object::LocalRef;
-
-public:
     struct GetShowPasswordSetting_t {
         typedef GeckoAppShell Owner;
         typedef bool ReturnType;
         typedef bool SetterType;
         typedef mozilla::jni::Args<> Args;
         static constexpr char name[] = "getShowPasswordSetting";
         static constexpr char signature[] =
                 "()Z";
deleted file mode 100644
--- a/widget/android/bindings/AndroidRect-classes.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-android.graphics.Rect
-android.graphics.RectF
--- a/widget/android/bindings/Makefile.in
+++ b/widget/android/bindings/Makefile.in
@@ -19,16 +19,15 @@ sdk_processor := \
 # MediaCodec-classes.txt.  This formulation invokes the SDK processor
 # at most once.
 
 %.cpp %.h: $(ANDROID_SDK)/android.jar %-classes.txt
 	$(sdk_processor) $(ANDROID_SDK)/android.jar $(srcdir)/$*-classes.txt $(CURDIR) $* 16
 
 # We'd like these to be defined in a future GENERATED_EXPORTS list.
 bindings_exports_FILES := \
-	AndroidRect.h \
   Bundle.h \
   MediaCodec.h \
   SurfaceTexture.h \
   $(NULL)
 bindings_exports_DEST = $(DIST)/include
 bindings_exports_TARGET := export
 INSTALL_TARGETS += bindings_exports
--- a/widget/android/bindings/moz.build
+++ b/widget/android/bindings/moz.build
@@ -2,20 +2,19 @@
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # List of stems to generate .cpp and .h files for.  To add a stem, add it to
 # this list and ensure that $(stem)-classes.txt exists in this directory.
 generated = [
-    'AndroidRect',
     'Bundle',
     'MediaCodec',
-    'SurfaceTexture'
+    'SurfaceTexture',
 ]
 
 SOURCES += ['!%s.cpp' % stem for stem in generated]
 
 # We'd like to add these to a future GENERATED_EXPORTS list, but for now we mark
 # them as generated here and manually install them in Makefile.in.
 GENERATED_FILES += [stem + '.h' for stem in generated]
 
--- a/widget/android/nsScreenManagerAndroid.cpp
+++ b/widget/android/nsScreenManagerAndroid.cpp
@@ -3,19 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #define MOZ_FATAL_ASSERTIONS_FOR_THREAD_SAFETY
 
 #include "nsScreenManagerAndroid.h"
 #include "nsWindow.h"
 #include "AndroidBridge.h"
-#include "GeneratedJNIWrappers.h"
-#include "AndroidRect.h"
-#include <mozilla/jni/Refs.h>
 
 using namespace mozilla;
 
 nsScreenAndroid::nsScreenAndroid(void *nativeScreen)
 {
 }
 
 nsScreenAndroid::~nsScreenAndroid()
@@ -27,21 +24,23 @@ nsScreenAndroid::GetId(uint32_t *outId)
 {
     *outId = 1;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsScreenAndroid::GetRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight)
 {
-    widget::sdk::Rect::LocalRef rect = widget::GeckoAppShell::GetScreenSize();
-    rect->Left(outLeft);
-    rect->Top(outTop);
-    rect->Width(outWidth);
-    rect->Height(outHeight);
+    gfxIntSize sz = nsWindow::GetAndroidScreenBounds();
+
+    *outLeft = 0;
+    *outTop = 0;
+
+    *outWidth = sz.width;
+    *outHeight = sz.height;
 
     return NS_OK;
 }
 
 
 NS_IMETHODIMP
 nsScreenAndroid::GetAvailRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight)
 {
--- a/widget/gtk/nsScreenManagerGtk.cpp
+++ b/widget/gtk/nsScreenManagerGtk.cpp
@@ -94,21 +94,16 @@ NS_IMPL_ISUPPORTS(nsScreenManagerGtk, ns
 // this function will make sure that everything has been initialized.
 nsresult
 nsScreenManagerGtk :: EnsureInit()
 {
   if (mCachedScreenArray.Count() > 0)
     return NS_OK;
 
   mRootWindow = gdk_get_default_root_window();
-  if (!mRootWindow) {
-    // Sometimes we don't initial X (e.g., xpcshell)
-    return NS_OK;
-  }
-
   g_object_ref(mRootWindow);
 
   // GDK_PROPERTY_CHANGE_MASK ==> PropertyChangeMask, for PropertyNotify
   gdk_window_set_events(mRootWindow,
                         GdkEventMask(gdk_window_get_events(mRootWindow) |
                                      GDK_PROPERTY_CHANGE_MASK));
 
   g_signal_connect(gdk_screen_get_default(), "monitors-changed",