Backed out changeset bf184a7a1d63 (bug 990608) for Android crashes.
authorRyan VanderMeulen <ryanvm@gmail.com>
Fri, 04 Apr 2014 15:20:49 -0400
changeset 184998 cbb81640ea1615f6aaa30076481038b8c859526d
parent 184996 95dac7341bc02d22c24026c2ab203f9f309e7e43
child 185001 e3c78a0e079586e875b1c121cb0da530fd8f9c83
push idunknown
push userunknown
push dateunknown
bugs990608
milestone31.0a1
backs outbf184a7a1d6306f23d49b03eb1a99f0f3b66e02d
Backed out changeset bf184a7a1d63 (bug 990608) for Android crashes. CLOSED TREE
dom/base/nsDOMWindowUtils.cpp
dom/interfaces/base/nsIDOMWindowUtils.idl
gfx/gl/GfxTexturesReporter.cpp
gfx/gl/GfxTexturesReporter.h
gfx/layers/TiledLayerBuffer.h
gfx/layers/client/ClientLayerManager.cpp
gfx/layers/client/SimpleTiledContentClient.cpp
gfx/layers/client/TiledContentClient.cpp
gfx/layers/composite/TiledContentHost.cpp
gfx/layers/opengl/TextureHostOGL.cpp
gfx/tests/gtest/TestTiledLayerBuffer.cpp
gfx/thebes/gfxPrefs.h
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
widget/xpwidgets/APZCCallbackHelper.cpp
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -399,18 +399,17 @@ nsDOMWindowUtils::SetDisplayPortForEleme
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::SetDisplayPortMarginsForElement(float aLeftMargin,
                                                   float aTopMargin,
                                                   float aRightMargin,
                                                   float aBottomMargin,
-                                                  uint32_t aAlignmentX,
-                                                  uint32_t aAlignmentY,
+                                                  uint32_t aAlignment,
                                                   nsIDOMElement* aElement,
                                                   uint32_t aPriority)
 {
   if (!nsContentUtils::IsCallerChrome()) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   nsIPresShell* presShell = GetPresShell();
@@ -441,17 +440,17 @@ nsDOMWindowUtils::SetDisplayPortMarginsF
   // Note order change of arguments between our function signature and
   // LayerMargin constructor.
   LayerMargin displayportMargins(aTopMargin,
                                  aRightMargin,
                                  aBottomMargin,
                                  aLeftMargin);
 
   content->SetProperty(nsGkAtoms::DisplayPortMargins,
-                       new DisplayPortMarginsPropertyData(displayportMargins, aAlignmentX, aAlignmentY, aPriority),
+                       new DisplayPortMarginsPropertyData(displayportMargins, aAlignment, aPriority),
                        nsINode::DeleteProperty<DisplayPortMarginsPropertyData>);
 
   nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame();
   if (rootScrollFrame && content == rootScrollFrame->GetContent()) {
     // We are setting a root displayport for a document.
     // The pres shell needs a special flag set.
     presShell->SetIgnoreViewportScrolling(true);
   }
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -170,18 +170,17 @@ interface nsIDOMWindowUtils : nsISupport
    * Note that both the margin values and alignment are treated as values in
    * LayerPixels. Refer to layout/base/Units.h for a description of this unit.
    * The base rect values are in app units.
    */
   void setDisplayPortMarginsForElement(in float aLeftMargin,
                                        in float aTopMargin,
                                        in float aRightMargin,
                                        in float aBottomMargin,
-                                       in uint32_t aAlignmentX,
-                                       in uint32_t aAlignmentY,
+                                       in uint32_t aAlignment,
                                        in nsIDOMElement aElement,
                                        in uint32_t aPriority);
 
   void setDisplayPortBaseForElement(in int32_t aX,
                                     in int32_t aY,
                                     in int32_t aWidth,
                                     in int32_t aHeight,
                                     in nsIDOMElement aElement);
--- a/gfx/gl/GfxTexturesReporter.cpp
+++ b/gfx/gl/GfxTexturesReporter.cpp
@@ -70,19 +70,18 @@ GetBitsPerTexel(GLenum format, GLenum ty
     }
 
     MOZ_ASSERT(false);
     return 0;
 }
 
 /* static */ void
 GfxTexturesReporter::UpdateAmount(MemoryUse action, GLenum format,
-                                  GLenum type, int32_t tileWidth,
-                                  int32_t tileHeight)
+                                  GLenum type, uint16_t tileSize)
 {
     int64_t bitsPerTexel = GetBitsPerTexel(format, type);
-    int64_t bytes = int64_t(tileWidth) * int64_t(tileHeight) * bitsPerTexel/8;
+    int64_t bytes = int64_t(tileSize) * int64_t(tileSize) * bitsPerTexel/8;
     if (action == MemoryFreed) {
         sAmount -= bytes;
     } else {
         sAmount += bytes;
     }
 }
--- a/gfx/gl/GfxTexturesReporter.h
+++ b/gfx/gl/GfxTexturesReporter.h
@@ -34,17 +34,17 @@ public:
         MemoryAllocated,
         // when memory being freed is reported to a memory reporter
         MemoryFreed
     };
 
     // When memory is used/freed for tile textures, call this method to update
     // the value reported by this memory reporter.
     static void UpdateAmount(MemoryUse action, GLenum format, GLenum type,
-                             int32_t tileWidth, int32_t tileHeight);
+                             uint16_t tileSize);
 
     NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
                               nsISupports* aData)
     {
         return MOZ_COLLECT_REPORT(
             "gfx-textures", KIND_OTHER, UNITS_BYTES, sAmount,
             "Memory used for storing GL textures.");
     }
--- a/gfx/layers/TiledLayerBuffer.h
+++ b/gfx/layers/TiledLayerBuffer.h
@@ -1,22 +1,23 @@
 /* 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/. */
 
 #ifndef GFX_TILEDLAYERBUFFER_H
 #define GFX_TILEDLAYERBUFFER_H
 
+#define TILEDLAYERBUFFER_TILE_SIZE 256
+
 // Debug defines
 //#define GFX_TILEDLAYER_DEBUG_OVERLAY
 //#define GFX_TILEDLAYER_PREF_WARNINGS
 
 #include <stdint.h>                     // for uint16_t, uint32_t
 #include <sys/types.h>                  // for int32_t
-#include "gfxPrefs.h"                   // for gfxPrefs::LayersTileWidth/Height
 #include "nsDebug.h"                    // for NS_ABORT_IF_FALSE
 #include "nsPoint.h"                    // for nsIntPoint
 #include "nsRect.h"                     // for nsIntRect
 #include "nsRegion.h"                   // for nsIntRegion
 #include "nsTArray.h"                   // for nsTArray
 
 #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
 #include <ui/Fence.h>
@@ -26,18 +27,18 @@ namespace mozilla {
 namespace layers {
 
 // An abstract implementation of a tile buffer. This code covers the logic of
 // moving and reusing tiles and leaves the validation up to the implementor. To
 // avoid the overhead of virtual dispatch, we employ the curiously recurring
 // template pattern.
 //
 // Tiles are aligned to a grid with one of the grid points at (0,0) and other
-// grid points spaced evenly in the x- and y-directions by GetTileSize()
-// multiplied by mResolution. GetScaledTileSize() provides convenience for
+// grid points spaced evenly in the x- and y-directions by GetTileLength()
+// multiplied by mResolution. GetScaledTileLength() provides convenience for
 // accessing these values.
 //
 // This tile buffer stores a valid region, which defines the areas that have
 // up-to-date content. The contents of tiles within this region will be reused
 // from paint to paint. It also stores the region that was modified in the last
 // paint operation; this is useful when one tiled layer buffer shadows another
 // (as in an off-main-thread-compositing scenario), so that the shadow tiled
 // layer buffer can correctly reflect the updates of the master layer buffer.
@@ -79,64 +80,66 @@ namespace layers {
 template<typename Derived, typename Tile>
 class TiledLayerBuffer
 {
 public:
   TiledLayerBuffer()
     : mRetainedWidth(0)
     , mRetainedHeight(0)
     , mResolution(1)
-    , mTileSize(gfxPrefs::LayersTileWidth(), gfxPrefs::LayersTileHeight())
   {}
 
   ~TiledLayerBuffer() {}
 
-  // Given a tile origin aligned to a multiple of GetScaledTileSize,
+  // Given a tile origin aligned to a multiple of GetScaledTileLength,
   // return the tile that describes that region.
   // NOTE: To get the valid area of that tile you must intersect
   //       (aTileOrigin.x, aTileOrigin.y,
-  //        GetScaledTileSize().width, GetScaledTileSize().height)
+  //        GetScaledTileLength(), GetScaledTileLength())
   //       and GetValidRegion() to get the area of the tile that is valid.
   Tile GetTile(const nsIntPoint& aTileOrigin) const;
 
   // Given a tile x, y relative to the top left of the layer, this function
   // will return the tile for
-  // (x*GetScaledTileSize().width, y*GetScaledTileSize().height,
-  //  GetScaledTileSize().width, GetScaledTileSize().height)
+  // (x*GetScaledTileLength(), y*GetScaledTileLength(),
+  //  GetScaledTileLength(), GetScaledTileLength())
   Tile GetTile(int x, int y) const;
 
   // This operates the same as GetTile(aTileOrigin), but will also replace the
   // specified tile with the placeholder tile. This does not call ReleaseTile
   // on the removed tile.
   bool RemoveTile(const nsIntPoint& aTileOrigin, Tile& aRemovedTile);
 
   // This operates the same as GetTile(x, y), but will also replace the
   // specified tile with the placeholder tile. This does not call ReleaseTile
   // on the removed tile.
   bool RemoveTile(int x, int y, Tile& aRemovedTile);
 
-  const gfx::IntSize& GetTileSize() const { return mTileSize; }
+  uint16_t GetTileLength() const { return TILEDLAYERBUFFER_TILE_SIZE; }
 
-  gfx::IntSize GetScaledTileSize() const { return mTileSize / mResolution; }
+#ifdef MOZ_WIDGET_ANDROID
+  MOZ_NEVER_INLINE // bug 881018 causes wrong results when GetScaledTileLength is inlined
+#endif
+  uint32_t GetScaledTileLength() const { return TILEDLAYERBUFFER_TILE_SIZE / mResolution; }
 
   unsigned int GetTileCount() const { return mRetainedTiles.Length(); }
 
   const nsIntRegion& GetValidRegion() const { return mValidRegion; }
   const nsIntRegion& GetPaintedRegion() const { return mPaintedRegion; }
   void ClearPaintedRegion() { mPaintedRegion.SetEmpty(); }
 
   // Given a position i, this function returns the position inside the current tile.
-  int GetTileStart(int i, int aTileLength) const {
-    return (i >= 0) ? (i % aTileLength)
-                    : ((aTileLength - (-i % aTileLength)) %
-                       aTileLength);
+  int GetTileStart(int i) const {
+    return (i >= 0) ? (i % GetScaledTileLength())
+                    : ((GetScaledTileLength() - (-i % GetScaledTileLength())) %
+                       GetScaledTileLength());
   }
 
   // Rounds the given coordinate down to the nearest tile boundary.
-  int RoundDownToTileEdge(int aX, int aTileLength) const { return aX - GetTileStart(aX, aTileLength); }
+  int RoundDownToTileEdge(int aX) const { return aX - GetTileStart(aX); }
 
   // Get and set draw scaling. mResolution affects the resolution at which the
   // contents of the buffer are drawn. mResolution has no effect on the
   // coordinate space of the valid region, but does affect the size of an
   // individual tile's rect in relation to the valid region.
   // Setting the resolution will invalidate the buffer.
   float GetResolution() const { return mResolution; }
   void SetResolution(float aResolution) {
@@ -170,17 +173,16 @@ protected:
    * Only the region intersecting with mValidRegion should be read from a tile,
    * another other region is assumed to be uninitialized. The contents of the
    * tiles is scaled by mResolution.
    */
   nsTArray<Tile>  mRetainedTiles;
   int             mRetainedWidth;  // in tiles
   int             mRetainedHeight; // in tiles
   float           mResolution;
-  gfx::IntSize    mTileSize;
 
 private:
   const Derived& AsDerived() const { return *static_cast<const Derived*>(this); }
   Derived& AsDerived() { return *static_cast<Derived*>(this); }
 
   bool IsPlaceholder(Tile aTile) const { return aTile == AsDerived().GetPlaceholderTile(); }
 };
 
@@ -237,39 +239,37 @@ static inline int floor_div(int a, int b
 }
 
 template<typename Derived, typename Tile> Tile
 TiledLayerBuffer<Derived, Tile>::GetTile(const nsIntPoint& aTileOrigin) const
 {
   // TODO Cache firstTileOriginX/firstTileOriginY
   // Find the tile x/y of the first tile and the target tile relative to the (0, 0)
   // origin, the difference is the tile x/y relative to the start of the tile buffer.
-  gfx::IntSize scaledTileSize = GetScaledTileSize();
-  int firstTileX = floor_div(mValidRegion.GetBounds().x, scaledTileSize.width);
-  int firstTileY = floor_div(mValidRegion.GetBounds().y, scaledTileSize.height);
-  return GetTile(floor_div(aTileOrigin.x, scaledTileSize.width) - firstTileX,
-                 floor_div(aTileOrigin.y, scaledTileSize.height) - firstTileY);
+  int firstTileX = floor_div(mValidRegion.GetBounds().x, GetScaledTileLength());
+  int firstTileY = floor_div(mValidRegion.GetBounds().y, GetScaledTileLength());
+  return GetTile(floor_div(aTileOrigin.x, GetScaledTileLength()) - firstTileX,
+                 floor_div(aTileOrigin.y, GetScaledTileLength()) - firstTileY);
 }
 
 template<typename Derived, typename Tile> Tile
 TiledLayerBuffer<Derived, Tile>::GetTile(int x, int y) const
 {
   int index = x * mRetainedHeight + y;
   return mRetainedTiles.SafeElementAt(index, AsDerived().GetPlaceholderTile());
 }
 
 template<typename Derived, typename Tile> bool
 TiledLayerBuffer<Derived, Tile>::RemoveTile(const nsIntPoint& aTileOrigin,
                                             Tile& aRemovedTile)
 {
-  gfx::IntSize scaledTileSize = GetScaledTileSize();
-  int firstTileX = floor_div(mValidRegion.GetBounds().x, scaledTileSize.width);
-  int firstTileY = floor_div(mValidRegion.GetBounds().y, scaledTileSize.height);
-  return RemoveTile(floor_div(aTileOrigin.x, scaledTileSize.width) - firstTileX,
-                    floor_div(aTileOrigin.y, scaledTileSize.height) - firstTileY,
+  int firstTileX = floor_div(mValidRegion.GetBounds().x, GetScaledTileLength());
+  int firstTileY = floor_div(mValidRegion.GetBounds().y, GetScaledTileLength());
+  return RemoveTile(floor_div(aTileOrigin.x, GetScaledTileLength()) - firstTileX,
+                    floor_div(aTileOrigin.y, GetScaledTileLength()) - firstTileY,
                     aRemovedTile);
 }
 
 template<typename Derived, typename Tile> bool
 TiledLayerBuffer<Derived, Tile>::RemoveTile(int x, int y, Tile& aRemovedTile)
 {
   int index = x * mRetainedHeight + y;
   const Tile& tileToRemove = mRetainedTiles.SafeElementAt(index, AsDerived().GetPlaceholderTile());
@@ -280,61 +280,59 @@ TiledLayerBuffer<Derived, Tile>::RemoveT
   }
   return false;
 }
 
 template<typename Derived, typename Tile> void
 TiledLayerBuffer<Derived, Tile>::Update(const nsIntRegion& aNewValidRegion,
                                         const nsIntRegion& aPaintRegion)
 {
-  gfx::IntSize scaledTileSize = GetScaledTileSize();
-
   nsTArray<Tile>  newRetainedTiles;
   nsTArray<Tile>& oldRetainedTiles = mRetainedTiles;
   const nsIntRect oldBound = mValidRegion.GetBounds();
   const nsIntRect newBound = aNewValidRegion.GetBounds();
-  const nsIntPoint oldBufferOrigin(RoundDownToTileEdge(oldBound.x, scaledTileSize.width),
-                                   RoundDownToTileEdge(oldBound.y, scaledTileSize.height));
-  const nsIntPoint newBufferOrigin(RoundDownToTileEdge(newBound.x, scaledTileSize.width),
-                                   RoundDownToTileEdge(newBound.y, scaledTileSize.height));
+  const nsIntPoint oldBufferOrigin(RoundDownToTileEdge(oldBound.x),
+                                   RoundDownToTileEdge(oldBound.y));
+  const nsIntPoint newBufferOrigin(RoundDownToTileEdge(newBound.x),
+                                   RoundDownToTileEdge(newBound.y));
   const nsIntRegion& oldValidRegion = mValidRegion;
   const nsIntRegion& newValidRegion = aNewValidRegion;
   const int oldRetainedHeight = mRetainedHeight;
 
   // Pass 1: Recycle valid content from the old buffer
   // Recycle tiles from the old buffer that contain valid regions.
   // Insert placeholders tiles if we have no valid area for that tile
   // which we will allocate in pass 2.
   // TODO: Add a tile pool to reduce new allocation
   int tileX = 0;
   int tileY = 0;
   int tilesMissing = 0;
   // Iterate over the new drawing bounds in steps of tiles.
   for (int32_t x = newBound.x; x < newBound.XMost(); tileX++) {
     // Compute tileRect(x,y,width,height) in layer space coordinate
     // giving us the rect of the tile that hits the newBounds.
-    int width = scaledTileSize.width - GetTileStart(x, scaledTileSize.width);
+    int width = GetScaledTileLength() - GetTileStart(x);
     if (x + width > newBound.XMost()) {
       width = newBound.x + newBound.width - x;
     }
 
     tileY = 0;
     for (int32_t y = newBound.y; y < newBound.YMost(); tileY++) {
-      int height = scaledTileSize.height - GetTileStart(y, scaledTileSize.height);
+      int height = GetScaledTileLength() - GetTileStart(y);
       if (y + height > newBound.y + newBound.height) {
         height = newBound.y + newBound.height - y;
       }
 
       const nsIntRect tileRect(x,y,width,height);
       if (oldValidRegion.Intersects(tileRect) && newValidRegion.Intersects(tileRect)) {
         // This old tiles contains some valid area so move it to the new tile
         // buffer. Replace the tile in the old buffer with a placeholder
         // to leave the old buffer index unaffected.
-        int tileX = floor_div(x - oldBufferOrigin.x, scaledTileSize.width);
-        int tileY = floor_div(y - oldBufferOrigin.y, scaledTileSize.height);
+        int tileX = floor_div(x - oldBufferOrigin.x, GetScaledTileLength());
+        int tileY = floor_div(y - oldBufferOrigin.y, GetScaledTileLength());
         int index = tileX * oldRetainedHeight + tileY;
 
         // The tile may have been removed, skip over it in this case.
         if (IsPlaceholder(oldRetainedTiles.
                           SafeElementAt(index, AsDerived().GetPlaceholderTile()))) {
           newRetainedTiles.AppendElement(AsDerived().GetPlaceholderTile());
         } else {
           Tile tileWithPartialValidContent = oldRetainedTiles[index];
@@ -406,53 +404,53 @@ TiledLayerBuffer<Derived, Tile>::Update(
   // allocated.
   tileX = 0;
 #ifdef GFX_TILEDLAYER_PREF_WARNINGS
   printf_stderr("Update %i, %i, %i, %i\n", newBound.x, newBound.y, newBound.width, newBound.height);
 #endif
   for (int x = newBound.x; x < newBound.x + newBound.width; tileX++) {
     // Compute tileRect(x,y,width,height) in layer space coordinate
     // giving us the rect of the tile that hits the newBounds.
-    int tileStartX = RoundDownToTileEdge(x, scaledTileSize.width);
-    int width = scaledTileSize.width - GetTileStart(x, scaledTileSize.width);
+    int tileStartX = RoundDownToTileEdge(x);
+    int width = GetScaledTileLength() - GetTileStart(x);
     if (x + width > newBound.XMost())
       width = newBound.XMost() - x;
 
     tileY = 0;
     for (int y = newBound.y; y < newBound.y + newBound.height; tileY++) {
-      int tileStartY = RoundDownToTileEdge(y, scaledTileSize.height);
-      int height = scaledTileSize.height - GetTileStart(y, scaledTileSize.height);
+      int tileStartY = RoundDownToTileEdge(y);
+      int height = GetScaledTileLength() - GetTileStart(y);
       if (y + height > newBound.YMost()) {
         height = newBound.YMost() - y;
       }
 
       const nsIntRect tileRect(x, y, width, height);
 
       nsIntRegion tileDrawRegion;
       tileDrawRegion.And(tileRect, regionToPaint);
 
       if (tileDrawRegion.IsEmpty()) {
         // We have a tile but it doesn't hit the draw region
         // because we can reuse all of the content from the
         // previous buffer.
 #ifdef DEBUG
-        int currTileX = floor_div(x - newBufferOrigin.x, scaledTileSize.width);
-        int currTileY = floor_div(y - newBufferOrigin.y, scaledTileSize.height);
+        int currTileX = floor_div(x - newBufferOrigin.x, GetScaledTileLength());
+        int currTileY = floor_div(y - newBufferOrigin.y, GetScaledTileLength());
         int index = currTileX * mRetainedHeight + currTileY;
         NS_ABORT_IF_FALSE(!newValidRegion.Intersects(tileRect) ||
                           !IsPlaceholder(newRetainedTiles.
                                          SafeElementAt(index, AsDerived().GetPlaceholderTile())),
                           "If we don't draw a tile we shouldn't have a placeholder there.");
 #endif
         y += height;
         continue;
       }
 
-      int tileX = floor_div(x - newBufferOrigin.x, scaledTileSize.width);
-      int tileY = floor_div(y - newBufferOrigin.y, scaledTileSize.height);
+      int tileX = floor_div(x - newBufferOrigin.x, GetScaledTileLength());
+      int tileY = floor_div(y - newBufferOrigin.y, GetScaledTileLength());
       int index = tileX * mRetainedHeight + tileY;
       NS_ABORT_IF_FALSE(index >= 0 &&
                         static_cast<unsigned>(index) < newRetainedTiles.Length(),
                         "index out of range");
 
       Tile newTile = newRetainedTiles[index];
 
       // Try to reuse a tile from the old retained tiles that had no partially
--- a/gfx/layers/client/ClientLayerManager.cpp
+++ b/gfx/layers/client/ClientLayerManager.cpp
@@ -2,17 +2,16 @@
  * 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/. */
 
 #include "ClientLayerManager.h"
 #include "CompositorChild.h"            // for CompositorChild
 #include "GeckoProfiler.h"              // for PROFILER_LABEL
 #include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxPrefs.h"                   // for gfxPrefs::LayersTileWidth/Height
 #include "ipc/AutoOpenSurface.h"        // for AutoOpenSurface
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
 #include "mozilla/Hal.h"
 #include "mozilla/dom/ScreenOrientation.h"  // for ScreenOrientation
 #include "mozilla/dom/TabChild.h"       // for TabChild
 #include "mozilla/hal_sandbox/PHal.h"   // for ScreenConfiguration
 #include "mozilla/layers/CompositableClient.h"  // for CompositableChild, etc
 #include "mozilla/layers/ContentClient.h"  // for ContentClientRemote
@@ -453,32 +452,32 @@ ClientLayerManager::GetTexturePool(Surfa
 {
   for (size_t i = 0; i < mTexturePools.Length(); i++) {
     if (mTexturePools[i]->GetFormat() == aFormat) {
       return mTexturePools[i];
     }
   }
 
   mTexturePools.AppendElement(
-      new TextureClientPool(aFormat, IntSize(gfxPrefs::LayersTileWidth(),
-                                             gfxPrefs::LayersTileHeight()),
+      new TextureClientPool(aFormat, IntSize(TILEDLAYERBUFFER_TILE_SIZE,
+                                             TILEDLAYERBUFFER_TILE_SIZE),
                             mForwarder));
 
   return mTexturePools.LastElement();
 }
 
 SimpleTextureClientPool*
 ClientLayerManager::GetSimpleTileTexturePool(SurfaceFormat aFormat)
 {
   int index = (int) aFormat;
   mSimpleTilePools.EnsureLengthAtLeast(index+1);
 
   if (mSimpleTilePools[index].get() == nullptr) {
-    mSimpleTilePools[index] = new SimpleTextureClientPool(aFormat, IntSize(gfxPrefs::LayersTileWidth(),
-                                                                           gfxPrefs::LayersTileHeight()),
+    mSimpleTilePools[index] = new SimpleTextureClientPool(aFormat, IntSize(TILEDLAYERBUFFER_TILE_SIZE,
+                                                                           TILEDLAYERBUFFER_TILE_SIZE),
                                                           mForwarder);
   }
 
   return mSimpleTilePools[index];
 }
 
 void
 ClientLayerManager::ClearCachedResources(Layer* aSubtree)
--- a/gfx/layers/client/SimpleTiledContentClient.cpp
+++ b/gfx/layers/client/SimpleTiledContentClient.cpp
@@ -9,17 +9,16 @@
 #include "ClientTiledThebesLayer.h"     // for ClientTiledThebesLayer
 #include "GeckoProfiler.h"              // for PROFILER_LABEL
 #include "Units.h"                      // for ScreenIntRect, CSSPoint, etc
 #include "UnitTransforms.h"             // for TransformTo
 #include "ClientLayerManager.h"         // for ClientLayerManager
 #include "CompositorChild.h"            // for CompositorChild
 #include "gfxContext.h"                 // for gfxContext, etc
 #include "gfxPlatform.h"                // for gfxPlatform
-#include "gfxPrefs.h"                   // for gfxPrefs::LayersTileWidth/Height
 #include "gfxRect.h"                    // for gfxRect
 #include "mozilla/Attributes.h"         // for MOZ_THIS_IN_INITIALIZER_LIST
 #include "mozilla/MathAlgorithms.h"     // for Abs
 #include "mozilla/gfx/Point.h"          // for IntSize
 #include "mozilla/gfx/Rect.h"           // for Rect
 #include "mozilla/layers/CompositableForwarder.h"
 #include "mozilla/layers/ShadowLayers.h"  // for ShadowLayerForwarder
 #include "SimpleTextureClientPool.h"
@@ -70,17 +69,17 @@ SimpleTiledLayerBuffer::PaintThebes(cons
 }
 
 SimpleTiledLayerTile
 SimpleTiledLayerBuffer::ValidateTile(SimpleTiledLayerTile aTile,
                                      const nsIntPoint& aTileOrigin,
                                      const nsIntRegion& aDirtyRegion)
 {
   PROFILER_LABEL("SimpleTiledLayerBuffer", "ValidateTile");
-  static gfx::IntSize kTileSize(gfxPrefs::LayersTileWidth(), gfxPrefs::LayersTileHeight());
+  static gfx::IntSize kTileSize(TILEDLAYERBUFFER_TILE_SIZE, TILEDLAYERBUFFER_TILE_SIZE);
 
   gfx::SurfaceFormat tileFormat = gfxPlatform::GetPlatform()->Optimal2DFormatForContent(GetContentType());
 
   // if this is true, we're using a separate buffer to do our drawing first
   bool doBufferedDrawing = true;
   bool fullPaint = false;
 
   RefPtr<TextureClient> textureClient = mManager->GetSimpleTileTexturePool(tileFormat)->GetTextureClientWithAutoRecycle();
@@ -125,17 +124,17 @@ SimpleTiledLayerBuffer::ValidateTile(Sim
       bufferData = (unsigned char*) aTile.mCachedBuffer->Data();
 
       drawTarget = gfxPlatform::GetPlatform()->CreateDrawTargetForData(bufferData,
                                                                        kTileSize,
                                                                        bufferStride,
                                                                        tileFormat);
 
       if (fullPaint) {
-        drawBounds = nsIntRect(aTileOrigin.x, aTileOrigin.y, GetScaledTileSize().width, GetScaledTileSize().height);
+        drawBounds = nsIntRect(aTileOrigin.x, aTileOrigin.y, GetScaledTileLength(), GetScaledTileLength());
         drawRegion = nsIntRegion(drawBounds);
       } else {
         drawBounds = aDirtyRegion.GetBounds();
         drawRegion = nsIntRegion(drawBounds);
         if (GetContentType() == gfxContentType::COLOR_ALPHA)
           drawTarget->ClearRect(Rect(drawBounds.x - aTileOrigin.x, drawBounds.y - aTileOrigin.y,
                                      drawBounds.width, drawBounds.height));
       }
@@ -145,17 +144,17 @@ SimpleTiledLayerBuffer::ValidateTile(Sim
     }
   }
 
   // this might get set above if we couldn't extract out a buffer
   if (!doBufferedDrawing) {
     drawTarget = textureClient->AsTextureClientDrawTarget()->GetAsDrawTarget();
 
     fullPaint = true;
-    drawBounds = nsIntRect(aTileOrigin.x, aTileOrigin.y, GetScaledTileSize().width, GetScaledTileSize().height);
+    drawBounds = nsIntRect(aTileOrigin.x, aTileOrigin.y, GetScaledTileLength(), GetScaledTileLength());
     drawRegion = nsIntRegion(drawBounds);
 
     if (GetContentType() == gfxContentType::COLOR_ALPHA)
       drawTarget->ClearRect(Rect(0, 0, drawBounds.width, drawBounds.height));
   }
 
   // do the drawing
   RefPtr<gfxContext> ctxt = new gfxContext(drawTarget);
--- a/gfx/layers/client/TiledContentClient.cpp
+++ b/gfx/layers/client/TiledContentClient.cpp
@@ -24,17 +24,17 @@
 #include "nsSize.h"                     // for nsIntSize
 #include "gfxReusableSharedImageSurfaceWrapper.h"
 #include "nsMathUtils.h"               // for NS_roundf
 #include "gfx2DGlue.h"
 
 // This is the minimum area that we deem reasonable to copy from the front buffer to the
 // back buffer on tile updates. If the valid region is smaller than this, we just
 // redraw it and save on the copy (and requisite surface-locking involved).
-#define MINIMUM_TILE_COPY_AREA (1.f/16.f)
+#define MINIMUM_TILE_COPY_AREA ((TILEDLAYERBUFFER_TILE_SIZE * TILEDLAYERBUFFER_TILE_SIZE)/16)
 
 #ifdef GFX_TILEDLAYER_DEBUG_OVERLAY
 #include "cairo.h"
 #include <sstream>
 using mozilla::layers::Layer;
 static void DrawDebugOverlay(mozilla::gfx::DrawTarget* dt, int x, int y, int width, int height)
 {
   gfxContext c(dt);
@@ -418,32 +418,31 @@ TileClient::Flip()
   mInvalidBack = invalidFront;
 }
 
 void
 TileClient::ValidateBackBufferFromFront(const nsIntRegion& aDirtyRegion,
                                         bool aCanRerasterizeValidRegion)
 {
   if (mBackBuffer && mFrontBuffer) {
-    gfx::IntSize tileSize = mFrontBuffer->GetSize();
-    const nsIntRect tileRect = nsIntRect(0, 0, tileSize.width, tileSize.height);
+    const nsIntRect tileRect = nsIntRect(0, 0, TILEDLAYERBUFFER_TILE_SIZE, TILEDLAYERBUFFER_TILE_SIZE);
 
     if (aDirtyRegion.Contains(tileRect)) {
       // The dirty region means that we no longer need the front buffer, so
       // discard it.
       DiscardFrontBuffer();
     } else {
       // Region that needs copying.
       nsIntRegion regionToCopy = mInvalidBack;
 
       regionToCopy.Sub(regionToCopy, aDirtyRegion);
 
       if (regionToCopy.IsEmpty() ||
           (aCanRerasterizeValidRegion &&
-           regionToCopy.Area() < tileSize.width * tileSize.height * MINIMUM_TILE_COPY_AREA)) {
+           regionToCopy.Area() < MINIMUM_TILE_COPY_AREA)) {
         // Just redraw it all.
         return;
       }
 
       if (!mFrontBuffer->Lock(OPEN_READ)) {
         NS_WARNING("Failed to lock the tile's front buffer");
         return;
       }
@@ -522,17 +521,17 @@ TileClient::GetBackBuffer(const nsIntReg
       mBackLock = new gfxMemorySharedReadLock();
     } else {
       mBackLock = new gfxShmSharedReadLock(mManager->AsShadowForwarder());
     }
 
     MOZ_ASSERT(mBackLock->IsValid());
 
     *aCreatedTextureClient = true;
-    mInvalidBack = nsIntRect(0, 0, mBackBuffer->GetSize().width, mBackBuffer->GetSize().height);
+    mInvalidBack = nsIntRect(0, 0, TILEDLAYERBUFFER_TILE_SIZE, TILEDLAYERBUFFER_TILE_SIZE);
   }
 
   ValidateBackBufferFromFront(aDirtyRegion, aCanRerasterizeValidRegion);
 
   return mBackBuffer;
 }
 
 TileDescriptor
@@ -778,23 +777,23 @@ ClientTiledLayerBuffer::ValidateTile(Til
       gfx::IntPoint copyTarget(NS_roundf(drawRect.x), NS_roundf(drawRect.y));
       drawTarget->CopySurface(source, copyRect, copyTarget);
 
       // Mark the newly updated area as invalid in the front buffer
       aTile.mInvalidFront.Or(aTile.mInvalidFront, nsIntRect(copyTarget.x, copyTarget.y, copyRect.width, copyRect.height));
     }
 
     // The new buffer is now validated, remove the dirty region from it.
-    aTile.mInvalidBack.Sub(nsIntRect(0, 0, GetTileSize().width, GetTileSize().height),
+    aTile.mInvalidBack.Sub(nsIntRect(0, 0, TILEDLAYERBUFFER_TILE_SIZE, TILEDLAYERBUFFER_TILE_SIZE),
                            offsetScaledDirtyRegion);
   } else {
     // Area of the full tile...
     nsIntRegion tileRegion =
       nsIntRect(aTileOrigin.x, aTileOrigin.y,
-                GetScaledTileSize().width, GetScaledTileSize().height);
+                GetScaledTileLength(), GetScaledTileLength());
 
     // Intersect this area with the portion that's dirty.
     tileRegion = tileRegion.Intersect(aDirtyRegion);
 
     // Add the resolution scale to store the dirty region.
     nsIntPoint unscaledTileOrigin = nsIntPoint(aTileOrigin.x * mResolution,
                                                aTileOrigin.y * mResolution);
     nsIntRegion unscaledTileRegion(tileRegion);
@@ -993,35 +992,35 @@ ClientTiledLayerBuffer::ComputeProgressi
   bool paintInSingleTransaction = paintVisible && (drawingStale || aPaintData->mFirstPaint);
 
   // The following code decides what order to draw tiles in, based on the
   // current scroll direction of the primary scrollable layer.
   NS_ASSERTION(!aRegionToPaint.IsEmpty(), "Unexpectedly empty paint region!");
   nsIntRect paintBounds = aRegionToPaint.GetBounds();
 
   int startX, incX, startY, incY;
-  gfx::IntSize scaledTileSize = GetScaledTileSize();
+  int tileLength = GetScaledTileLength();
   if (aPaintData->mScrollOffset.x >= aPaintData->mLastScrollOffset.x) {
-    startX = RoundDownToTileEdge(paintBounds.x, scaledTileSize.width);
-    incX = scaledTileSize.width;
+    startX = RoundDownToTileEdge(paintBounds.x);
+    incX = tileLength;
   } else {
-    startX = RoundDownToTileEdge(paintBounds.XMost() - 1, scaledTileSize.width);
-    incX = -scaledTileSize.width;
+    startX = RoundDownToTileEdge(paintBounds.XMost() - 1);
+    incX = -tileLength;
   }
 
   if (aPaintData->mScrollOffset.y >= aPaintData->mLastScrollOffset.y) {
-    startY = RoundDownToTileEdge(paintBounds.y, scaledTileSize.height);
-    incY = scaledTileSize.height;
+    startY = RoundDownToTileEdge(paintBounds.y);
+    incY = tileLength;
   } else {
-    startY = RoundDownToTileEdge(paintBounds.YMost() - 1, scaledTileSize.height);
-    incY = -scaledTileSize.height;
+    startY = RoundDownToTileEdge(paintBounds.YMost() - 1);
+    incY = -tileLength;
   }
 
   // Find a tile to draw.
-  nsIntRect tileBounds(startX, startY, scaledTileSize.width, scaledTileSize.height);
+  nsIntRect tileBounds(startX, startY, tileLength, tileLength);
   int32_t scrollDiffX = aPaintData->mScrollOffset.x - aPaintData->mLastScrollOffset.x;
   int32_t scrollDiffY = aPaintData->mScrollOffset.y - aPaintData->mLastScrollOffset.y;
   // This loop will always terminate, as there is at least one tile area
   // along the first/last row/column intersecting with regionToPaint, or its
   // bounds would have been smaller.
   while (true) {
     aRegionToPaint.And(aInvalidRegion, tileBounds);
     if (!aRegionToPaint.IsEmpty()) {
--- a/gfx/layers/composite/TiledContentHost.cpp
+++ b/gfx/layers/composite/TiledContentHost.cpp
@@ -424,48 +424,47 @@ TiledContentHost::RenderLayerBuffer(Tile
   // Make sure the resolution and difference in frame resolution are accounted
   // for in the layer transform.
   aTransform.Scale(1/(resolution * layerScale.width),
                    1/(resolution * layerScale.height), 1);
 
   uint32_t rowCount = 0;
   uint32_t tileX = 0;
   nsIntRect visibleRect = aVisibleRegion.GetBounds();
-  gfx::IntSize scaledTileSize = aLayerBuffer.GetScaledTileSize();
   for (int32_t x = visibleRect.x; x < visibleRect.x + visibleRect.width;) {
     rowCount++;
-    int32_t tileStartX = aLayerBuffer.GetTileStart(x, scaledTileSize.width);
-    int32_t w = scaledTileSize.width - tileStartX;
+    int32_t tileStartX = aLayerBuffer.GetTileStart(x);
+    int32_t w = aLayerBuffer.GetScaledTileLength() - tileStartX;
     if (x + w > visibleRect.x + visibleRect.width) {
       w = visibleRect.x + visibleRect.width - x;
     }
     int tileY = 0;
     for (int32_t y = visibleRect.y; y < visibleRect.y + visibleRect.height;) {
-      int32_t tileStartY = aLayerBuffer.GetTileStart(y, scaledTileSize.height);
-      int32_t h = scaledTileSize.height - tileStartY;
+      int32_t tileStartY = aLayerBuffer.GetTileStart(y);
+      int32_t h = aLayerBuffer.GetScaledTileLength() - tileStartY;
       if (y + h > visibleRect.y + visibleRect.height) {
         h = visibleRect.y + visibleRect.height - y;
       }
 
       TileHost tileTexture = aLayerBuffer.
-        GetTile(nsIntPoint(aLayerBuffer.RoundDownToTileEdge(x, scaledTileSize.width),
-                           aLayerBuffer.RoundDownToTileEdge(y, scaledTileSize.height)));
+        GetTile(nsIntPoint(aLayerBuffer.RoundDownToTileEdge(x),
+                           aLayerBuffer.RoundDownToTileEdge(y)));
       if (tileTexture != aLayerBuffer.GetPlaceholderTile()) {
         nsIntRegion tileDrawRegion;
         tileDrawRegion.And(nsIntRect(x, y, w, h), aLayerBuffer.GetValidRegion());
         tileDrawRegion.And(tileDrawRegion, aVisibleRegion);
         tileDrawRegion.Sub(tileDrawRegion, maskRegion);
 
         if (!tileDrawRegion.IsEmpty()) {
           tileDrawRegion.ScaleRoundOut(resolution, resolution);
           nsIntPoint tileOffset((x - tileStartX) * resolution,
                                 (y - tileStartY) * resolution);
-          gfx::IntSize tileSize = aLayerBuffer.GetTileSize();
+          uint32_t tileSize = aLayerBuffer.GetTileLength();
           RenderTile(tileTexture, aEffectChain, aOpacity, aTransform, aFilter, aClipRect, tileDrawRegion,
-                     tileOffset, nsIntSize(tileSize.width, tileSize.height));
+                     tileOffset, nsIntSize(tileSize, tileSize));
         }
       }
       tileY++;
       y += h;
     }
     tileX++;
     x += w;
   }
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -8,19 +8,19 @@
 #include "GLSharedHandleHelpers.h"
 #include "GLUploadHelpers.h"
 #include "GLReadTexImageHelper.h"
 #include "SharedSurface.h"              // for SharedSurface
 #include "SharedSurfaceEGL.h"           // for SharedSurface_EGLImage
 #include "SharedSurfaceGL.h"            // for SharedSurface_GLTexture, etc
 #include "SurfaceStream.h"              // for SurfaceStream
 #include "SurfaceTypes.h"               // for SharedSurfaceType, etc
+#include "TiledLayerBuffer.h"           // for TILEDLAYERBUFFER_TILE_SIZE
 #include "gfx2DGlue.h"                  // for ContentForFormat, etc
 #include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxPrefs.h"                   // for gfxPrefs::LayersTileWidth/Height
 #include "gfxReusableSurfaceWrapper.h"  // for gfxReusableSurfaceWrapper
 #include "ipc/AutoOpenSurface.h"        // for AutoOpenSurface
 #include "mozilla/gfx/2D.h"             // for DataSourceSurface
 #include "mozilla/gfx/BaseSize.h"       // for BaseSize
 #include "mozilla/layers/CompositorOGL.h"  // for CompositorOGL
 #ifdef MOZ_WIDGET_GONK
 # include "GrallocImages.h"  // for GrallocImage
 # include "EGLImageHelpers.h"
--- a/gfx/tests/gtest/TestTiledLayerBuffer.cpp
+++ b/gfx/tests/gtest/TestTiledLayerBuffer.cpp
@@ -56,18 +56,18 @@ public:
 
 TEST(TiledLayerBuffer, TileConstructor) {
   TestTiledLayerBuffer buffer;
 }
 
 TEST(TiledLayerBuffer, TileStart) {
   TestTiledLayerBuffer buffer;
 
-  ASSERT_EQ(buffer.RoundDownToTileEdge(10, 256), 0);
-  ASSERT_EQ(buffer.RoundDownToTileEdge(-10, 256), -256);
+  ASSERT_EQ(buffer.RoundDownToTileEdge(10), 0);
+  ASSERT_EQ(buffer.RoundDownToTileEdge(-10), -256);
 }
 
 TEST(TiledLayerBuffer, EmptyUpdate) {
   TestTiledLayerBuffer buffer;
 
   nsIntRegion validRegion(nsIntRect(0, 0, 10, 10));
   buffer.TestUpdate(validRegion, validRegion);
 
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -174,21 +174,16 @@ private:
   DECL_GFX_PREF(Live, "layers.draw-borders",                   DrawLayerBorders, bool, false);
   DECL_GFX_PREF(Live, "layers.draw-tile-borders",              DrawTileBorders, bool, false);
   DECL_GFX_PREF(Live, "layers.flash-borders",                  FlashLayerBorders, bool, false);
   DECL_GFX_PREF(Live, "layers.draw-layer-info",                DrawLayerInfo, bool, false);
   DECL_GFX_PREF(Once, "layers.dump",                           LayersDump, bool, false);
   DECL_GFX_PREF(Once, "layers.enable-tiles",                   LayersTilesEnabled, bool, false);
   DECL_GFX_PREF(Once, "layers.simple-tiles",                   LayersUseSimpleTiles, bool, false);
   DECL_GFX_PREF(Once, "layers.force-per-tile-drawing",         PerTileDrawing, bool, false);
-  // We allow for configurable and rectangular tile size to avoid wasting memory on devices whose
-  // screen size does not align nicely to the default tile size. Although layers can be any size,
-  // they are often the same size as the screen, especially for width.
-  DECL_GFX_PREF(Once, "layers.tile-width",                     LayersTileWidth, int32_t, 256);
-  DECL_GFX_PREF(Once, "layers.tile-height",                    LayersTileHeight, int32_t, 256);
   DECL_GFX_PREF(Once, "layers.overzealous-gralloc-unlocking",  OverzealousGrallocUnlocking, bool, false);
   DECL_GFX_PREF(Once, "layers.force-shmem-tiles",              ForceShmemTiles, bool, false);
   DECL_GFX_PREF(Live, "layers.frame-counter",                  DrawFrameCounter, bool, false);
   DECL_GFX_PREF(Live, "layers.low-precision-buffer",           UseLowPrecisionBuffer, bool, false);
   DECL_GFX_PREF(Live, "layers.low-precision-resolution",       LowPrecisionResolution, int32_t, 250);
   DECL_GFX_PREF(Once, "layers.offmainthreadcomposition.enabled", LayersOffMainThreadCompositionEnabled, bool, false);
   DECL_GFX_PREF(Live, "layers.offmainthreadcomposition.frame-rate", LayersCompositionFrameRate, int32_t,-1);
   DECL_GFX_PREF(Once, "layers.offmainthreadcomposition.force-enabled", LayersOffMainThreadCompositionForceEnabled, bool, false);
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -720,36 +720,36 @@ nsLayoutUtils::GetDisplayPort(nsIContent
         rect.height =
           parentRes.height * NSAppUnitsToFloatPixels(base.height, auPerDevPixel);
 
         rect.Inflate(marginsData->mMargins);
 
         nsIScrollableFrame* scrollableFrame = frame->GetScrollTargetFrame();
         nsPoint scrollPos(
           scrollableFrame ? scrollableFrame->GetScrollPosition() : nsPoint(0,0));
-        if (marginsData->mAlignmentX > 0 || marginsData->mAlignmentY > 0) {
+        if (marginsData->mAlignment > 0) {
           LayerPoint scrollPosLayer(
             res.width * NSAppUnitsToFloatPixels(scrollPos.x, auPerDevPixel),
             res.height * NSAppUnitsToFloatPixels(scrollPos.y, auPerDevPixel));
           rect += scrollPosLayer;
 
           // Inflate the rectangle by 1 so that we always push to the next tile
           // boundary. This is desirable to stop from having a rectangle with a
           // moving origin occasionally being smaller when it coincidentally lines
           // up to tile boundaries.
           rect.Inflate(1);
 
           float left =
-            marginsData->mAlignmentX * floor(rect.x / marginsData->mAlignmentX);
+            marginsData->mAlignment * floor(rect.x / marginsData->mAlignment);
           float top =
-            marginsData->mAlignmentY * floor(rect.y / marginsData->mAlignmentY);
+            marginsData->mAlignment * floor(rect.y / marginsData->mAlignment);
           float right =
-            marginsData->mAlignmentX * ceil(rect.XMost() / marginsData->mAlignmentX);
+            marginsData->mAlignment * ceil(rect.XMost() / marginsData->mAlignment);
           float bottom =
-            marginsData->mAlignmentY * ceil(rect.YMost() / marginsData->mAlignmentY);
+            marginsData->mAlignment * ceil(rect.YMost() / marginsData->mAlignment);
           rect = LayerRect(left, top, right - left, bottom - top);
           rect -= scrollPosLayer;
         }
 
         nsRect result;
         result.x = NSFloatPixelsToAppUnits(rect.x / res.width, auPerDevPixel);
         result.y = NSFloatPixelsToAppUnits(rect.y / res.height, auPerDevPixel);
         result.width =
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -82,26 +82,23 @@ struct DisplayPortPropertyData {
     , mPriority(aPriority)
   {}
   nsRect mRect;
   uint32_t mPriority;
 };
 
 struct DisplayPortMarginsPropertyData {
   DisplayPortMarginsPropertyData(const LayerMargin& aMargins,
-                                 uint32_t aAlignmentX, uint32_t aAlignmentY,
-                                 uint32_t aPriority)
+                                 uint32_t aAlignment, uint32_t aPriority)
     : mMargins(aMargins)
-    , mAlignmentX(aAlignmentX)
-    , mAlignmentY(aAlignmentY)
+    , mAlignment(aAlignment)
     , mPriority(aPriority)
   {}
   LayerMargin mMargins;
-  uint32_t mAlignmentX;
-  uint32_t mAlignmentY;
+  uint32_t mAlignment;
   uint32_t mPriority;
 };
 
 template <class AnimationsOrTransitions>
 extern AnimationsOrTransitions* HasAnimationOrTransition(nsIContent* aContent,
                                                          nsIAtom* aAnimationProperty,
                                                          nsCSSProperty aProperty);
 
--- a/widget/xpwidgets/APZCCallbackHelper.cpp
+++ b/widget/xpwidgets/APZCCallbackHelper.cpp
@@ -1,20 +1,21 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #include "APZCCallbackHelper.h"
-#include "gfxPrefs.h" // For gfxPrefs::LayersTilesEnabled, LayersTileWidth/Height
+#include "gfxPrefs.h" // For gfxPrefs::LayersTilesEnabled
 #include "mozilla/Preferences.h"
 #include "nsIScrollableFrame.h"
 #include "nsLayoutUtils.h"
 #include "nsIDOMElement.h"
 #include "nsIInterfaceRequestorUtils.h"
+#include "TiledLayerBuffer.h" // For TILEDLAYERBUFFER_TILE_SIZE
 
 namespace mozilla {
 namespace widget {
 
 bool
 APZCCallbackHelper::HasValidPresShellId(nsIDOMWindowUtils* aUtils,
                                         const FrameMetrics& aMetrics)
 {
@@ -40,22 +41,24 @@ static CSSRect ExpandDisplayPortToTileBo
 
   // Inflate the rectangle by 1 so that we always push to the next tile
   // boundary. This is desirable to stop from having a rectangle with a
   // moving origin occasionally being smaller when it coincidentally lines
   // up to tile boundaries.
   displayPortInLayerSpace.Inflate(1);
 
   // Now nudge the rectangle to the nearest equal or larger tile boundary.
-  int32_t tileWidth = gfxPrefs::LayersTileWidth();
-  int32_t tileHeight = gfxPrefs::LayersTileHeight();
-  gfxFloat left = tileWidth * floor(displayPortInLayerSpace.x / tileWidth);
-  gfxFloat right = tileWidth * ceil(displayPortInLayerSpace.XMost() / tileWidth);
-  gfxFloat top = tileHeight * floor(displayPortInLayerSpace.y / tileHeight);
-  gfxFloat bottom = tileHeight * ceil(displayPortInLayerSpace.YMost() / tileHeight);
+  gfxFloat left = TILEDLAYERBUFFER_TILE_SIZE
+    * floor(displayPortInLayerSpace.x / TILEDLAYERBUFFER_TILE_SIZE);
+  gfxFloat top = TILEDLAYERBUFFER_TILE_SIZE
+    * floor(displayPortInLayerSpace.y / TILEDLAYERBUFFER_TILE_SIZE);
+  gfxFloat right = TILEDLAYERBUFFER_TILE_SIZE
+    * ceil(displayPortInLayerSpace.XMost() / TILEDLAYERBUFFER_TILE_SIZE);
+  gfxFloat bottom = TILEDLAYERBUFFER_TILE_SIZE
+    * ceil(displayPortInLayerSpace.YMost() / TILEDLAYERBUFFER_TILE_SIZE);
 
   displayPortInLayerSpace = LayerRect(left, top, right - left, bottom - top);
   CSSRect displayPort = displayPortInLayerSpace / aLayerPixelsPerCSSPixel;
 
   return displayPort;
 }
 
 static void
@@ -223,26 +226,24 @@ APZCCallbackHelper::UpdateRootFrame(nsID
     }
     if (!aMetrics.GetUseDisplayPortMargins()) {
         aUtils->SetDisplayPortForElement(aMetrics.mDisplayPort.x,
                                          aMetrics.mDisplayPort.y,
                                          aMetrics.mDisplayPort.width,
                                          aMetrics.mDisplayPort.height,
                                          element, 0);
     } else {
-        gfx::IntSize alignment = gfxPrefs::LayersTilesEnabled()
-            ? gfx::IntSize(gfxPrefs::LayersTileWidth(), gfxPrefs::LayersTileHeight()) :
-              gfx::IntSize(1, 1);
+        uint32_t alignment = gfxPrefs::LayersTilesEnabled()
+            ? TILEDLAYERBUFFER_TILE_SIZE : 1;
         LayerMargin margins = aMetrics.GetDisplayPortMargins();
         aUtils->SetDisplayPortMarginsForElement(margins.left,
                                                 margins.top,
                                                 margins.right,
                                                 margins.bottom,
-                                                alignment.width,
-                                                alignment.height,
+                                                alignment,
                                                 element, 0);
         CSSRect baseCSS = aMetrics.mCompositionBounds / aMetrics.GetZoomToParent();
         nsRect base(baseCSS.x * nsPresContext::AppUnitsPerCSSPixel(),
                     baseCSS.y * nsPresContext::AppUnitsPerCSSPixel(),
                     baseCSS.width * nsPresContext::AppUnitsPerCSSPixel(),
                     baseCSS.height * nsPresContext::AppUnitsPerCSSPixel());
         nsLayoutUtils::SetDisplayPortBase(content, base);
     }
@@ -278,26 +279,24 @@ APZCCallbackHelper::UpdateSubFrame(nsICo
         MaybeAlignAndClampDisplayPort(aMetrics, actualScrollOffset);
         if (!aMetrics.GetUseDisplayPortMargins()) {
             utils->SetDisplayPortForElement(aMetrics.mDisplayPort.x,
                                             aMetrics.mDisplayPort.y,
                                             aMetrics.mDisplayPort.width,
                                             aMetrics.mDisplayPort.height,
                                             element, 0);
         } else {
-            gfx::IntSize alignment = gfxPrefs::LayersTilesEnabled()
-                ? gfx::IntSize(gfxPrefs::LayersTileWidth(), gfxPrefs::LayersTileHeight()) :
-                  gfx::IntSize(1, 1);
+            uint32_t alignment = gfxPrefs::LayersTilesEnabled()
+                ? TILEDLAYERBUFFER_TILE_SIZE : 1;
             LayerMargin margins = aMetrics.GetDisplayPortMargins();
             utils->SetDisplayPortMarginsForElement(margins.left,
                                                    margins.top,
                                                    margins.right,
                                                    margins.bottom,
-                                                   alignment.width,
-                                                   alignment.height,
+                                                   alignment,
                                                    element, 0);
             CSSRect baseCSS = aMetrics.mCompositionBounds / aMetrics.GetZoomToParent();
             nsRect base(baseCSS.x * nsPresContext::AppUnitsPerCSSPixel(),
                         baseCSS.y * nsPresContext::AppUnitsPerCSSPixel(),
                         baseCSS.width * nsPresContext::AppUnitsPerCSSPixel(),
                         baseCSS.height * nsPresContext::AppUnitsPerCSSPixel());
             nsLayoutUtils::SetDisplayPortBase(aContent, base);
         }