Merge mozilla-central to b2g-inbound
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Tue, 17 Feb 2015 14:56:47 +0100
changeset 229332 81afbc24cad3ac745a83d56a49df5fe3b8b87e09
parent 229331 cbf5a0dd70d77c8538a7030517b5a0db386cca5b (current diff)
parent 229297 feac5924bccbd2ace7d67b0d2a1eac3058b22286 (diff)
child 229333 5be9b3e39912c1e95bc4fe6e76218e8fa8901a5d
push id11352
push userryanvm@gmail.com
push dateTue, 17 Feb 2015 19:29:37 +0000
treeherderfx-team@b6c56fab513d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone38.0a1
Merge mozilla-central to b2g-inbound
--- a/gfx/layers/TiledLayerBuffer.h
+++ b/gfx/layers/TiledLayerBuffer.h
@@ -523,38 +523,40 @@ TiledLayerBuffer<Derived, Tile>::Update(
 
       int tileX = floor_div(x - newBufferOrigin.x, scaledTileSize.width);
       int tileY = floor_div(y - newBufferOrigin.y, scaledTileSize.height);
       int index = tileX * mRetainedHeight + tileY;
       MOZ_ASSERT(index >= 0 &&
                  static_cast<unsigned>(index) < newRetainedTiles.Length(),
                  "index out of range");
 
-      Tile& newTile = newRetainedTiles[index];
+      Tile newTile = newRetainedTiles[index];
 
       // Try to reuse a tile from the old retained tiles that had no partially
       // valid content.
       while (newTile.IsPlaceholderTile() && oldRetainedTiles.Length() > 0) {
         AsDerived().SwapTiles(newTile, oldRetainedTiles[oldRetainedTiles.Length()-1]);
         oldRetainedTiles.RemoveElementAt(oldRetainedTiles.Length()-1);
         if (!newTile.IsPlaceholderTile()) {
           oldTileCount--;
         }
       }
 
       // We've done our best effort to recycle a tile but it can be null
       // in which case it's up to the derived class's ValidateTile()
       // implementation to allocate a new tile before drawing
       nsIntPoint tileOrigin(tileStartX, tileStartY);
-      AsDerived().ValidateTile(newTile, nsIntPoint(tileStartX, tileStartY),
-                               tileDrawRegion);
+      newTile = AsDerived().ValidateTile(newTile, nsIntPoint(tileStartX, tileStartY),
+                                         tileDrawRegion);
       NS_ASSERTION(!newTile.IsPlaceholderTile(), "Unexpected placeholder tile - failed to allocate?");
 #ifdef GFX_TILEDLAYER_PREF_WARNINGS
       printf_stderr("Store Validate tile %i, %i -> %i\n", tileStartX, tileStartY, index);
 #endif
+      newRetainedTiles[index] = newTile;
+
       y += height;
     }
 
     x += width;
   }
 
   AsDerived().PostValidate(aPaintRegion);
   for (unsigned int i = 0; i < newRetainedTiles.Length(); ++i) {
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -386,23 +386,28 @@ BasicCompositor::ClearRect(const gfx::Re
 
 void
 BasicCompositor::BeginFrame(const nsIntRegion& aInvalidRegion,
                             const gfx::Rect *aClipRectIn,
                             const gfx::Rect& aRenderBounds,
                             gfx::Rect *aClipRectOut /* = nullptr */,
                             gfx::Rect *aRenderBoundsOut /* = nullptr */)
 {
-  mWidgetSize = mWidget->GetClientSize();
-  IntRect intRect = gfx::IntRect(IntPoint(), mWidgetSize);
+  nsIntRect intRect;
+  mWidget->GetClientBounds(intRect);
+  mWidgetSize = gfx::ToIntSize(intRect.Size());
+
+  // The result of GetClientBounds is shifted over by the size of the window
+  // manager styling. We want to ignore that.
+  intRect.MoveTo(0, 0);
   Rect rect = Rect(0, 0, intRect.width, intRect.height);
 
   // Sometimes the invalid region is larger than we want to draw.
   nsIntRegion invalidRegionSafe;
-  invalidRegionSafe.And(aInvalidRegion, gfx::ThebesIntRect(intRect));
+  invalidRegionSafe.And(aInvalidRegion, intRect);
 
   nsIntRect invalidRect = invalidRegionSafe.GetBounds();
   mInvalidRect = IntRect(invalidRect.x, invalidRect.y, invalidRect.width, invalidRect.height);
   mInvalidRegion = invalidRegionSafe;
 
   if (aRenderBoundsOut) {
     *aRenderBoundsOut = Rect();
   }
--- a/gfx/layers/client/TiledContentClient.cpp
+++ b/gfx/layers/client/TiledContentClient.cpp
@@ -1054,17 +1054,17 @@ ClientTiledLayerBuffer::PostValidate(con
     mMoz2DTiles.clear();
     // Reset:
     mTilingOrigin = IntPoint(std::numeric_limits<int32_t>::max(),
                              std::numeric_limits<int32_t>::max());
   }
 }
 
 void
-ClientTiledLayerBuffer::UnlockTile(TileClient& aTile)
+ClientTiledLayerBuffer::UnlockTile(TileClient aTile)
 {
   // We locked the back buffer, and flipped so we now need to unlock the front
   if (aTile.mFrontBuffer && aTile.mFrontBuffer->IsLocked()) {
     aTile.mFrontBuffer->Unlock();
     aTile.mFrontBuffer->SyncWithObject(mCompositableClient->GetForwarder()->GetSyncObject());
   }
   if (aTile.mFrontBufferOnWhite && aTile.mFrontBufferOnWhite->IsLocked()) {
     aTile.mFrontBufferOnWhite->Unlock();
@@ -1073,18 +1073,18 @@ ClientTiledLayerBuffer::UnlockTile(TileC
   if (aTile.mBackBuffer && aTile.mBackBuffer->IsLocked()) {
     aTile.mBackBuffer->Unlock();
   }
   if (aTile.mBackBufferOnWhite && aTile.mBackBufferOnWhite->IsLocked()) {
     aTile.mBackBufferOnWhite->Unlock();
   }
 }
 
-void
-ClientTiledLayerBuffer::ValidateTile(TileClient& aTile,
+TileClient
+ClientTiledLayerBuffer::ValidateTile(TileClient aTile,
                                     const nsIntPoint& aTileOrigin,
                                     const nsIntRegion& aDirtyRegion)
 {
   PROFILER_LABEL("ClientTiledLayerBuffer", "ValidateTile",
     js::ProfileEntry::Category::GRAPHICS);
 
 #ifdef GFX_TILEDLAYER_PREF_WARNINGS
   if (aDirtyRegion.IsComplex()) {
@@ -1115,66 +1115,71 @@ ClientTiledLayerBuffer::ValidateTile(Til
                         &backBufferOnWhite);
 
   extraPainted.MoveBy(aTileOrigin);
   extraPainted.And(extraPainted, mNewValidRegion);
   mPaintedRegion.Or(mPaintedRegion, extraPainted);
 
   if (!backBuffer) {
     NS_WARNING("Failed to allocate a tile TextureClient");
-    aTile.Release();
-    return;
+    aTile.DiscardBackBuffer();
+    aTile.DiscardFrontBuffer();
+    return TileClient();
   }
 
   // the back buffer may have been already locked in ValidateBackBufferFromFront
   if (!backBuffer->IsLocked()) {
     if (!backBuffer->Lock(OpenMode::OPEN_READ_WRITE)) {
       NS_WARNING("Failed to lock a tile TextureClient");
-    aTile.Release();
-    return;
+      aTile.DiscardBackBuffer();
+      aTile.DiscardFrontBuffer();
+      return TileClient();
     }
   }
 
   if (backBufferOnWhite && !backBufferOnWhite->IsLocked()) {
     if (!backBufferOnWhite->Lock(OpenMode::OPEN_READ_WRITE)) {
       NS_WARNING("Failed to lock tile TextureClient for updating.");
-      aTile.Release();
-      return;
+      aTile.DiscardBackBuffer();
+      aTile.DiscardFrontBuffer();
+      return TileClient();
     }
   }
 
   if (usingTiledDrawTarget) {
     if (createdTextureClient) {
       if (!mCompositableClient->AddTextureClient(backBuffer)) {
         NS_WARNING("Failed to add tile TextureClient.");
-        aTile.Release();
-        return;
+        aTile.DiscardFrontBuffer();
+        aTile.DiscardBackBuffer();
+        return aTile;
       }
       if (backBufferOnWhite && !mCompositableClient->AddTextureClient(backBufferOnWhite)) {
         NS_WARNING("Failed to add tile TextureClient.");
-        aTile.Release();
-        return;
+        aTile.DiscardFrontBuffer();
+        aTile.DiscardBackBuffer();
+        return aTile;
       }
     }
 
     // prepare an array of Moz2D tiles that will be painted into in PostValidate
     gfx::Tile moz2DTile;
     RefPtr<DrawTarget> dt = backBuffer->BorrowDrawTarget();
     RefPtr<DrawTarget> dtOnWhite;
     if (backBufferOnWhite) {
       dtOnWhite = backBufferOnWhite->BorrowDrawTarget();
       moz2DTile.mDrawTarget = Factory::CreateDualDrawTarget(dt, dtOnWhite);
     } else {
       moz2DTile.mDrawTarget = dt;
     }
     moz2DTile.mTileOrigin = gfx::IntPoint(aTileOrigin.x, aTileOrigin.y);
     if (!dt || (backBufferOnWhite && !dtOnWhite)) {
-      NS_WARNING("Failed to get a DrawTarget from a tile");
-      aTile.Release();
-      return;
+      aTile.DiscardFrontBuffer();
+      aTile.DiscardBackBuffer();
+      return aTile;
     }
 
     mMoz2DTiles.push_back(moz2DTile);
     mTilingOrigin.x = std::min(mTilingOrigin.x, moz2DTile.mTileOrigin.x);
     mTilingOrigin.y = std::min(mTilingOrigin.y, moz2DTile.mTileOrigin.y);
 
     nsIntRegionRectIterator it(aDirtyRegion);
     for (const nsIntRect* dirtyRect = it.Next(); dirtyRect != nullptr; dirtyRect = it.Next()) {
@@ -1197,17 +1202,17 @@ ClientTiledLayerBuffer::ValidateTile(Til
       }
     }
 
     // The new buffer is now validated, remove the dirty region from it.
     aTile.mInvalidBack.SubOut(offsetScaledDirtyRegion);
 
     aTile.Flip();
 
-    return;
+    return aTile;
   }
 
   // Single paint buffer case:
 
   MOZ_ASSERT(!backBufferOnWhite, "Component alpha only supported with TiledDrawTarget");
 
   // We must not keep a reference to the DrawTarget after it has been unlocked,
   // make sure these are null'd before unlocking as destruction of the context
@@ -1281,31 +1286,34 @@ ClientTiledLayerBuffer::ValidateTile(Til
   tileRegion.SubOut(aDirtyRegion); // Has now been validated
 
   backBuffer->Unlock();
   backBuffer->SetWaste(tileRegion.Area() * mResolution * mResolution);
 
   if (createdTextureClient) {
     if (!mCompositableClient->AddTextureClient(backBuffer)) {
       NS_WARNING("Failed to add tile TextureClient.");
-      aTile.Release();
-      return;
+      aTile.DiscardFrontBuffer();
+      aTile.DiscardBackBuffer();
+      return aTile;
     }
   }
 
   aTile.Flip();
 
   // Note, we don't call UpdatedTexture. The Updated function is called manually
   // by the TiledContentHost before composition.
 
   if (backBuffer->HasInternalBuffer()) {
     // If our new buffer has an internal buffer, we don't want to keep another
     // TextureClient around unnecessarily, so discard the back-buffer.
     aTile.DiscardBackBuffer();
   }
+
+  return aTile;
 }
 
 /**
  * This function takes the transform stored in aTransformToCompBounds
  * (which was generated in GetTransformToAncestorsParentLayer), and
  * modifies it with the ViewTransform from the compositor side so that
  * it reflects what the compositor is actually rendering. This operation
  * basically adds in the layer's async transform.
--- a/gfx/layers/client/TiledContentClient.h
+++ b/gfx/layers/client/TiledContentClient.h
@@ -435,25 +435,25 @@ public:
                          const nsIntRegion& aOldValidRegion,
                          BasicTiledLayerPaintData* aPaintData,
                          LayerManager::DrawPaintedLayerCallback aCallback,
                          void* aCallbackData);
 
   SurfaceDescriptorTiles GetSurfaceDescriptorTiles();
 
 protected:
-  void ValidateTile(TileClient& aTile,
-                    const nsIntPoint& aTileRect,
-                    const nsIntRegion& dirtyRect);
+  TileClient ValidateTile(TileClient aTile,
+                          const nsIntPoint& aTileRect,
+                          const nsIntRegion& dirtyRect);
 
   void PostValidate(const nsIntRegion& aPaintRegion);
 
-  void UnlockTile(TileClient& aTile);
+  void UnlockTile(TileClient aTile);
 
-  void ReleaseTile(TileClient& aTile) { aTile.Release(); }
+  void ReleaseTile(TileClient aTile) { aTile.Release(); }
 
   void SwapTiles(TileClient& aTileA, TileClient& aTileB) { std::swap(aTileA, aTileB); }
 
   TileClient GetPlaceholderTile() const { return TileClient(); }
 
 private:
   gfxContentType GetContentType(SurfaceMode* aMode = nullptr) const;
   ClientTiledPaintedLayer* mPaintedLayer;
--- a/gfx/layers/composite/TiledContentHost.cpp
+++ b/gfx/layers/composite/TiledContentHost.cpp
@@ -163,24 +163,24 @@ TiledLayerBufferComposite::Upload()
     return;
   }
   // The TextureClients were created with the TextureFlags::IMMEDIATE_UPLOAD flag,
   // so calling Update on all the texture hosts will perform the texture upload.
   Update(mValidRegion, mPaintedRegion);
   ClearPaintedRegion();
 }
 
-void
-TiledLayerBufferComposite::ValidateTile(TileHost& aTile,
+TileHost
+TiledLayerBufferComposite::ValidateTile(TileHost aTile,
                                         const nsIntPoint& aTileOrigin,
                                         const nsIntRegion& aDirtyRect)
 {
   if (aTile.IsPlaceholderTile()) {
     NS_WARNING("Placeholder tile encountered in painted region");
-    return;
+    return aTile;
   }
 
 #ifdef GFX_TILEDLAYER_PREF_WARNINGS
   printf_stderr("Upload tile %i, %i\n", aTileOrigin.x, aTileOrigin.y);
   long start = PR_IntervalNow();
 #endif
 
   MOZ_ASSERT(aTile.mTextureHost->GetFlags() & TextureFlags::IMMEDIATE_UPLOAD);
@@ -200,16 +200,17 @@ TiledLayerBufferComposite::ValidateTile(
   }
 #endif
 
 #ifdef GFX_TILEDLAYER_PREF_WARNINGS
   if (PR_IntervalNow() - start > 1) {
     printf_stderr("Tile Time to upload %i\n", PR_IntervalNow() - start);
   }
 #endif
+  return aTile;
 }
 
 void
 TiledLayerBufferComposite::SetCompositor(Compositor* aCompositor)
 {
   if (!IsValid()) {
     return;
   }
--- a/gfx/layers/composite/TiledContentHost.h
+++ b/gfx/layers/composite/TiledContentHost.h
@@ -159,19 +159,19 @@ public:
   virtual void SetReleaseFence(const android::sp<android::Fence>& aReleaseFence);
 #endif
 
   // Recycle callback for TextureHost.
   // Used when TiledContentClient is present in client side.
   static void RecycleCallback(TextureHost* textureHost, void* aClosure);
 
 protected:
-  void ValidateTile(TileHost& aTile,
-                    const nsIntPoint& aTileRect,
-                    const nsIntRegion& dirtyRect);
+  TileHost ValidateTile(TileHost aTile,
+                        const nsIntPoint& aTileRect,
+                        const nsIntRegion& dirtyRect);
 
   // do nothing, the desctructor in the texture host takes care of releasing resources
   void ReleaseTile(TileHost aTile) {}
 
   void SwapTiles(TileHost& aTileA, TileHost& aTileB) { std::swap(aTileA, aTileB); }
 
   void UnlockTile(TileHost aTile) {}
   void PostValidate(const nsIntRegion& aPaintRegion) {}
--- a/gfx/tests/gtest/TestTiledLayerBuffer.cpp
+++ b/gfx/tests/gtest/TestTiledLayerBuffer.cpp
@@ -31,38 +31,38 @@ class TestTiledLayerBuffer : public Tile
 {
   friend class TiledLayerBuffer<TestTiledLayerBuffer, TestTiledLayerTile>;
 
 public:
   TestTiledLayerTile GetPlaceholderTile() const {
     return TestTiledLayerTile(-1);
   }
 
-  void ValidateTile(TestTiledLayerTile& aTile, const nsIntPoint& aTileOrigin, const nsIntRegion& aDirtyRect) {
-    aTile = TestTiledLayerTile();
+  TestTiledLayerTile ValidateTile(TestTiledLayerTile aTile, const nsIntPoint& aTileOrigin, const nsIntRegion& aDirtyRect) {
+    return TestTiledLayerTile();
   }
 
-  void ReleaseTile(TestTiledLayerTile& aTile)
+  void ReleaseTile(TestTiledLayerTile aTile)
   {
 
   }
 
   void SwapTiles(TestTiledLayerTile& aTileA, TestTiledLayerTile& aTileB)
   {
     TestTiledLayerTile oldTileA = aTileA;
     aTileA = aTileB;
     aTileB = oldTileA;
   }
 
   void TestUpdate(const nsIntRegion& aNewValidRegion, const nsIntRegion& aPaintRegion)
   {
     Update(aNewValidRegion, aPaintRegion);
   }
 
-  void UnlockTile(TestTiledLayerTile& aTile) {}
+  void UnlockTile(TestTiledLayerTile aTile) {}
   void PostValidate(const nsIntRegion& aPaintRegion) {}
 };
 
 TEST(TiledLayerBuffer, TileConstructor) {
   gfxPlatform::GetPlatform()->ComputeTileSize();
 
   TestTiledLayerBuffer buffer;
 }
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -6,18 +6,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/MiscEvents.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TextEvents.h"
 #include <algorithm>
 
-#include "GeckoProfiler.h"
-
 #include "prlink.h"
 #include "nsGTKToolkit.h"
 #include "nsIRollupListener.h"
 #include "nsIDOMNode.h"
 
 #include "nsWidgetsCID.h"
 #include "nsDragService.h"
 #include "nsIWidgetListener.h"
@@ -1522,39 +1520,31 @@ nsWindow::GetScreenBounds(nsIntRect &aRe
     // frame bounds, but mBounds.Size() is returned here for consistency
     // with Resize.
     aRect.SizeTo(mBounds.Size());
     LOG(("GetScreenBounds %d,%d | %dx%d\n",
          aRect.x, aRect.y, aRect.width, aRect.height));
     return NS_OK;
 }
 
-gfx::IntSize
-nsWindow::GetClientSize()
-{
-  return gfx::IntSize(mBounds.width, mBounds.height);
-}
-
 NS_IMETHODIMP
 nsWindow::GetClientBounds(nsIntRect &aRect)
 {
     // GetBounds returns a rect whose top left represents the top left of the
     // outer bounds, but whose width/height represent the size of the inner
     // bounds (which is messed up).
     GetBounds(aRect);
     aRect.MoveBy(GetClientOffset());
 
     return NS_OK;
 }
 
 nsIntPoint
 nsWindow::GetClientOffset()
 {
-    PROFILER_LABEL("nsWindow", "GetClientOffset", js::ProfileEntry::Category::GRAPHICS);
-
     if (!mIsTopLevel) {
         return nsIntPoint(0, 0);
     }
 
     GdkAtom cardinal_atom = gdk_x11_xatom_to_atom(XA_CARDINAL);
 
     GdkAtom type_returned;
     int format_returned;
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -122,17 +122,16 @@ public:
                                    nsIWidget                  *aWidget,
                                    bool                        aActivate) MOZ_OVERRIDE;
     void               SetZIndex(int32_t aZIndex) MOZ_OVERRIDE;
     NS_IMETHOD         SetSizeMode(int32_t aMode) MOZ_OVERRIDE;
     NS_IMETHOD         Enable(bool aState) MOZ_OVERRIDE;
     NS_IMETHOD         SetFocus(bool aRaise = false) MOZ_OVERRIDE;
     NS_IMETHOD         GetScreenBounds(nsIntRect &aRect) MOZ_OVERRIDE;
     NS_IMETHOD         GetClientBounds(nsIntRect &aRect) MOZ_OVERRIDE;
-    virtual gfx::IntSize GetClientSize() MOZ_OVERRIDE;
     virtual nsIntPoint GetClientOffset() MOZ_OVERRIDE;
     NS_IMETHOD         SetCursor(nsCursor aCursor) MOZ_OVERRIDE;
     NS_IMETHOD         SetCursor(imgIContainer* aCursor,
                                  uint32_t aHotspotX, uint32_t aHotspotY) MOZ_OVERRIDE;
     NS_IMETHOD         Invalidate(const nsIntRect &aRect) MOZ_OVERRIDE;
     virtual void*      GetNativeData(uint32_t aDataType) MOZ_OVERRIDE;
     void               SetNativeData(uint32_t aDataType, uintptr_t aVal) MOZ_OVERRIDE;
     NS_IMETHOD         SetTitle(const nsAString& aTitle) MOZ_OVERRIDE;
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -18,17 +18,16 @@
 #include "nsITheme.h"
 #include "nsITimer.h"
 #include "nsXULAppAPI.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/layers/LayersTypes.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/TimeStamp.h"
 #include "Units.h"
-#include "mozilla/gfx/Point.h"
 
 // forward declarations
 class   nsFontMetrics;
 class   nsDeviceContext;
 struct  nsFont;
 class   nsIRollupListener;
 class   imgIContainer;
 class   nsIContent;
@@ -1272,28 +1271,16 @@ class nsIWidget : public nsISupports {
     /**
      * Get the client offset from the window origin.
      *
      * @return the x and y of the offset.
      *
      */
     virtual nsIntPoint GetClientOffset() = 0;
 
-
-    /**
-     * Equivalent to GetClientBounds but only returns the size.
-     */
-    virtual mozilla::gfx::IntSize GetClientSize() {
-      // Dependeing on the backend, overloading this method may be useful if
-      // if requesting the client offset is expensive.
-      nsIntRect rect;
-      GetClientBounds(rect);
-      return mozilla::gfx::IntSize(rect.width, rect.height);
-    }
-
     /**
      * Set the background color for this widget
      *
      * @param aColor the new background color
      *
      */
 
     virtual void SetBackgroundColor(const nscolor &aColor) { }