Backed out 3 changesets (bug 1105834) for non-unified bustage
authorWes Kocher <wkocher@mozilla.com>
Mon, 08 Dec 2014 17:15:46 -0800
changeset 244609 f2bd10f0159c8c88c63fa8ca08f59e68ed4afea7
parent 244608 7ed611fb2797f42c63d879e6f3cf24d729196a8b
child 244610 8c25427adcac6126ddb63662ae451c0e352312ca
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1105834
milestone37.0a1
backs out33592fd41f1f77c7917f7e8bac5c03dd37e26e79
c3e505887e9fdbd4ceda38eee644f3f028052bea
6aad17f431d1cd199981304464146b29fd75b1ac
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 3 changesets (bug 1105834) for non-unified bustage Backed out changeset 33592fd41f1f (bug 1105834) Backed out changeset c3e505887e9f (bug 1105834) Backed out changeset 6aad17f431d1 (bug 1105834)
gfx/2d/DataSurfaceHelpers.cpp
gfx/2d/DataSurfaceHelpers.h
gfx/2d/FilterNodeSoftware.cpp
gfx/2d/Rect.h
gfx/layers/LayersLogging.cpp
gfx/layers/composite/CompositableHost.cpp
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/TiledContentHost.cpp
gfx/layers/opengl/GrallocTextureHost.cpp
gfx/thebes/gfxPrefs.h
gfx/thebes/gfxUtils.cpp
gfx/thebes/gfxUtils.h
modules/libpref/init/all.js
--- a/gfx/2d/DataSurfaceHelpers.cpp
+++ b/gfx/2d/DataSurfaceHelpers.cpp
@@ -4,51 +4,21 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <cstring>
 
 #include "2D.h"
 #include "DataSurfaceHelpers.h"
 #include "Logging.h"
 #include "mozilla/MathAlgorithms.h"
-#include "mozilla/PodOperations.h"
 #include "Tools.h"
 
 namespace mozilla {
 namespace gfx {
 
-uint8_t*
-DataAtOffset(DataSourceSurface* aSurface, IntPoint aPoint)
-{
-  if (!SurfaceContainsPoint(aSurface, aPoint)) {
-    MOZ_CRASH("sample position needs to be inside surface!");
-  }
-
-  MOZ_ASSERT(Factory::CheckSurfaceSize(aSurface->GetSize()),
-             "surface size overflows - this should have been prevented when the surface was created");
-
-  uint8_t* data = aSurface->GetData() + aPoint.y * aSurface->Stride() +
-    aPoint.x * BytesPerPixel(aSurface->GetFormat());
-
-  if (data < aSurface->GetData()) {
-    MOZ_CRASH("out-of-range data access");
-  }
-
-  return data;
-}
-
-// This check is safe against integer overflow.
-bool
-SurfaceContainsPoint(SourceSurface* aSurface, const IntPoint& aPoint)
-{
-  IntSize size = aSurface->GetSize();
-  return aPoint.x >= 0 && aPoint.x < size.width &&
-         aPoint.y >= 0 && aPoint.y < size.height;
-}
-
 void
 ConvertBGRXToBGRA(uint8_t* aData, const IntSize &aSize, int32_t aStride)
 {
   uint32_t* pixel = reinterpret_cast<uint32_t*>(aData);
 
   for (int row = 0; row < aSize.height; ++row) {
     for (int column = 0; column < aSize.width; ++column) {
 #ifdef IS_BIG_ENDIAN
@@ -221,62 +191,10 @@ BufferSizeFromStrideAndHeight(int32_t aS
     CheckedInt32(aStride) * CheckedInt32(aHeight) + CheckedInt32(aExtraBytes);
   if (MOZ_UNLIKELY(!requiredBytes.isValid())) {
     gfxWarning() << "Buffer size too big; returning zero";
     return 0;
   }
   return requiredBytes.value();
 }
 
-/**
- * aSrcRect: Rect relative to the aSrc surface
- * aDestPoint: Point inside aDest surface
- */
-void
-CopyRect(DataSourceSurface* aSrc, DataSourceSurface* aDest,
-         IntRect aSrcRect, IntPoint aDestPoint)
-{
-  if (aSrcRect.Overflows() ||
-      IntRect(aDestPoint, aSrcRect.Size()).Overflows()) {
-    MOZ_CRASH("we should never be getting invalid rects at this point");
-  }
-
-  MOZ_ASSERT(aSrc->GetFormat() == aDest->GetFormat(), "different surface formats");
-  MOZ_ASSERT(IntRect(IntPoint(), aSrc->GetSize()).Contains(aSrcRect), "source rect too big for source surface");
-  MOZ_ASSERT(IntRect(IntPoint(), aDest->GetSize()).Contains(aSrcRect - aSrcRect.TopLeft() + aDestPoint), "dest surface too small");
-
-  if (aSrcRect.IsEmpty()) {
-    return;
-  }
-
-  uint8_t* sourceData = DataAtOffset(aSrc, aSrcRect.TopLeft());
-  uint32_t sourceStride = aSrc->Stride();
-  uint8_t* destData = DataAtOffset(aDest, aDestPoint);
-  uint32_t destStride = aDest->Stride();
-
-  if (BytesPerPixel(aSrc->GetFormat()) == 4) {
-    for (int32_t y = 0; y < aSrcRect.height; y++) {
-      PodCopy((int32_t*)destData, (int32_t*)sourceData, aSrcRect.width);
-      sourceData += sourceStride;
-      destData += destStride;
-    }
-  } else if (BytesPerPixel(aSrc->GetFormat()) == 1) {
-    for (int32_t y = 0; y < aSrcRect.height; y++) {
-      PodCopy(destData, sourceData, aSrcRect.width);
-      sourceData += sourceStride;
-      destData += destStride;
-    }
-  }
-}
-
-TemporaryRef<DataSourceSurface>
-CreateDataSourceSurfaceByCloning(DataSourceSurface* aSource)
-{
-  RefPtr<DataSourceSurface> copy =
-    Factory::CreateDataSourceSurface(aSource->GetSize(), aSource->GetFormat());
-  if (copy) {
-    CopyRect(aSource, copy, IntRect(IntPoint(), aSource->GetSize()), IntPoint());
-  }
-  return copy.forget();
-}
-
 }
 }
--- a/gfx/2d/DataSurfaceHelpers.h
+++ b/gfx/2d/DataSurfaceHelpers.h
@@ -65,42 +65,12 @@ ClearDataSourceSurface(DataSourceSurface
  *
  * @return The result of the multiplication if it is acceptable, or else zero.
  */
 size_t
 BufferSizeFromStrideAndHeight(int32_t aStride,
                               int32_t aHeight,
                               int32_t aExtraBytes = 0);
 
-/**
- * Copy aSrcRect from aSrc to aDest starting at aDestPoint.
- */
-void
-CopyRect(DataSourceSurface* aSrc, DataSourceSurface* aDest,
-         IntRect aSrcRect, IntPoint aDestPoint);
-
-/**
- * Create a non aliasing copy of aSource. This creates a new DataSourceSurface
- * using the factory and copies the bits.
- *
- * @return a dss allocated by Factory that contains a copy a aSource.
- */
-TemporaryRef<DataSourceSurface>
-CreateDataSourceSurfaceByCloning(DataSourceSurface* aSource);
-
-/**
- * Return the byte at aPoint.
- */
-uint8_t*
-DataAtOffset(DataSourceSurface* aSurface, IntPoint aPoint);
-
-/**
- * Check if aPoint is contained by the surface.
- *
- * @returns true if and only if aPoint is inside the surface.
- */
-bool
-SurfaceContainsPoint(SourceSurface* aSurface, const IntPoint& aPoint);
-
 }
 }
 
 #endif // _MOZILLA_GFX_DATASURFACEHELPERS_H
--- a/gfx/2d/FilterNodeSoftware.cpp
+++ b/gfx/2d/FilterNodeSoftware.cpp
@@ -175,26 +175,111 @@ private:
 
 // from xpcom/ds/nsMathUtils.h
 static int32_t
 NS_lround(double x)
 {
   return x >= 0.0 ? int32_t(x + 0.5) : int32_t(x - 0.5);
 }
 
+// This check is safe against integer overflow.
+static bool
+SurfaceContainsPoint(SourceSurface* aSurface, const IntPoint& aPoint)
+{
+  IntSize size = aSurface->GetSize();
+  return aPoint.x >= 0 && aPoint.x < size.width &&
+         aPoint.y >= 0 && aPoint.y < size.height;
+}
+
+static uint8_t*
+DataAtOffset(DataSourceSurface* aSurface, IntPoint aPoint)
+{
+  if (!SurfaceContainsPoint(aSurface, aPoint)) {
+    MOZ_CRASH("sample position needs to be inside surface!");
+  }
+
+  MOZ_ASSERT(Factory::CheckSurfaceSize(aSurface->GetSize()),
+             "surface size overflows - this should have been prevented when the surface was created");
+
+  uint8_t* data = aSurface->GetData() + aPoint.y * aSurface->Stride() +
+    aPoint.x * BytesPerPixel(aSurface->GetFormat());
+
+  if (data < aSurface->GetData()) {
+    MOZ_CRASH("out-of-range data access");
+  }
+
+  return data;
+}
+
+static bool
+IntRectOverflows(const IntRect& aRect)
+{
+  CheckedInt<int32_t> xMost = aRect.x;
+  xMost += aRect.width;
+  CheckedInt<int32_t> yMost = aRect.y;
+  yMost += aRect.height;
+  return !xMost.isValid() || !yMost.isValid();
+}
+
+/**
+ * aSrcRect: Rect relative to the aSrc surface
+ * aDestPoint: Point inside aDest surface
+ */
+static void
+CopyRect(DataSourceSurface* aSrc, DataSourceSurface* aDest,
+         IntRect aSrcRect, IntPoint aDestPoint)
+{
+  if (IntRectOverflows(aSrcRect) ||
+      IntRectOverflows(IntRect(aDestPoint, aSrcRect.Size()))) {
+    MOZ_CRASH("we should never be getting invalid rects at this point");
+  }
+
+  MOZ_ASSERT(aSrc->GetFormat() == aDest->GetFormat(), "different surface formats");
+  MOZ_ASSERT(IntRect(IntPoint(), aSrc->GetSize()).Contains(aSrcRect), "source rect too big for source surface");
+  MOZ_ASSERT(IntRect(IntPoint(), aDest->GetSize()).Contains(aSrcRect - aSrcRect.TopLeft() + aDestPoint), "dest surface too small");
+
+  if (aSrcRect.IsEmpty()) {
+    return;
+  }
+
+  uint8_t* sourceData = DataAtOffset(aSrc, aSrcRect.TopLeft());
+  uint32_t sourceStride = aSrc->Stride();
+  uint8_t* destData = DataAtOffset(aDest, aDestPoint);
+  uint32_t destStride = aDest->Stride();
+
+  if (BytesPerPixel(aSrc->GetFormat()) == 4) {
+    for (int32_t y = 0; y < aSrcRect.height; y++) {
+      PodCopy((int32_t*)destData, (int32_t*)sourceData, aSrcRect.width);
+      sourceData += sourceStride;
+      destData += destStride;
+    }
+  } else if (BytesPerPixel(aSrc->GetFormat()) == 1) {
+    for (int32_t y = 0; y < aSrcRect.height; y++) {
+      PodCopy(destData, sourceData, aSrcRect.width);
+      sourceData += sourceStride;
+      destData += destStride;
+    }
+  }
+}
+
 TemporaryRef<DataSourceSurface>
 CloneAligned(DataSourceSurface* aSource)
 {
-  return CreateDataSourceSurfaceByCloning(aSource);
+  RefPtr<DataSourceSurface> copy =
+    Factory::CreateDataSourceSurface(aSource->GetSize(), aSource->GetFormat());
+  if (copy) {
+    CopyRect(aSource, copy, IntRect(IntPoint(), aSource->GetSize()), IntPoint());
+  }
+  return copy.forget();
 }
 
 static void
 FillRectWithPixel(DataSourceSurface *aSurface, const IntRect &aFillRect, IntPoint aPixelPos)
 {
-  MOZ_ASSERT(!aFillRect.Overflows());
+  MOZ_ASSERT(!IntRectOverflows(aFillRect));
   MOZ_ASSERT(IntRect(IntPoint(), aSurface->GetSize()).Contains(aFillRect),
              "aFillRect needs to be completely inside the surface");
   MOZ_ASSERT(SurfaceContainsPoint(aSurface, aPixelPos),
              "aPixelPos needs to be inside the surface");
 
   int32_t stride = aSurface->Stride();
   uint8_t* sourcePixelData = DataAtOffset(aSurface, aPixelPos);
   uint8_t* data = DataAtOffset(aSurface, aFillRect.TopLeft());
@@ -217,18 +302,18 @@ FillRectWithPixel(DataSourceSurface *aSu
   }
 }
 
 static void
 FillRectWithVerticallyRepeatingHorizontalStrip(DataSourceSurface *aSurface,
                                                const IntRect &aFillRect,
                                                const IntRect &aSampleRect)
 {
-  MOZ_ASSERT(!aFillRect.Overflows());
-  MOZ_ASSERT(!aSampleRect.Overflows());
+  MOZ_ASSERT(!IntRectOverflows(aFillRect));
+  MOZ_ASSERT(!IntRectOverflows(aSampleRect));
   MOZ_ASSERT(IntRect(IntPoint(), aSurface->GetSize()).Contains(aFillRect),
              "aFillRect needs to be completely inside the surface");
   MOZ_ASSERT(IntRect(IntPoint(), aSurface->GetSize()).Contains(aSampleRect),
              "aSampleRect needs to be completely inside the surface");
 
   int32_t stride = aSurface->Stride();
   uint8_t* sampleData = DataAtOffset(aSurface, aSampleRect.TopLeft());
   uint8_t* data = DataAtOffset(aSurface, aFillRect.TopLeft());
@@ -245,18 +330,18 @@ FillRectWithVerticallyRepeatingHorizonta
   }
 }
 
 static void
 FillRectWithHorizontallyRepeatingVerticalStrip(DataSourceSurface *aSurface,
                                                const IntRect &aFillRect,
                                                const IntRect &aSampleRect)
 {
-  MOZ_ASSERT(!aFillRect.Overflows());
-  MOZ_ASSERT(!aSampleRect.Overflows());
+  MOZ_ASSERT(!IntRectOverflows(aFillRect));
+  MOZ_ASSERT(!IntRectOverflows(aSampleRect));
   MOZ_ASSERT(IntRect(IntPoint(), aSurface->GetSize()).Contains(aFillRect),
              "aFillRect needs to be completely inside the surface");
   MOZ_ASSERT(IntRect(IntPoint(), aSurface->GetSize()).Contains(aSampleRect),
              "aSampleRect needs to be completely inside the surface");
 
   int32_t stride = aSurface->Stride();
   uint8_t* sampleData = DataAtOffset(aSurface, aSampleRect.TopLeft());
   uint8_t* data = DataAtOffset(aSurface, aFillRect.TopLeft());
@@ -277,17 +362,17 @@ FillRectWithHorizontallyRepeatingVertica
       sampleData += stride;
     }
   }
 }
 
 static void
 DuplicateEdges(DataSourceSurface* aSurface, const IntRect &aFromRect)
 {
-  MOZ_ASSERT(!aFromRect.Overflows());
+  MOZ_ASSERT(!IntRectOverflows(aFromRect));
   MOZ_ASSERT(IntRect(IntPoint(), aSurface->GetSize()).Contains(aFromRect),
              "aFromRect needs to be completely inside the surface");
 
   IntSize size = aSurface->GetSize();
   IntRect fill;
   IntRect sampleRect;
   for (int32_t ix = 0; ix < 3; ix++) {
     switch (ix) {
@@ -385,17 +470,17 @@ TileSurface(DataSourceSurface* aSource, 
 static TemporaryRef<DataSourceSurface>
 GetDataSurfaceInRect(SourceSurface *aSurface,
                      const IntRect &aSurfaceRect,
                      const IntRect &aDestRect,
                      ConvolveMatrixEdgeMode aEdgeMode)
 {
   MOZ_ASSERT(aSurface ? aSurfaceRect.Size() == aSurface->GetSize() : aSurfaceRect.IsEmpty());
 
-  if (aSurfaceRect.Overflows() || aDestRect.Overflows()) {
+  if (IntRectOverflows(aSurfaceRect) || IntRectOverflows(aDestRect)) {
     // We can't rely on the intersection calculations below to make sense when
     // XMost() or YMost() overflow. Bail out.
     return nullptr;
   }
 
   IntRect sourceRect = aSurfaceRect;
 
   if (sourceRect.IsEqualEdges(aDestRect)) {
@@ -540,17 +625,17 @@ FilterNodeSoftware::Draw(DrawTarget* aDr
 #ifdef DEBUG_DUMP_SURFACES
     printf("render rect overflowed, not painting anything\n");
     printf("</pre>\n");
 #endif
     return;
   }
 
   IntRect outputRect = GetOutputRectInRect(renderIntRect);
-  if (outputRect.Overflows()) {
+  if (IntRectOverflows(outputRect)) {
 #ifdef DEBUG_DUMP_SURFACES
     printf("output rect overflowed, not painting anything\n");
     printf("</pre>\n");
 #endif
     return;
   }
 
   RefPtr<DataSourceSurface> result;
@@ -591,17 +676,17 @@ FilterNodeSoftware::Draw(DrawTarget* aDr
   }
 }
 
 TemporaryRef<DataSourceSurface>
 FilterNodeSoftware::GetOutput(const IntRect &aRect)
 {
   MOZ_ASSERT(GetOutputRectInRect(aRect).Contains(aRect));
 
-  if (aRect.Overflows()) {
+  if (IntRectOverflows(aRect)) {
     return nullptr;
   }
 
   if (!mCachedRect.Contains(aRect)) {
     RequestRect(aRect);
     mCachedOutput = Render(mRequestedRect);
     if (!mCachedOutput) {
       mCachedRect = IntRect();
@@ -621,17 +706,17 @@ FilterNodeSoftware::RequestRect(const In
 {
   mRequestedRect = mRequestedRect.Union(aRect);
   RequestFromInputsForRect(aRect);
 }
 
 void
 FilterNodeSoftware::RequestInputRect(uint32_t aInputEnumIndex, const IntRect &aRect)
 {
-  if (aRect.Overflows()) {
+  if (IntRectOverflows(aRect)) {
     return;
   }
 
   int32_t inputIndex = InputIndex(aInputEnumIndex);
   if (inputIndex < 0 || (uint32_t)inputIndex >= NumberOfSetInputs()) {
     MOZ_CRASH();
   }
   if (mInputSurfaces[inputIndex]) {
@@ -654,17 +739,17 @@ FilterNodeSoftware::DesiredFormat(Surfac
 
 TemporaryRef<DataSourceSurface>
 FilterNodeSoftware::GetInputDataSourceSurface(uint32_t aInputEnumIndex,
                                               const IntRect& aRect,
                                               FormatHint aFormatHint,
                                               ConvolveMatrixEdgeMode aEdgeMode,
                                               const IntRect *aTransparencyPaddedSourceRect)
 {
-  if (aRect.Overflows()) {
+  if (IntRectOverflows(aRect)) {
     return nullptr;
   }
 
 #ifdef DEBUG_DUMP_SURFACES
   printf("<section><h1>GetInputDataSourceSurface with aRect: %d, %d, %d, %d</h1>\n",
          aRect.x, aRect.y, aRect.width, aRect.height);
 #endif
   int32_t inputIndex = InputIndex(aInputEnumIndex);
@@ -769,17 +854,17 @@ FilterNodeSoftware::GetInputDataSourceSu
 
   return result.forget();
 }
 
 IntRect
 FilterNodeSoftware::GetInputRectInRect(uint32_t aInputEnumIndex,
                                        const IntRect &aInRect)
 {
-  if (aInRect.Overflows()) {
+  if (IntRectOverflows(aInRect)) {
     return IntRect();
   }
 
   int32_t inputIndex = InputIndex(aInputEnumIndex);
   if (inputIndex < 0 || (uint32_t)inputIndex >= NumberOfSetInputs()) {
     MOZ_CRASH();
     return IntRect();
   }
--- a/gfx/2d/Rect.h
+++ b/gfx/2d/Rect.h
@@ -86,24 +86,16 @@ struct IntRectTyped :
 
     static IntRectTyped<units> FromUnknownRect(const IntRectTyped<UnknownUnits>& rect) {
         return IntRectTyped<units>(rect.x, rect.y, rect.width, rect.height);
     }
 
     IntRectTyped<UnknownUnits> ToUnknownRect() const {
         return IntRectTyped<UnknownUnits>(this->x, this->y, this->width, this->height);
     }
-
-    bool Overflows() const {
-      CheckedInt<int32_t> xMost = this->x;
-      xMost += this->width;
-      CheckedInt<int32_t> yMost = this->y;
-      yMost += this->height;
-      return !xMost.isValid() || !yMost.isValid();
-    }
 };
 typedef IntRectTyped<UnknownUnits> IntRect;
 
 template<class units>
 struct RectTyped :
     public BaseRect<Float, RectTyped<units>, PointTyped<units>, SizeTyped<units>, MarginTyped<units> >,
     public units {
     static_assert(IsPixel<units>::value,
--- a/gfx/layers/LayersLogging.cpp
+++ b/gfx/layers/LayersLogging.cpp
@@ -322,19 +322,27 @@ AppendToString(std::stringstream& aStrea
 void
 print_stderr(std::stringstream& aStr)
 {
 #if defined(ANDROID)
   // On Android logcat output is truncated to 1024 chars per line, and
   // we usually use std::stringstream to build up giant multi-line gobs
   // of output. So to avoid the truncation we find the newlines and
   // print the lines individually.
-  std::string line;
-  while (std::getline(aStr, line)) {
-    printf_stderr("%s\n", line.c_str());
+  char line[1024];
+  while (!aStr.eof()) {
+    aStr.getline(line, sizeof(line));
+    if (!aStr.eof() || strlen(line) > 0) {
+      printf_stderr("%s\n", line);
+    }
+    if (aStr.fail()) {
+      // line was too long, skip to next newline
+      aStr.clear();
+      aStr.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
+    }
   }
 #else
   printf_stderr("%s", aStr.str().c_str());
 #endif
 }
 
 void
 fprint_stderr(FILE* aFile, std::stringstream& aStr)
--- a/gfx/layers/composite/CompositableHost.cpp
+++ b/gfx/layers/composite/CompositableHost.cpp
@@ -213,17 +213,23 @@ CompositableHost::DumpTextureHost(std::s
 {
   if (!aTexture) {
     return;
   }
   RefPtr<gfx::DataSourceSurface> dSurf = aTexture->GetAsSurface();
   if (!dSurf) {
     return;
   }
-  aStream << gfxUtils::GetAsLZ4Base64Str(dSurf).get();
+  gfxPlatform *platform = gfxPlatform::GetPlatform();
+  RefPtr<gfx::DrawTarget> dt = platform->CreateDrawTargetForData(dSurf->GetData(),
+                                                                 dSurf->GetSize(),
+                                                                 dSurf->Stride(),
+                                                                 dSurf->GetFormat());
+  // TODO stream surface
+  gfxUtils::DumpAsDataURI(dt, stderr);
 }
 #endif
 
 namespace CompositableMap {
 
 typedef std::map<uint64_t, PCompositableParent*> CompositableMap_t;
 static CompositableMap_t* sCompositableMap = nullptr;
 bool IsCreated() {
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -22,17 +22,16 @@
 #include "nsPrintfCString.h"            // for nsPrintfCString
 #include "mozilla/layers/PTextureParent.h"
 #include "mozilla/unused.h"
 #include <limits>
 #include "SharedSurface.h"
 #include "SharedSurfaceEGL.h"
 #include "SharedSurfaceGL.h"
 #include "../opengl/CompositorOGL.h"
-#include "gfxUtils.h"
 
 #ifdef MOZ_ENABLE_D3D10_LAYER
 #include "../d3d11/CompositorD3D11.h"
 #endif
 
 #ifdef MOZ_WIDGET_GONK
 #include "../opengl/GrallocTextureClient.h"
 #include "../opengl/GrallocTextureHost.h"
@@ -322,28 +321,16 @@ TextureHost::PrintInfo(std::stringstream
   // Note: the TextureHost needs to be locked before it is safe to call
   //       GetSize() and GetFormat() on it.
   if (Lock()) {
     AppendToString(aStream, GetSize(), " [size=", "]");
     AppendToString(aStream, GetFormat(), " [format=", "]");
     Unlock();
   }
   AppendToString(aStream, mFlags, " [flags=", "]");
-#ifdef MOZ_DUMP_PAINTING
-  if (gfxPrefs::LayersDumpTexture()) {
-    nsAutoCString pfx(aPrefix);
-    pfx += "  ";
-
-    aStream << "\n" << pfx.get() << "Surface: ";
-    RefPtr<gfx::DataSourceSurface> dSurf = GetAsSurface();
-    if (dSurf) {
-      aStream << gfxUtils::GetAsLZ4Base64Str(dSurf).get();
-    }
-  }
-#endif
 }
 
 TextureSource::TextureSource()
 : mCompositableCount(0)
 {
     MOZ_COUNT_CTOR(TextureSource);
 }
 
--- a/gfx/layers/composite/TiledContentHost.cpp
+++ b/gfx/layers/composite/TiledContentHost.cpp
@@ -601,61 +601,40 @@ TiledContentHost::RenderLayerBuffer(Tile
 }
 
 void
 TiledContentHost::PrintInfo(std::stringstream& aStream, const char* aPrefix)
 {
   aStream << aPrefix;
   aStream << nsPrintfCString("TiledContentHost (0x%p)", this).get();
 
-#ifdef MOZ_DUMP_PAINTING
-  if (gfxPrefs::LayersDumpTexture()) {
-    nsAutoCString pfx(aPrefix);
-    pfx += "  ";
-
-    Dump(aStream, pfx.get(), false);
-  }
-#endif
 }
 
 #ifdef MOZ_DUMP_PAINTING
 void
 TiledContentHost::Dump(std::stringstream& aStream,
                        const char* aPrefix,
                        bool aDumpHtml)
 {
-  nsIntRect visibleRect = mTiledBuffer.GetValidRegion().GetBounds();
-  gfx::IntSize scaledTileSize = mTiledBuffer.GetScaledTileSize();
-  for (int32_t x = visibleRect.x; x < visibleRect.x + visibleRect.width;) {
-    int32_t tileStartX = mTiledBuffer.GetTileStart(x, scaledTileSize.width);
-    int32_t w = scaledTileSize.width - tileStartX;
-    if (x + w > visibleRect.x + visibleRect.width) {
-      w = visibleRect.x + visibleRect.width - x;
+  TiledLayerBufferComposite::Iterator it = mTiledBuffer.TilesBegin();
+  TiledLayerBufferComposite::Iterator stop = mTiledBuffer.TilesEnd();
+  if (aDumpHtml) {
+    aStream << "<ul>";
+  }
+  for (;it != stop; ++it) {
+    aStream << aPrefix;
+    aStream << (aDumpHtml ? "<li> <a href=" : "Tile ");
+    if (it->IsPlaceholderTile()) {
+      aStream << "empty tile";
+    } else {
+      DumpTextureHost(aStream, it->mTextureHost);
+      DumpTextureHost(aStream, it->mTextureHostOnWhite);
     }
-
-    for (int32_t y = visibleRect.y; y < visibleRect.y + visibleRect.height;) {
-      int32_t tileStartY = mTiledBuffer.GetTileStart(y, scaledTileSize.height);
-      TileHost tileTexture = mTiledBuffer.
-        GetTile(nsIntPoint(mTiledBuffer.RoundDownToTileEdge(x, scaledTileSize.width),
-                           mTiledBuffer.RoundDownToTileEdge(y, scaledTileSize.height)));
-      int32_t h = scaledTileSize.height - tileStartY;
-      if (y + h > visibleRect.y + visibleRect.height) {
-        h = visibleRect.y + visibleRect.height - y;
-      }
-
-      aStream << "\n" << aPrefix << "Tile (x=" <<
-        mTiledBuffer.RoundDownToTileEdge(x, scaledTileSize.width) << ", y=" <<
-        mTiledBuffer.RoundDownToTileEdge(y, scaledTileSize.height) << "): ";
-      if (tileTexture != mTiledBuffer.GetPlaceholderTile()) {
-        DumpTextureHost(aStream, tileTexture.mTextureHost);
-        // TODO We should combine the OnWhite/OnBlack here an just output a single image.
-      } else {
-        aStream << "empty tile";
-      }
-      y += h;
-    }
-    x += w;
+    aStream << (aDumpHtml ? " >Tile</a></li>" : " ");
+  }
+  if (aDumpHtml) {
+    aStream << "</ul>";
   }
 }
 #endif
 
 } // namespace
 } // namespace
--- a/gfx/layers/opengl/GrallocTextureHost.cpp
+++ b/gfx/layers/opengl/GrallocTextureHost.cpp
@@ -3,17 +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/. */
 
 #include "base/process.h"
 #include "GLContext.h"
 #include "gfx2DGlue.h"
 #include <ui/GraphicBuffer.h>
 #include "GrallocImages.h"  // for GrallocImage
-#include "mozilla/gfx/DataSurfaceHelpers.h"
 #include "mozilla/layers/GrallocTextureHost.h"
 #include "mozilla/layers/SharedBufferManagerParent.h"
 #include "EGLImageHelpers.h"
 #include "GLReadTexImageHelper.h"
 
 namespace mozilla {
 namespace layers {
 
@@ -381,55 +380,39 @@ GrallocTextureHostOGL::GetRenderState()
                             this);
   }
 
   return LayerRenderState();
 }
 
 TemporaryRef<gfx::DataSourceSurface>
 GrallocTextureHostOGL::GetAsSurface() {
-  if (mTilingTextureSource) {
-    return mTilingTextureSource->GetAsSurface();
-  } else {
-    android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
-    uint8_t* grallocData;
-    int32_t rv = graphicBuffer->lock(GRALLOC_USAGE_SW_READ_OFTEN, reinterpret_cast<void**>(&grallocData));
-    RefPtr<gfx::DataSourceSurface> grallocTempSurf =
-      Factory::CreateWrappingDataSourceSurface(grallocData,
-                                               graphicBuffer->getStride() * android::bytesPerPixel(graphicBuffer->getPixelFormat()),
-                                               GetSize(), GetFormat());
-    RefPtr<gfx::DataSourceSurface> surf = CreateDataSourceSurfaceByCloning(grallocTempSurf);
-
-    graphicBuffer->unlock();
-
-    return surf.forget();
-  }
+  return mTilingTextureSource ? mTilingTextureSource->GetAsSurface()
+                              : nullptr;
 }
 
 TemporaryRef<gfx::DataSourceSurface>
 GrallocTextureSourceOGL::GetAsSurface() {
-  if (!IsValid()) {
-    return nullptr;
-  }
-
-  uint8_t* grallocData;
-  int32_t rv = mGraphicBuffer->lock(GRALLOC_USAGE_SW_READ_OFTEN, reinterpret_cast<void**>(&grallocData));
-  if (rv) {
+  if (!IsValid() || !gl()->MakeCurrent()) {
     return nullptr;
   }
 
-  RefPtr<gfx::DataSourceSurface> grallocTempSurf =
-    Factory::CreateWrappingDataSourceSurface(grallocData,
-                                             mGraphicBuffer->getStride() * android::bytesPerPixel(mGraphicBuffer->getPixelFormat()),
-                                             GetSize(), GetFormat());
+  GLuint tex = GetGLTexture();
+  gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
+  gl()->fBindTexture(GetTextureTarget(), tex);
+  if (!mEGLImage) {
+    mEGLImage = EGLImageCreateFromNativeBuffer(gl(), mGraphicBuffer->getNativeBuffer());
+  }
+  BindEGLImage();
 
-  RefPtr<gfx::DataSourceSurface> surf = CreateDataSourceSurfaceByCloning(grallocTempSurf);
+  RefPtr<gfx::DataSourceSurface> surf =
+    IsValid() ? ReadBackSurface(gl(), tex, false, GetFormat())
+              : nullptr;
 
-  mGraphicBuffer->unlock();
-
+  gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
   return surf.forget();
 }
 
 GLuint
 GrallocTextureSourceOGL::GetGLTexture()
 {
   return mTexture;
 }
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -265,17 +265,16 @@ private:
   DECL_GFX_PREF(Once, "layers.componentalpha.enabled",         ComponentAlphaEnabled, bool, true);
 #endif
   DECL_GFX_PREF(Live, "layers.draw-bigimage-borders",          DrawBigImageBorders, bool, false);
   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(Live, "layers.dump",                           LayersDump, bool, false);
-  DECL_GFX_PREF(Live, "layers.dump-texture",                   LayersDumpTexture, bool, false);
 
   // 0 is "no change" for contrast, positive values increase it, negative values
   // decrease it until we hit mid gray at -1 contrast, after that it gets weird.
   DECL_GFX_PREF(Live, "layers.effect.contrast",                LayersEffectContrast, float, 0.0f);
   DECL_GFX_PREF(Live, "layers.effect.grayscale",               LayersEffectGrayscale, bool, false);
   DECL_GFX_PREF(Live, "layers.effect.invert",                  LayersEffectInvert, bool, false);
 
   DECL_GFX_PREF(Once, "layers.enable-tiles",                   LayersTilesEnabledDoNotUseDirectly, bool, false);
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -38,20 +38,16 @@
 
 using namespace mozilla;
 using namespace mozilla::image;
 using namespace mozilla::layers;
 using namespace mozilla::gfx;
 
 #include "DeprecatedPremultiplyTables.h"
 
-#undef compress
-#include "mozilla/Compression.h"
-
-using namespace mozilla::Compression;
 extern "C" {
 
 /**
  * Dump a raw image to the default log.  This function is exported
  * from libxul, so it can be called from any library in addition to
  * (of course) from a debugger.
  *
  * Note: this helper currently assumes that all 2-bytepp images are
@@ -1109,39 +1105,38 @@ gfxUtils::GetColorForFrameNumber(uint64_
         colors[i++] = gfx::Color::FromABGR(0xff999999);
         MOZ_ASSERT(i == sNumFrameColors);
         initialized = true;
     }
 
     return colors[aFrameNumber % sNumFrameColors];
 }
 
-static nsresult
-EncodeSourceSurfaceInternal(SourceSurface* aSurface,
-                           const nsACString& aMimeType,
-                           const nsAString& aOutputOptions,
-                           gfxUtils::BinaryOrData aBinaryOrData,
-                           FILE* aFile,
-                           nsCString* aStrOut)
+/* static */ nsresult
+gfxUtils::EncodeSourceSurface(SourceSurface* aSurface,
+                              const nsACString& aMimeType,
+                              const nsAString& aOutputOptions,
+                              BinaryOrData aBinaryOrData,
+                              FILE* aFile)
 {
-  MOZ_ASSERT(aBinaryOrData == gfxUtils::eDataURIEncode || aFile || aStrOut,
+  MOZ_ASSERT(aBinaryOrData == eDataURIEncode || aFile,
              "Copying binary encoding to clipboard not currently supported");
 
   const IntSize size = aSurface->GetSize();
   if (size.IsEmpty()) {
     return NS_ERROR_INVALID_ARG;
   }
   const Size floatSize(size.width, size.height);
 
   RefPtr<DataSourceSurface> dataSurface;
   if (aSurface->GetFormat() != SurfaceFormat::B8G8R8A8) {
     // FIXME bug 995807 (B8G8R8X8), bug 831898 (R5G6B5)
     dataSurface =
-      gfxUtils::CopySurfaceToDataSourceSurfaceWithFormat(aSurface,
-                                                         SurfaceFormat::B8G8R8A8);
+      CopySurfaceToDataSourceSurfaceWithFormat(aSurface,
+                                               SurfaceFormat::B8G8R8A8);
   } else {
     dataSurface = aSurface->GetDataSurface();
   }
   if (!dataSurface) {
     return NS_ERROR_FAILURE;
   }
 
   DataSourceSurface::MappedSurface map;
@@ -1214,17 +1209,17 @@ EncodeSourceSurfaceInternal(SourceSurfac
       if (!imgData.resizeUninitialized(bufSize)) {
         return NS_ERROR_OUT_OF_MEMORY;
       }
     }
   }
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(!imgData.empty(), NS_ERROR_FAILURE);
 
-  if (aBinaryOrData == gfxUtils::eBinaryEncode) {
+  if (aBinaryOrData == eBinaryEncode) {
     if (aFile) {
       fwrite(imgData.begin(), 1, imgSize, aFile);
     }
     return NS_OK;
   }
 
   // base 64, result will be null-terminated
   nsCString encodedImg;
@@ -1247,48 +1242,25 @@ EncodeSourceSurfaceInternal(SourceSurfac
         if (len <= 140)
           break;
         len -= 140;
         cStr += 140;
       }
     }
 #endif
     fprintf(aFile, "%s", string.BeginReading());
-  } else if (aStrOut) {
-    *aStrOut = string;
   } else {
     nsCOMPtr<nsIClipboardHelper> clipboard(do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv));
     if (clipboard) {
       clipboard->CopyString(NS_ConvertASCIItoUTF16(string), nullptr);
     }
   }
   return NS_OK;
 }
 
-static nsCString
-EncodeSourceSurfaceAsPNGURI(SourceSurface* aSurface)
-{
-  nsCString string;
-  EncodeSourceSurfaceInternal(aSurface, NS_LITERAL_CSTRING("image/png"),
-                              EmptyString(), gfxUtils::eDataURIEncode,
-                              nullptr, &string);
-  return string;
-}
-
-/* static */ nsresult
-gfxUtils::EncodeSourceSurface(SourceSurface* aSurface,
-                              const nsACString& aMimeType,
-                              const nsAString& aOutputOptions,
-                              BinaryOrData aBinaryOrData,
-                              FILE* aFile)
-{
-  return EncodeSourceSurfaceInternal(aSurface, aMimeType, aOutputOptions,
-                                     aBinaryOrData, aFile, nullptr);
-}
-
 /* static */ void
 gfxUtils::WriteAsPNG(SourceSurface* aSurface, const nsAString& aFile)
 {
   WriteAsPNG(aSurface, NS_ConvertUTF16toUTF8(aFile).get());
 }
 
 /* static */ void
 gfxUtils::WriteAsPNG(SourceSurface* aSurface, const char* aFile)
@@ -1360,71 +1332,27 @@ gfxUtils::WriteAsPNG(nsIPresShell* aShel
 
 /* static */ void
 gfxUtils::DumpAsDataURI(SourceSurface* aSurface, FILE* aFile)
 {
   EncodeSourceSurface(aSurface, NS_LITERAL_CSTRING("image/png"),
                       EmptyString(), eDataURIEncode, aFile);
 }
 
-/* static */ nsCString
-gfxUtils::GetAsDataURI(SourceSurface* aSurface)
-{
-  return EncodeSourceSurfaceAsPNGURI(aSurface);
-}
-
 /* static */ void
 gfxUtils::DumpAsDataURI(DrawTarget* aDT, FILE* aFile)
 {
   RefPtr<SourceSurface> surface = aDT->Snapshot();
   if (surface) {
     DumpAsDataURI(surface, aFile);
   } else {
     NS_WARNING("Failed to get surface!");
   }
 }
 
-/* static */ nsCString
-gfxUtils::GetAsLZ4Base64Str(DataSourceSurface* aSourceSurface)
-{
-  int32_t dataSize = aSourceSurface->GetSize().height * aSourceSurface->Stride();
-  auto compressedData = MakeUnique<char[]>(LZ4::maxCompressedSize(dataSize));
-  if (compressedData) {
-    int nDataSize = LZ4::compress((char*)aSourceSurface->GetData(),
-                                  dataSize,
-                                  compressedData.get());
-    if (nDataSize > 0) {
-      nsCString encodedImg;
-      nsresult rv = Base64Encode(Substring(compressedData.get(), nDataSize), encodedImg);
-      if (rv == NS_OK) {
-        nsCString string("");
-        string.AppendPrintf("data:image/lz4bgra;base64,%i,%i,%i,",
-                             aSourceSurface->GetSize().width,
-                             aSourceSurface->Stride(),
-                             aSourceSurface->GetSize().height);
-        string.Append(encodedImg);
-        return string;
-      }
-    }
-  }
-  return nsCString("");
-}
-
-/* static */ nsCString
-gfxUtils::GetAsDataURI(DrawTarget* aDT)
-{
-  RefPtr<SourceSurface> surface = aDT->Snapshot();
-  if (surface) {
-    return EncodeSourceSurfaceAsPNGURI(surface);
-  } else {
-    NS_WARNING("Failed to get surface!");
-    return nsCString("");
-  }
-}
-
 /* static */ void
 gfxUtils::CopyAsDataURI(SourceSurface* aSurface)
 {
   EncodeSourceSurface(aSurface, NS_LITERAL_CSTRING("image/png"),
                       EmptyString(), eDataURIEncode, nullptr);
 }
 
 /* static */ void
--- a/gfx/thebes/gfxUtils.h
+++ b/gfx/thebes/gfxUtils.h
@@ -276,19 +276,16 @@ public:
     static void DumpAsDataURI(SourceSurface* aSourceSurface, FILE* aFile);
     static inline void DumpAsDataURI(SourceSurface* aSourceSurface) {
         DumpAsDataURI(aSourceSurface, stdout);
     }
     static void DumpAsDataURI(DrawTarget* aDT, FILE* aFile);
     static inline void DumpAsDataURI(DrawTarget* aDT) {
         DumpAsDataURI(aDT, stdout);
     }
-    static nsCString GetAsDataURI(SourceSurface* aSourceSurface);
-    static nsCString GetAsDataURI(DrawTarget* aDT);
-    static nsCString GetAsLZ4Base64Str(DataSourceSurface* aSourceSurface);
 
     /**
      * Copy to the clipboard as a PNG encoded Data URL.
      */
     static void CopyAsDataURI(SourceSurface* aSourceSurface);
     static void CopyAsDataURI(DrawTarget* aDT);
 
 #ifdef MOZ_DUMP_PAINTING
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -3889,20 +3889,16 @@ pref("layers.bench.enabled", false);
 pref("layers.acceleration.force-enabled", true);
 #else
 pref("layers.acceleration.force-enabled", false);
 #endif
 
 pref("layers.acceleration.draw-fps", false);
 
 pref("layers.dump", false);
-#ifdef MOZ_DUMP_PAINTING
-// If we're dumping layers, also dump the texture data
-pref("layers.dump-texture", false);
-#endif
 pref("layers.draw-borders", false);
 pref("layers.draw-tile-borders", false);
 pref("layers.draw-bigimage-borders", false);
 pref("layers.frame-counter", false);
 pref("layers.enable-tiles", false);
 pref("layers.tiled-drawtarget.enabled", false);
 pref("layers.low-precision-buffer", false);
 pref("layers.progressive-paint", false);