From 93743fee4c8c742ce6d34fde3107d9fcf758ffb7 Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Sun, 27 May 2012 21:11:18 -0400 Subject: [PATCH] Bug 752799. Move image pattern translation within pixman's range. r=roc --HG-- extra : rebase_source : 0b135838d189944b012e83ec8a225e27ab7dcdca --- gfx/thebes/gfxUtils.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp index b5bdff6ad9db..215d9455bba5 100644 --- a/gfx/thebes/gfxUtils.cpp +++ b/gfx/thebes/gfxUtils.cpp @@ -478,10 +478,22 @@ gfxUtils::DrawPixelSnapped(gfxContext* aContext, aFilter = ReduceResamplingFilter(aFilter, aImageRect.Width(), aImageRect.Height(), aSourceRect.Width(), aSourceRect.Height()); + gfxMatrix userSpaceToImageSpace = aUserSpaceToImageSpace; + // On Mobile, we don't ever want to do this; it has the potential for // allocating very large temporary surfaces, especially since we'll // do full-page snapshots often (see bug 749426). -#ifndef MOZ_GFX_OPTIMIZE_MOBILE +#ifdef MOZ_GFX_OPTIMIZE_MOBILE + // If the pattern translation is large we can get into trouble with pixman's + // 16 bit coordinate limits. For now, we only do this on platforms where + // we know we have the pixman limits. 16384.0 is a somewhat arbitrary + // large number to make sure we avoid the expensive fmod when we can, but + // still maintain a safe margin from the actual limit + if (doTile && (userSpaceToImageSpace.y0 > 16384.0 || userSpaceToImageSpace.x0 > 16384.0)) { + userSpaceToImageSpace.x0 = fmod(userSpaceToImageSpace.x0, aImageRect.width); + userSpaceToImageSpace.y0 = fmod(userSpaceToImageSpace.y0, aImageRect.height); + } +#else // OK now, the hard part left is to account for the subimage sampling // restriction. If all the transforms involved are just integer // translations, then we assume no resampling will occur so there's @@ -511,7 +523,7 @@ gfxUtils::DrawPixelSnapped(gfxContext* aContext, aContext->SetOperator(OptimalFillOperator()); } - drawable->Draw(aContext, aFill, doTile, aFilter, aUserSpaceToImageSpace); + drawable->Draw(aContext, aFill, doTile, aFilter, userSpaceToImageSpace); aContext->SetOperator(op); }