Bug 1251807 - Use the surface's size, not the intrinsic size, in CopyFrame. r=tn
authorSeth Fowler <mark.seth.fowler@gmail.com>
Mon, 07 Mar 2016 17:15:25 -0800
changeset 287108 9314f8ddff7830e1cb4beb5450cb6ad2875bcdd2
parent 287107 b485a37494452b6cedacd95f0aa673d48ef449b5
child 287109 8c056908523ec29f08db9d304bff71f5485a14f2
push id73057
push usermfowler@mozilla.com
push dateTue, 08 Mar 2016 01:30:19 +0000
treeherdermozilla-inbound@396e7cdc2539 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs1251807
milestone47.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 1251807 - Use the surface's size, not the intrinsic size, in CopyFrame. r=tn
image/RasterImage.cpp
--- a/image/RasterImage.cpp
+++ b/image/RasterImage.cpp
@@ -489,38 +489,42 @@ RasterImage::CopyFrame(uint32_t aWhichFr
   // FLAG_SYNC_DECODE
   DrawableFrameRef frameRef =
     LookupFrame(GetRequestedFrameIndex(aWhichFrame), mSize, aFlags);
   if (!frameRef) {
     // The OS threw this frame away and we couldn't redecode it right now.
     return nullptr;
   }
 
-  // Create a 32-bit image surface of our size, but draw using the frame's
-  // rect, implicitly padding the frame out to the image's size.
-
-  IntSize size(mSize.width, mSize.height);
+  // Create a 32-bit surface at the decoded size of the image. If
+  // FLAG_SYNC_DECODE was not passed, we may have substituted a downscaled
+  // version of the image we already had available, so this is not necessarily
+  // the intrinsic size of the image. We'll take the frame rect of the image
+  // into account when we draw, implicitly adding padding so that the caller
+  // doesn't need to worry about frame rects.
+  // XXX(seth): In bug 1247520 we'll remove support for frame rects, rendering
+  // this additional padding unnecessary.
   RefPtr<DataSourceSurface> surf =
-    Factory::CreateDataSourceSurface(size,
+    Factory::CreateDataSourceSurface(frameRef->GetImageSize(),
                                      SurfaceFormat::B8G8R8A8,
                                      /* aZero = */ true);
   if (NS_WARN_IF(!surf)) {
     return nullptr;
   }
 
   DataSourceSurface::MappedSurface mapping;
   if (!surf->Map(DataSourceSurface::MapType::WRITE, &mapping)) {
     gfxCriticalError() << "RasterImage::CopyFrame failed to map surface";
     return nullptr;
   }
 
   RefPtr<DrawTarget> target =
     Factory::CreateDrawTargetForData(BackendType::CAIRO,
                                      mapping.mData,
-                                     size,
+                                     frameRef->GetImageSize(),
                                      mapping.mStride,
                                      SurfaceFormat::B8G8R8A8);
   if (!target) {
     gfxWarning() << "RasterImage::CopyFrame failed in CreateDrawTargetForData";
     return nullptr;
   }
 
   IntRect intFrameRect = frameRef->GetRect();