Bug 1068881 - Inflate the dest rect to at least one device pixel when computing the optimal image size for drawing. r=roc

This commit is contained in:
Seth Fowler 2015-03-26 15:39:37 -07:00
parent 9d9c869948
commit 93db772833

View File

@ -5877,18 +5877,25 @@ ComputeSnappedImageDrawingParameters(gfxContext* aCtx,
fill = devPixelFill;
}
// Apply the context's scale to the dest rect.
gfxSize destScale = didSnap ? gfxSize(currentMatrix._11, currentMatrix._22)
: currentMatrix.ScaleFactors(true);
gfxSize appUnitScaledDest(dest.width * destScale.width,
dest.height * destScale.height);
gfxSize scaledDest = appUnitScaledDest / aAppUnitsPerDevPixel;
if (scaledDest.IsEmpty()) {
return SnappedImageDrawingParameters();
}
// Compute a snapped version of the scaled dest rect, which we'll use to
// determine the optimal image size to draw with. We need to be sure that
// this rect is at least one pixel in width and height, or we'll end up
// drawing nothing even if we have a nonempty fill.
gfxSize snappedScaledDest =
gfxSize(NSAppUnitsToIntPixels(appUnitScaledDest.width, aAppUnitsPerDevPixel),
NSAppUnitsToIntPixels(appUnitScaledDest.height, aAppUnitsPerDevPixel));
if (scaledDest.IsEmpty() || snappedScaledDest.IsEmpty()) {
return SnappedImageDrawingParameters();
}
snappedScaledDest.width = std::max(snappedScaledDest.width, 1.0);
snappedScaledDest.height = std::max(snappedScaledDest.height, 1.0);
nsIntSize intImageSize =
aImage->OptimalImageSizeForDest(snappedScaledDest,