Commit e95d8cf1 authored by Alexandru Michis's avatar Alexandru Michis
Browse files

Backed out 3 changesets (bug 1739454) for causing crashtest failures in 1739454-1.html

CLOSED TREE

Backed out changeset 3accfa522abb (bug 1739454)
Backed out changeset 18fdb7a13e63 (bug 1739454)
Backed out changeset 1de7d723923a (bug 1739454)
parent 9b12e17f
Loading
Loading
Loading
Loading
+37 −19
Original line number Diff line number Diff line
@@ -635,31 +635,44 @@ already_AddRefed<SourceSurface> ImageBitmap::PrepareForDrawTarget(
               mSurface->GetFormat() == SurfaceFormat::B8G8R8A8 ||
               mSurface->GetFormat() == SurfaceFormat::A8R8G8B8);

    RefPtr<DataSourceSurface> srcSurface = mSurface->GetDataSurface();
    RefPtr<DataSourceSurface> dstSurface = Factory::CreateDataSourceSurface(
        srcSurface->GetSize(), srcSurface->GetFormat());
    if (NS_WARN_IF(!srcSurface) || NS_WARN_IF(!dstSurface)) {
      return nullptr;
    }
    RefPtr<DataSourceSurface> dstSurface = mSurface->GetDataSurface();
    MOZ_ASSERT(dstSurface);

    RefPtr<DataSourceSurface> srcSurface;
    DataSourceSurface::MappedSurface srcMap;
    DataSourceSurface::MappedSurface dstMap;

    DataSourceSurface::ScopedMap srcMap(srcSurface, DataSourceSurface::READ);
    if (!srcMap.IsMapped()) {
    if (dstSurface->Map(DataSourceSurface::MapType::READ_WRITE, &dstMap)) {
      srcMap = dstMap;
    } else {
      srcSurface = dstSurface;
      if (!srcSurface->Map(DataSourceSurface::READ, &srcMap)) {
        gfxCriticalError()
            << "Failed to map source surface for premultiplying alpha.";
        return nullptr;
      }

    DataSourceSurface::ScopedMap dstMap(dstSurface, DataSourceSurface::WRITE);
    if (!dstMap.IsMapped()) {
      dstSurface = Factory::CreateDataSourceSurface(srcSurface->GetSize(),
                                                    srcSurface->GetFormat());

      if (!dstSurface ||
          !dstSurface->Map(DataSourceSurface::MapType::WRITE, &dstMap)) {
        gfxCriticalError()
            << "Failed to map destination surface for premultiplying alpha.";
        srcSurface->Unmap();
        return nullptr;
      }
    }

    PremultiplyData(srcMap.GetData(), srcMap.GetStride(), mSurface->GetFormat(),
                    dstMap.GetData(), dstMap.GetStride(), mSurface->GetFormat(),
    PremultiplyData(srcMap.mData, srcMap.mStride, mSurface->GetFormat(),
                    dstMap.mData, dstMap.mStride, mSurface->GetFormat(),
                    dstSurface->GetSize());

    dstSurface->Unmap();
    if (srcSurface) {
      srcSurface->Unmap();
    }

    mAlphaType = gfxAlphaType::Premult;
    mSurface = dstSurface;
  }
@@ -1748,10 +1761,15 @@ CreateImageBitmapFromBlob::OnImageReady(imgIContainer* aImgContainer,
  RefPtr<SourceSurface> croppedSurface = surface;
  RefPtr<DataSourceSurface> dataSurface = surface->GetDataSurface();

#ifdef DEBUG
  // the returned dataSurface image memory is write protected in debug mode
  // force a copy into unprotected memory as a side effect of
  // CropAndCopyDataSourceSurface
  bool copyRequired = mCropRect.isSome() ||
                      mOptions.mImageOrientation == ImageOrientation::FlipY;
#else
  bool copyRequired = mCropRect.isSome();
#endif

  if (copyRequired) {
    // The blob is just decoded into a RasterImage and not optimized yet, so the
+0 −16
Original line number Diff line number Diff line
<!DOCTYPE html>
<html class="reftest-wait">
<body>
<script>
document.addEventListener('DOMContentLoaded', async () => {
  cnv = document.createElement('canvas')
  ctx = cnv.getContext('2d')
  try { a = await fetch('../test/image_green-16x16.png') } catch (e) { }
  try { b = await a.arrayBuffer() } catch (e) { }
  c = await self.createImageBitmap(new Blob([b]), {'premultiplyAlpha':'none'})
  ctx.createPattern(c, 'repeat-x')
  document.documentElement.classList.remove("reftest-wait");
})
</script>
</body>
</html>
+0 −1
Original line number Diff line number Diff line
@@ -57,4 +57,3 @@ load 1549853.html
load 1551745.html
load 1569648.html
skip-if(!winWidget||!isDebugBuild) pref(layers.gpu-process.crash-also-crashes-browser,true) load 1654477.html
load 1739454-1.html
+1 −6
Original line number Diff line number Diff line
@@ -92,15 +92,10 @@ bool SourceSurfaceSharedDataWrapper::EnsureMapped(size_t aLength) {
  return true;
}

bool SourceSurfaceSharedDataWrapper::Map(MapType aMapType,
bool SourceSurfaceSharedDataWrapper::Map(MapType,
                                         MappedSurface* aMappedSurface) {
  uint8_t* dataPtr;

  if (aMapType != MapType::READ) {
    // The data may be write-protected
    return false;
  }

  if (mHandleLock) {
    MutexAutoLock lock(*mHandleLock);
    dataPtr = GetData();
+2 −6
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ class SourceSurfaceSharedDataWrapper final : public DataSourceSurface {

  bool OnHeap() const override { return false; }

  bool Map(MapType aMapType, MappedSurface* aMappedSurface) final;
  bool Map(MapType, MappedSurface* aMappedSurface) final;

  void Unmap() final;

@@ -174,12 +174,8 @@ class SourceSurfaceSharedData : public DataSourceSurface {
   * the same data pointer by retaining the old shared buffer until
   * the last mapping is freed via Unmap.
   */
  bool Map(MapType aMapType, MappedSurface* aMappedSurface) final {
  bool Map(MapType, MappedSurface* aMappedSurface) final {
    MutexAutoLock lock(mMutex);
    if (mFinalized && aMapType != MapType::READ) {
      // Once finalized the data may be write-protected
      return false;
    }
    ++mMapCount;
    aMappedSurface->mData = GetDataInternal();
    aMappedSurface->mStride = mStride;
Loading