Bug 996929 - Make nsLayoutUtils::SurfaceFromElement optimize the returned surface upfront so that it doesn't have to be converted every time it's used. r=jwatt

This commit is contained in:
Matt Woodrow 2014-04-16 01:40:18 +01:00
parent b6241f2007
commit d62f8237e0

View File

@ -5404,6 +5404,17 @@ nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent* aElement,
if (!result.mSourceSurface) {
return result;
}
// The surface we return is likely to be cached. We don't want to have to
// convert to a surface that's compatible with aTarget each time it's used
// (that would result in terrible performance), so we convert once here
// upfront if aTarget is specified.
if (aTarget) {
RefPtr<SourceSurface> optSurface =
aTarget->OptimizeSourceSurface(result.mSourceSurface);
if (optSurface) {
result.mSourceSurface = optSurface;
}
}
} else {
result.mDrawInfo.mImgContainer = imgContainer;
result.mDrawInfo.mWhichFrame = whichFrame;