Bug 1616411 - Part 6a: Make OrientedImage::GetFrameAtSize return an appropriately sized surface. r=tnikkel
authorCameron McCormack <cam@mcc.id.au>
Fri, 17 Apr 2020 02:57:46 +0000
changeset 524541 c30a54ef15b5212e9c6abd12b1f200d837cf6346
parent 524540 35f6bf00a95e1b8d5d9961af6284cf37f96a1167
child 524542 325e655b6024492c976ba22bf2335ad5d2229036
push id37321
push userdluca@mozilla.com
push dateFri, 17 Apr 2020 09:38:52 +0000
treeherdermozilla-central@24537fed53e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1616411
milestone77.0a1
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
Bug 1616411 - Part 6a: Make OrientedImage::GetFrameAtSize return an appropriately sized surface. r=tnikkel We need this since nsLayoutUtils::SurfaceFromElement expects the returned frame size to be correct, and we are now wrapping a source element's image with an OrientedImage. Differential Revision: https://phabricator.services.mozilla.com/D71243
image/OrientedImage.cpp
--- a/image/OrientedImage.cpp
+++ b/image/OrientedImage.cpp
@@ -128,19 +128,27 @@ OrientedImage::GetFrame(uint32_t aWhichF
   NS_ENSURE_TRUE(innerSurface, nullptr);
 
   return OrientSurface(mOrientation, innerSurface);
 }
 
 NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
 OrientedImage::GetFrameAtSize(const IntSize& aSize, uint32_t aWhichFrame,
                               uint32_t aFlags) {
-  // XXX(seth): It'd be nice to support downscale-during-decode for this case,
-  // but right now we just fall back to the intrinsic size.
-  return GetFrame(aWhichFrame, aFlags);
+  // Get a SourceSurface for the inner image then orient it according to
+  // mOrientation.
+  IntSize innerSize = aSize;
+  if (mOrientation.SwapsWidthAndHeight()) {
+    swap(innerSize.width, innerSize.height);
+  }
+  RefPtr<SourceSurface> innerSurface =
+      InnerImage()->GetFrameAtSize(innerSize, aWhichFrame, aFlags);
+  NS_ENSURE_TRUE(innerSurface, nullptr);
+
+  return OrientSurface(mOrientation, innerSurface);
 }
 
 NS_IMETHODIMP_(bool)
 OrientedImage::IsImageContainerAvailable(LayerManager* aManager,
                                          uint32_t aFlags) {
   if (mOrientation.IsIdentity()) {
     return InnerImage()->IsImageContainerAvailable(aManager, aFlags);
   }