Backed out 2 changesets (bug 1299164) for win vm bc4 bustage a=backout
authorWes Kocher <wkocher@mozilla.com>
Fri, 02 Sep 2016 11:38:22 -0700
changeset 353791 aefced02ac1e5ad12bb81e6e252ec1c2c031363c
parent 353790 97471e6c4d4c67339d3896f7df36b02e1d570105
child 353792 568c0384b6b2303334b833cce9746cbdbc689869
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1299164
milestone51.0a1
backs out53dc795121e100ca900642f0ba0ce295d69bd903
c39ec15e7e214ea6203ff49f28d3b12c55cbd8f3
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 2 changesets (bug 1299164) for win vm bc4 bustage a=backout Backed out changeset 53dc795121e1 (bug 1299164) Backed out changeset c39ec15e7e21 (bug 1299164)
dom/base/ImageEncoder.cpp
dom/canvas/CanvasRenderingContext2D.cpp
dom/canvas/ImageBitmapRenderingContext.cpp
dom/plugins/ipc/PluginInstanceChild.cpp
gfx/2d/DataSurfaceHelpers.cpp
gfx/2d/DataSurfaceHelpers.h
gfx/2d/Factory.cpp
gfx/2d/ImageScaling.cpp
gfx/2d/SourceSurfaceRawData.h
gfx/layers/TextureDIB.cpp
gfx/layers/basic/GrallocTextureHostBasic.cpp
gfx/layers/composite/CanvasLayerComposite.cpp
gfx/layers/composite/ImageLayerComposite.cpp
gfx/thebes/gfxAndroidPlatform.cpp
gfx/thebes/gfxPlatformGtk.cpp
gfx/thebes/gfxPlatformMac.cpp
gfx/thebes/gfxWindowsPlatform.cpp
--- a/dom/base/ImageEncoder.cpp
+++ b/dom/base/ImageEncoder.cpp
@@ -364,20 +364,16 @@ ImageEncoder::ExtractDataInternal(const 
     return NS_ERROR_INVALID_ARG;
   }
 
   nsCOMPtr<nsIInputStream> imgStream;
 
   // get image bytes
   nsresult rv;
   if (aImageBuffer) {
-    if (BufferSizeFromDimensions(aSize.width, aSize.height, 4) == 0) {
-      return NS_ERROR_INVALID_ARG;
-    }
-
     rv = ImageEncoder::GetInputStream(
       aSize.width,
       aSize.height,
       aImageBuffer,
       aFormat,
       aEncoder,
       nsPromiseFlatString(aOptions).get(),
       getter_AddRefs(imgStream));
@@ -416,20 +412,16 @@ ImageEncoder::ExtractDataInternal(const 
       rv = aEncoder->InitFromData(data.Elements(),
                                   aSize.width * aSize.height * 4,
                                   aSize.width,
                                   aSize.height,
                                   aSize.width * 4,
                                   imgIEncoder::INPUT_FORMAT_HOSTARGB,
                                   aOptions);
     } else {
-      if (BufferSizeFromDimensions(aSize.width, aSize.height, 4) == 0) {
-        return NS_ERROR_INVALID_ARG;
-      }
-
       RefPtr<gfx::DataSourceSurface> dataSurface;
       RefPtr<layers::Image> image(aImage);
       dataSurface = GetBRGADataSourceSurfaceSync(image.forget());
 
       DataSourceSurface::MappedSurface map;
       if (!dataSurface->Map(gfx::DataSourceSurface::MapType::READ, &map)) {
         return NS_ERROR_INVALID_ARG;
       }
@@ -442,20 +434,22 @@ ImageEncoder::ExtractDataInternal(const 
                                   aOptions);
       dataSurface->Unmap();
     }
 
     if (NS_SUCCEEDED(rv)) {
       imgStream = do_QueryInterface(aEncoder);
     }
   } else {
-    if (BufferSizeFromDimensions(aSize.width, aSize.height, 4) == 0) {
+    CheckedInt32 requiredBytes = CheckedInt32(aSize.width) * CheckedInt32(aSize.height) * 4;
+    if (MOZ_UNLIKELY(!requiredBytes.isValid())) {
       return NS_ERROR_INVALID_ARG;
     }
 
+
     // no context, so we have to encode an empty image
     // note that if we didn't have a current context, the spec says we're
     // supposed to just return transparent black pixels of the canvas
     // dimensions.
     RefPtr<DataSourceSurface> emptyCanvas =
       Factory::CreateDataSourceSurfaceWithStride(IntSize(aSize.width, aSize.height),
                                                  SurfaceFormat::B8G8R8A8,
                                                  4 * aSize.width, true);
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -5238,23 +5238,18 @@ CanvasRenderingContext2D::DrawWindow(nsG
       (!mBufferProvider || mBufferProvider->GetType() != LayersBackend::LAYERS_CLIENT))
   {
     thebes = gfxContext::CreateOrNull(mTarget);
     MOZ_ASSERT(thebes); // already checked the draw target above
                         // (in SupportsAzureContentForDrawTarget)
     thebes->SetMatrix(gfxMatrix(matrix._11, matrix._12, matrix._21,
                                 matrix._22, matrix._31, matrix._32));
   } else {
-    IntSize dtSize = IntSize::Ceil(sw, sh);
-    if (!Factory::AllowedSurfaceSize(dtSize)) {
-      aError.Throw(NS_ERROR_FAILURE);
-      return;
-    }
     drawDT =
-      gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(dtSize,
+      gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(IntSize::Ceil(sw, sh),
                                                                    SurfaceFormat::B8G8R8A8);
     if (!drawDT || !drawDT->IsValid()) {
       aError.Throw(NS_ERROR_FAILURE);
       return;
     }
 
     thebes = gfxContext::CreateOrNull(drawDT);
     MOZ_ASSERT(thebes); // alrady checked the draw target above
@@ -5270,22 +5265,16 @@ CanvasRenderingContext2D::DrawWindow(nsG
 
   if (drawDT) {
     RefPtr<SourceSurface> snapshot = drawDT->Snapshot();
     if (NS_WARN_IF(!snapshot)) {
       aError.Throw(NS_ERROR_FAILURE);
       return;
     }
     RefPtr<DataSourceSurface> data = snapshot->GetDataSurface();
-    if (!data || !Factory::AllowedSurfaceSize(data->GetSize())) {
-      gfxCriticalError() << "Unexpected invalid data source surface " <<
-        (data ? data->GetSize() : IntSize(0,0));
-      aError.Throw(NS_ERROR_FAILURE);
-      return;
-    }
 
     DataSourceSurface::MappedSurface rawData;
     if (NS_WARN_IF(!data->Map(DataSourceSurface::READ, &rawData))) {
         aError.Throw(NS_ERROR_FAILURE);
         return;
     }
     RefPtr<SourceSurface> source =
       mTarget->CreateSourceSurfaceFromData(rawData.mData,
--- a/dom/canvas/ImageBitmapRenderingContext.cpp
+++ b/dom/canvas/ImageBitmapRenderingContext.cpp
@@ -104,18 +104,17 @@ ImageBitmapRenderingContext::MatchWithIn
   }
 
   RefPtr<DrawTarget> dt =
     Factory::CreateDrawTargetForData(BackendType::CAIRO,
                                      map.GetData(),
                                      temp->GetSize(),
                                      map.GetStride(),
                                      temp->GetFormat());
-  if (!dt || !dt->IsValid()) {
-    gfxWarning() << "ImageBitmapRenderingContext::MatchWithIntrinsicSize failed";
+  if (!dt) {
     return nullptr;
   }
 
 
   dt->ClearRect(Rect(0, 0, mWidth, mHeight));
   dt->CopySurface(surface,
                   IntRect(0, 0, surface->GetSize().width,
                                 surface->GetSize().height),
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -3781,23 +3781,19 @@ PluginInstanceChild::PaintRectToSurface(
                                               imageSurface->Data(),
                                               imageSurface->GetSize(),
                                               imageSurface->Stride(),
                                               SurfaceFormat::B8G8R8A8);
       } else {
         // Copy helper surface content to target
         dt = CreateDrawTargetForSurface(aSurface);
       }
-      if (dt && dt->IsValid()) {
-          RefPtr<SourceSurface> surface =
-              gfxPlatform::GetSourceSurfaceForSurface(dt, renderSurface);
-          dt->CopySurface(surface, aRect, aRect.TopLeft());
-      } else {
-          gfxWarning() << "PluginInstanceChild::PaintRectToSurface failure";
-      }
+      RefPtr<SourceSurface> surface =
+        gfxPlatform::GetSourceSurfaceForSurface(dt, renderSurface);
+      dt->CopySurface(surface, aRect, aRect.TopLeft());
     }
 }
 
 void
 PluginInstanceChild::PaintRectWithAlphaExtraction(const nsIntRect& aRect,
                                                   gfxASurface* aSurface)
 {
     MOZ_ASSERT(aSurface->GetContentType() == gfxContentType::COLOR_ALPHA,
--- a/gfx/2d/DataSurfaceHelpers.cpp
+++ b/gfx/2d/DataSurfaceHelpers.cpp
@@ -260,53 +260,31 @@ ClearDataSourceSurface(DataSourceSurface
   aSurface->Unmap();
 }
 
 size_t
 BufferSizeFromStrideAndHeight(int32_t aStride,
                               int32_t aHeight,
                               int32_t aExtraBytes)
 {
-  if (MOZ_UNLIKELY(aHeight <= 0) || MOZ_UNLIKELY(aStride <= 0)) {
+  if (MOZ_UNLIKELY(aHeight <= 0)) {
     return 0;
   }
 
   // We limit the length returned to values that can be represented by int32_t
   // because we don't want to allocate buffers any bigger than that. This
   // allows for a buffer size of over 2 GiB which is already rediculously
   // large and will make the process janky. (Note the choice of the signed type
   // is deliberate because we specifically don't want the returned value to
   // overflow if someone stores the buffer length in an int32_t variable.)
 
   CheckedInt32 requiredBytes =
     CheckedInt32(aStride) * CheckedInt32(aHeight) + CheckedInt32(aExtraBytes);
   if (MOZ_UNLIKELY(!requiredBytes.isValid())) {
-    gfxWarning() << "Buffer size too big; returning zero " << aStride << ", " << aHeight << ", " << aExtraBytes;
-    return 0;
-  }
-  return requiredBytes.value();
-}
-
-size_t
-BufferSizeFromDimensions(int32_t aWidth,
-                         int32_t aHeight,
-                         int32_t aDepth,
-                         int32_t aExtraBytes)
-{
-  if (MOZ_UNLIKELY(aHeight <= 0) ||
-      MOZ_UNLIKELY(aWidth <= 0) ||
-      MOZ_UNLIKELY(aDepth <= 0)) {
-    return 0;
-  }
-
-  // Similar to BufferSizeFromStrideAndHeight, but with an extra parameter.
-
-  CheckedInt32 requiredBytes = CheckedInt32(aWidth) * CheckedInt32(aHeight) * CheckedInt32(aDepth) + CheckedInt32(aExtraBytes);
-  if (MOZ_UNLIKELY(!requiredBytes.isValid())) {
-    gfxWarning() << "Buffer size too big; returning zero " << aWidth << ", " << aHeight << ", " << aDepth << ", " << aExtraBytes;
+    gfxWarning() << "Buffer size too big; returning zero";
     return 0;
   }
   return requiredBytes.value();
 }
 
 /**
  * aSrcRect: Rect relative to the aSrc surface
  * aDestPoint: Point inside aDest surface
--- a/gfx/2d/DataSurfaceHelpers.h
+++ b/gfx/2d/DataSurfaceHelpers.h
@@ -88,32 +88,16 @@ 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);
 
 /**
- * Multiplies aWidth, aHeight, aDepth and makes sure the result is limited to
- * something sane. To keep things consistent, this should always be used
- * wherever we allocate a buffer based on surface dimensions.
- *
- * @param aExtra Optional argument to specify an additional number of trailing
- *   bytes (useful for creating intermediate surfaces for filters, for
- *   example).
- *
- * @return The result of the multiplication if it is acceptable, or else zero.
- */
-size_t
-BufferSizeFromDimensions(int32_t aWidth,
-                         int32_t aHeight,
-                         int32_t aDepth,
-                         int32_t aExtraBytes = 0);
-/**
  * Copy aSrcRect from aSrc to aDest starting at aDestPoint.
  * @returns false if the copy is not successful or the aSrc's size is empty.
  */
 bool
 CopyRect(DataSourceSurface* aSrc, DataSourceSurface* aDest,
          IntRect aSrcRect, IntPoint aDestPoint);
 
 /**
--- a/gfx/2d/Factory.cpp
+++ b/gfx/2d/Factory.cpp
@@ -730,21 +730,16 @@ Factory::CreateDrawTargetSkiaWithGrConte
 void
 Factory::PurgeAllCaches()
 {
 }
 
 already_AddRefed<DrawTarget>
 Factory::CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat)
 {
-  if (!AllowedSurfaceSize(aSize)) {
-    gfxCriticalError(LoggerOptionsBasedOnSize(aSize)) << "Failed to allocate a surface due to invalid size (Cairo) " << aSize;
-    return nullptr;
-  }
-
   RefPtr<DrawTarget> retVal;
 
 #ifdef USE_CAIRO
   RefPtr<DrawTargetCairo> newTarget = new DrawTargetCairo();
 
   if (newTarget->Init(aSurface, aSize, aFormat)) {
     retVal = newTarget;
   }
@@ -770,21 +765,16 @@ Factory::CreateSourceSurfaceForCairoSurf
   return nullptr;
 #endif
 }
 
 #ifdef XP_DARWIN
 already_AddRefed<DrawTarget>
 Factory::CreateDrawTargetForCairoCGContext(CGContextRef cg, const IntSize& aSize)
 {
-  if (!AllowedSurfaceSize(aSize)) {
-    gfxCriticalError(LoggerOptionsBasedOnSize(aSize)) << "Failed to allocate a surface due to invalid size (CG) " << aSize;
-    return nullptr;
-  }
-
   RefPtr<DrawTarget> retVal;
 
   RefPtr<DrawTargetCG> newTarget = new DrawTargetCG();
 
   if (newTarget->Init(cg, aSize)) {
     retVal = newTarget;
   }
 
@@ -804,17 +794,17 @@ Factory::CreateCGGlyphRenderingOptions(c
 already_AddRefed<DataSourceSurface>
 Factory::CreateWrappingDataSourceSurface(uint8_t *aData,
                                          int32_t aStride,
                                          const IntSize &aSize,
                                          SurfaceFormat aFormat,
                                          SourceSurfaceDeallocator aDeallocator /* = nullptr */,
                                          void* aClosure /* = nullptr */)
 {
-  if (!AllowedSurfaceSize(aSize) || aStride <= 0) {
+  if (aSize.width <= 0 || aSize.height <= 0) {
     return nullptr;
   }
   if (!aDeallocator && aClosure) {
     return nullptr;
   }
 
   MOZ_ASSERT(aData);
 
@@ -848,18 +838,17 @@ Factory::CreateDataSourceSurface(const I
 }
 
 already_AddRefed<DataSourceSurface>
 Factory::CreateDataSourceSurfaceWithStride(const IntSize &aSize,
                                            SurfaceFormat aFormat,
                                            int32_t aStride,
                                            bool aZero)
 {
-  if (!AllowedSurfaceSize(aSize) ||
-      aStride < aSize.width * BytesPerPixel(aFormat)) {
+  if (aStride < aSize.width * BytesPerPixel(aFormat)) {
     gfxCriticalError(LoggerOptionsBasedOnSize(aSize)) << "CreateDataSourceSurfaceWithStride failed with bad stride " << aStride << ", " << aSize << ", " << aFormat;
     return nullptr;
   }
 
   // Skia doesn't support RGBX, so memset RGBX to 0xFF
   bool clearSurface = aZero || aFormat == SurfaceFormat::B8G8R8X8;
   uint8_t clearValue = aFormat == SurfaceFormat::B8G8R8X8 ? 0xFF : 0;
 
--- a/gfx/2d/ImageScaling.cpp
+++ b/gfx/2d/ImageScaling.cpp
@@ -60,30 +60,30 @@ ImageHalfScaler::ScaleForSize(const IntS
     horizontalDownscales++;
     scaleSize.width /= 2;
   }
 
   if (scaleSize == mOrigSize) {
     return;
   }
 
-  delete [] mDataStorage;
+  IntSize internalSurfSize;
 
-  IntSize internalSurfSize;
   internalSurfSize.width = max(scaleSize.width, mOrigSize.width / 2);
   internalSurfSize.height = max(scaleSize.height, mOrigSize.height / 2);
 
-  size_t bufLen = 0;
-  mStride = GetAlignedStride<16>(internalSurfSize.width, 4);
-  if (mStride > 0) {
-    // Allocate 15 bytes extra to make sure we can get 16 byte alignment. We
-    // should add tools for this, see bug 751696.
-    bufLen = BufferSizeFromStrideAndHeight(mStride, internalSurfSize.height, 15);
+  mStride = internalSurfSize.width * 4;
+  if (mStride % 16) {
+    mStride += 16 - (mStride % 16);
   }
 
+  delete [] mDataStorage;
+  // Allocate 15 bytes extra to make sure we can get 16 byte alignment. We
+  // should add tools for this, see bug 751696.
+  size_t bufLen = BufferSizeFromStrideAndHeight(mStride, internalSurfSize.height, 15);
   if (bufLen == 0) {
     mSize.SizeTo(0, 0);
     mDataStorage = nullptr;
     return;
   }
   mDataStorage = new uint8_t[bufLen];
 
   if (uintptr_t(mDataStorage) % 16) {
--- a/gfx/2d/SourceSurfaceRawData.h
+++ b/gfx/2d/SourceSurfaceRawData.h
@@ -75,18 +75,17 @@ public:
     mMapCount--;
     MOZ_ASSERT(mMapCount >= 0);
   }
 
 private:
   friend class Factory;
 
   // If we have a custom deallocator, the |aData| will be released using the
-  // custom deallocator and |aClosure| in dtor.  The assumption is that the
-  // caller will check for valid size and stride before making this call.
+  // custom deallocator and |aClosure| in dtor.
   void InitWrappingData(unsigned char *aData,
                         const IntSize &aSize,
                         int32_t aStride,
                         SurfaceFormat aFormat,
                         Factory::SourceSurfaceDeallocator aDeallocator,
                         void* aClosure);
 
   uint8_t *mRawData;
--- a/gfx/layers/TextureDIB.cpp
+++ b/gfx/layers/TextureDIB.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * 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 "TextureDIB.h"
 #include "gfx2DGlue.h"
-#include "mozilla/gfx/DataSurfaceHelpers.h" // For BufferSizeFromDimensions
 #include "mozilla/layers/ISurfaceAllocator.h"
 #include "mozilla/ipc/ProtocolUtils.h"
 
 namespace mozilla {
 
 using namespace gfx;
 
 namespace layers {
@@ -429,17 +428,17 @@ DIBTextureHost::UpdatedInternal(const ns
       gfxWarning() << "Bad Cairo surface internal update " << mSurface->CairoStatus();
       mTextureSource = nullptr;
       return;
   }
   RefPtr<gfxImageSurface> imgSurf = mSurface->GetAsImageSurface();
 
   RefPtr<DataSourceSurface> surf = Factory::CreateWrappingDataSourceSurface(imgSurf->Data(), imgSurf->Stride(), mSize, mFormat);
 
-  if (!surf || !mTextureSource->Update(surf, const_cast<nsIntRegion*>(aRegion))) {
+  if (!mTextureSource->Update(surf, const_cast<nsIntRegion*>(aRegion))) {
     mTextureSource = nullptr;
   }
 
   ReadUnlock();
 }
 
 TextureHostFileMapping::TextureHostFileMapping(TextureFlags aFlags,
                                                const SurfaceDescriptorFileMapping& aDescriptor)
@@ -469,30 +468,24 @@ TextureHostFileMapping::UpdatedInternal(
     // attached to a layer.
     return;
   }
 
   if (!mTextureSource) {
     mTextureSource = mCompositor->CreateDataTextureSource(mFlags);
   }
 
-  uint8_t* data = nullptr;
-  int32_t totalBytes = BufferSizeFromDimensions(mSize.width, mSize.height, BytesPerPixel(mFormat));
-  if (totalBytes > 0) {
-    data = (uint8_t*)::MapViewOfFile(mFileMapping, FILE_MAP_READ, 0, 0, totalBytes);
-  }
+  uint8_t* data = (uint8_t*)::MapViewOfFile(mFileMapping, FILE_MAP_READ, 0, 0, mSize.width * mSize.height * BytesPerPixel(mFormat));
 
   if (data) {
     RefPtr<DataSourceSurface> surf = Factory::CreateWrappingDataSourceSurface(data, mSize.width * BytesPerPixel(mFormat), mSize, mFormat);
-    if (surf) {
-        surf->AddUserData(&kFileMappingKey, data, UnmapFileData);
-        if (!mTextureSource->Update(surf, const_cast<nsIntRegion*>(aRegion))) {
-          mTextureSource = nullptr;
-        }
-    } else {
+
+    surf->AddUserData(&kFileMappingKey, data, UnmapFileData);
+
+    if (!mTextureSource->Update(surf, const_cast<nsIntRegion*>(aRegion))) {
       mTextureSource = nullptr;
     }
   } else {
     mTextureSource = nullptr;
   }
 
   ReadUnlock();
 }
--- a/gfx/layers/basic/GrallocTextureHostBasic.cpp
+++ b/gfx/layers/basic/GrallocTextureHostBasic.cpp
@@ -135,23 +135,19 @@ GrallocTextureHostBasic::Lock()
       return false;
     }
     surf = gfx::Factory::CreateWrappingDataSourceSurface(
              mMappedBuffer,
              graphicBuffer->getStride() * gfx::BytesPerPixel(mFormat),
              mCropSize,
              mFormat);
   }
-  if (surf) {
-    mTextureSource = mCompositor->CreateDataTextureSource(mFlags);
-    mTextureSource->Update(surf, nullptr);
-    return true;
-  }
-  mMappedBuffer = nullptr;
-  return false;
+  mTextureSource = mCompositor->CreateDataTextureSource(mFlags);
+  mTextureSource->Update(surf, nullptr);
+  return true;
 }
 
 bool
 GrallocTextureHostBasic::IsValid() const
 {
   android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
   return graphicBuffer != nullptr;
 }
--- a/gfx/layers/composite/CanvasLayerComposite.cpp
+++ b/gfx/layers/composite/CanvasLayerComposite.cpp
@@ -84,19 +84,17 @@ CanvasLayerComposite::RenderLayer(const 
     return;
   }
 
   mCompositor->MakeCurrent();
 
 #ifdef MOZ_DUMP_PAINTING
   if (gfxEnv::DumpCompositorTextures()) {
     RefPtr<gfx::DataSourceSurface> surf = mCompositableHost->GetAsSurface();
-    if (surf) {
-      WriteSnapshotToDumpFile(this, surf);
-    }
+    WriteSnapshotToDumpFile(this, surf);
   }
 #endif
 
   RenderWithAllMasks(this, mCompositor, aClipRect,
                      [&](EffectChain& effectChain, const IntRect& clipRect) {
     mCompositableHost->Composite(this, effectChain,
                           GetEffectiveOpacity(),
                           GetEffectiveTransform(),
--- a/gfx/layers/composite/ImageLayerComposite.cpp
+++ b/gfx/layers/composite/ImageLayerComposite.cpp
@@ -94,19 +94,17 @@ ImageLayerComposite::RenderLayer(const I
 {
   if (!mImageHost || !mImageHost->IsAttached()) {
     return;
   }
 
 #ifdef MOZ_DUMP_PAINTING
   if (gfxEnv::DumpCompositorTextures()) {
     RefPtr<gfx::DataSourceSurface> surf = mImageHost->GetAsSurface();
-    if (surf) {
-      WriteSnapshotToDumpFile(this, surf);
-    }
+    WriteSnapshotToDumpFile(this, surf);
   }
 #endif
 
   mCompositor->MakeCurrent();
 
   RenderWithAllMasks(this, mCompositor, aClipRect,
                      [&](EffectChain& effectChain, const IntRect& clipRect) {
     mImageHost->SetCompositor(mCompositor);
--- a/gfx/thebes/gfxAndroidPlatform.cpp
+++ b/gfx/thebes/gfxAndroidPlatform.cpp
@@ -118,20 +118,16 @@ gfxAndroidPlatform::~gfxAndroidPlatform(
     FT_Done_Library(gPlatformFTLibrary);
     gPlatformFTLibrary = nullptr;
 }
 
 already_AddRefed<gfxASurface>
 gfxAndroidPlatform::CreateOffscreenSurface(const IntSize& aSize,
                                            gfxImageFormat aFormat)
 {
-    if (!Factory::AllowedSurfaceSize(aSize)) {
-        return nullptr;
-    }
-
     RefPtr<gfxASurface> newSurface;
     newSurface = new gfxImageSurface(aSize, aFormat);
 
     return newSurface.forget();
 }
 
 static bool
 IsJapaneseLocale()
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -137,20 +137,16 @@ gfxPlatformGtk::FlushContentDrawing()
         XFlush(DefaultXDisplay());
     }
 }
 
 already_AddRefed<gfxASurface>
 gfxPlatformGtk::CreateOffscreenSurface(const IntSize& aSize,
                                        gfxImageFormat aFormat)
 {
-    if (!Factory::AllowedSurfaceSize(aSize)) {
-        return nullptr;
-    }
-
     RefPtr<gfxASurface> newSurface;
     bool needsClear = true;
 #ifdef MOZ_X11
     // XXX we really need a different interface here, something that passes
     // in more context, including the display and/or target surface type that
     // we should try to match
     GdkScreen *gdkScreen = gdk_screen_get_default();
     if (gdkScreen) {
--- a/gfx/thebes/gfxPlatformMac.cpp
+++ b/gfx/thebes/gfxPlatformMac.cpp
@@ -111,20 +111,16 @@ gfxPlatformMac::CreatePlatformFontList()
     gfxPlatformFontList::Shutdown();
     return nullptr;
 }
 
 already_AddRefed<gfxASurface>
 gfxPlatformMac::CreateOffscreenSurface(const IntSize& aSize,
                                        gfxImageFormat aFormat)
 {
-    if (!Factory::AllowedSurfaceSize(aSize)) {
-        return nullptr;
-    }
-
     RefPtr<gfxASurface> newSurface =
       new gfxQuartzSurface(aSize, aFormat);
     return newSurface.forget();
 }
 
 already_AddRefed<ScaledFont>
 gfxPlatformMac::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
 {
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -580,20 +580,16 @@ gfxWindowsPlatform::DisableD2D(FeatureSt
   Factory::SetDirect3D11Device(nullptr);
   UpdateBackendPrefs();
 }
 
 already_AddRefed<gfxASurface>
 gfxWindowsPlatform::CreateOffscreenSurface(const IntSize& aSize,
                                            gfxImageFormat aFormat)
 {
-    if (!Factory::AllowedSurfaceSize(aSize)) {
-        return nullptr;
-    }
-
     RefPtr<gfxASurface> surf = nullptr;
 
 #ifdef CAIRO_HAS_WIN32_SURFACE
     if (mRenderMode == RENDER_GDI || mRenderMode == RENDER_DIRECT2D)
         surf = new gfxWindowsSurface(aSize, aFormat);
 #endif
 
     if (!surf || surf->CairoStatus()) {