Bug 1191040 - Ensure that we only compute the tile size once. r=BenWa
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 07 Aug 2015 15:37:56 -0400
changeset 288545 daef3729bce246fa8194c094ac34f3bb4cce4faf
parent 288544 2fa6cc610bd43cca35e867e42b7e188f2dbb6ab6
child 288546 b6362a1d61894f7888620672568ceda5d0ccb199
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBenWa
bugs1191040
milestone42.0a1
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
Bug 1191040 - Ensure that we only compute the tile size once. r=BenWa
gfx/layers/ipc/CompositorParent.cpp
gfx/tests/gtest/TestTiledLayerBuffer.cpp
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -677,18 +677,16 @@ CompositorParent::CompositorParent(nsIWi
 
   if (UseVsyncComposition()) {
     gfxDebugOnce() << "Enabling vsync compositor";
     mCompositorScheduler = new CompositorVsyncScheduler(this, aWidget);
   } else {
     mCompositorScheduler = new CompositorSoftwareTimerScheduler(this);
   }
 
-  gfxPlatform::GetPlatform()->ComputeTileSize();
-
   LayerScope::SetPixelScale(mWidget->GetDefaultScale().scale);
 }
 
 bool
 CompositorParent::IsInCompositorThread()
 {
   return CompositorThread() && CompositorThread()->thread_id() == PlatformThread::CurrentId();
 }
@@ -1730,17 +1728,16 @@ class CrossProcessCompositorParent final
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(CrossProcessCompositorParent)
 public:
   explicit CrossProcessCompositorParent(Transport* aTransport)
     : mTransport(aTransport)
     , mCompositorThreadHolder(sCompositorThreadHolder)
     , mNotifyAfterRemotePaint(false)
   {
     MOZ_ASSERT(NS_IsMainThread());
-    gfxPlatform::GetPlatform()->ComputeTileSize();
   }
 
   // IToplevelProtocol::CloneToplevel()
   virtual IToplevelProtocol*
   CloneToplevel(const InfallibleTArray<mozilla::ipc::ProtocolFdMapping>& aFds,
                 base::ProcessHandle aPeerProcess,
                 mozilla::ipc::ProtocolCloneContext* aCtx) override;
 
--- a/gfx/tests/gtest/TestTiledLayerBuffer.cpp
+++ b/gfx/tests/gtest/TestTiledLayerBuffer.cpp
@@ -6,18 +6,16 @@
 #include "TiledLayerBuffer.h"
 
 #include "gtest/gtest.h"
 
 namespace mozilla {
 namespace layers {
 
 TEST(TiledLayerBuffer, TileStart) {
-  gfxPlatform::GetPlatform()->ComputeTileSize();
-
   ASSERT_EQ(RoundDownToTileEdge(10, 256), 0);
   ASSERT_EQ(RoundDownToTileEdge(-10, 256), -256);
 }
 
 TEST(TiledLayerBuffer, TilesPlacement) {
   for (int firstY = -10; firstY < 10; ++firstY) {
     for (int firstX = -10; firstX < 10; ++firstX) {
       for (int height = 1; height < 10; ++height) {
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -499,16 +499,18 @@ gfxPlatform::Init()
 
 #ifdef MOZ_GL_DEBUG
     GLContext::StaticInit();
 #endif
 
     InitLayersAccelerationPrefs();
     InitLayersIPC();
 
+    gPlatform->ComputeTileSize();
+
     nsresult rv;
 
     bool usePlatformFontList = true;
 #if defined(MOZ_WIDGET_GTK)
     usePlatformFontList = gfxPlatformGtk::UseFcFontList();
 #elif defined(MOZ_WIDGET_QT)
     usePlatformFontList = false;
 #endif
@@ -997,17 +999,17 @@ gfxPlatform::SetTileSize(int aWidth, int
 }
 
 void
 gfxPlatform::ComputeTileSize()
 {
   // The tile size should be picked in the parent processes
   // and sent to the child processes over IPDL GetTileSize.
   if (!XRE_IsParentProcess()) {
-    NS_RUNTIMEABORT("wrong process.");
+    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()) {
 #ifdef MOZ_WIDGET_GONK
@@ -1021,31 +1023,33 @@ gfxPlatform::ComputeTileSize()
 
     if (alloc.get()) {
       w = alloc->getStride(); // We want the tiles to be gralloc stride aligned.
       // No need to adjust the height here.
     }
 #endif
   }
 
+#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
 
   SetTileSize(w, h);
 }
 
 bool
 gfxPlatform::SupportsAzureContentForDrawTarget(DrawTarget* aTarget)
 {
   if (!aTarget) {
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -302,22 +302,16 @@ public:
      */
     virtual nsresult GetFontList(nsIAtom *aLangGroup,
                                  const nsACString& aGenericFamily,
                                  nsTArray<nsString>& aListOfFonts);
 
     int GetTileWidth();
     int GetTileHeight();
     void SetTileSize(int aWidth, int aHeight);
-    /**
-     * Calling this function will compute and set the ideal tile size for the
-     * platform. This should only be called in the parent process; child processes
-     * should be updated via SetTileSize to match the value computed in the parent.
-     */
-    void ComputeTileSize();
 
     /**
      * Rebuilds the any cached system font lists
      */
     virtual nsresult UpdateFontList();
 
     /**
      * Create the platform font-list object (gfxPlatformFontList concrete subclass).
@@ -755,16 +749,23 @@ private:
     static void CreateCMSOutputProfile();
 
     static void GetCMSOutputProfileData(void *&mem, size_t &size);
 
     friend void RecordingPrefChanged(const char *aPrefName, void *aClosure);
 
     virtual void GetPlatformCMSOutputProfile(void *&mem, size_t &size);
 
+    /**
+     * 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();
+
     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;