Commit f5a0ea92 authored by Seth Fowler's avatar Seth Fowler
Browse files

Bug 1251804 - Use the ImageContainer's size and not the intrinsic size when...

Bug 1251804 - Use the ImageContainer's size and not the intrinsic size when computing the transform in nsDisplayImage::ConfigureLayer. r=tn

--HG--
extra : rebase_source : df3cfd946dd08a67284d0091b1b7ce0131fff47e
parent e5558626
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -2799,10 +2799,20 @@ nsDisplayBackgroundImage::ConfigureLayer(ImageLayer* aLayer,
  // aParameters.Offset() is always zero.
  MOZ_ASSERT(aParameters.Offset() == LayerIntPoint(0,0));

  // It's possible (for example, due to downscale-during-decode) that the
  // ImageContainer this ImageLayer is holding has a different size from the
  // intrinsic size of the image. For this reason we compute the transform using
  // the ImageContainer's size rather than the image's intrinsic size.
  // XXX(seth): In reality, since the size of the ImageContainer may change
  // asynchronously, this is not enough. Bug 1183378 will provide a more
  // complete fix, but this solution is safe in more cases than simply relying
  // on the intrinsic size.
  IntSize containerSize = aLayer->GetContainer()->GetCurrentSize();

  const LayoutDevicePoint p = mImageLayerDestRect.TopLeft();
  Matrix transform = Matrix::Translation(p.x, p.y);
  transform.PreScale(mImageLayerDestRect.width / imageWidth,
                     mImageLayerDestRect.height / imageHeight);
  transform.PreScale(mImageLayerDestRect.width / containerSize.width,
                     mImageLayerDestRect.height / containerSize.height);
  aLayer->SetBaseTransform(gfx::Matrix4x4::From2D(transform));
}

+12 −2
Original line number Diff line number Diff line
@@ -1703,10 +1703,20 @@ nsDisplayImage::ConfigureLayer(ImageLayer* aLayer,
  // aParameters.Offset() is always zero.
  MOZ_ASSERT(aParameters.Offset() == LayerIntPoint(0,0));

  // It's possible (for example, due to downscale-during-decode) that the
  // ImageContainer this ImageLayer is holding has a different size from the
  // intrinsic size of the image. For this reason we compute the transform using
  // the ImageContainer's size rather than the image's intrinsic size.
  // XXX(seth): In reality, since the size of the ImageContainer may change
  // asynchronously, this is not enough. Bug 1183378 will provide a more
  // complete fix, but this solution is safe in more cases than simply relying
  // on the intrinsic size.
  IntSize containerSize = aLayer->GetContainer()->GetCurrentSize();

  const LayoutDevicePoint p = destRect.TopLeft();
  Matrix transform = Matrix::Translation(p.x, p.y);
  transform.PreScale(destRect.Width() / imageWidth,
                     destRect.Height() / imageHeight);
  transform.PreScale(destRect.Width() / containerSize.width,
                     destRect.Height() / containerSize.height);
  aLayer->SetBaseTransform(gfx::Matrix4x4::From2D(transform));
}

+12 −2
Original line number Diff line number Diff line
@@ -480,10 +480,20 @@ nsDisplayXULImage::ConfigureLayer(ImageLayer* aLayer,
  // aParameters.Offset() is always zero.
  MOZ_ASSERT(aParameters.Offset() == LayerIntPoint(0,0));

  // It's possible (for example, due to downscale-during-decode) that the
  // ImageContainer this ImageLayer is holding has a different size from the
  // intrinsic size of the image. For this reason we compute the transform using
  // the ImageContainer's size rather than the image's intrinsic size.
  // XXX(seth): In reality, since the size of the ImageContainer may change
  // asynchronously, this is not enough. Bug 1183378 will provide a more
  // complete fix, but this solution is safe in more cases than simply relying
  // on the intrinsic size.
  IntSize containerSize = aLayer->GetContainer()->GetCurrentSize();

  const LayoutDevicePoint p = destRect.TopLeft();
  Matrix transform = Matrix::Translation(p.x, p.y);
  transform.PreScale(destRect.Width() / imageWidth,
                     destRect.Height() / imageHeight);
  transform.PreScale(destRect.Width() / containerSize.width,
                     destRect.Height() / containerSize.height);
  aLayer->SetBaseTransform(gfx::Matrix4x4::From2D(transform));
}