From 351cd4311bcf3992d762857d60920893dd53f703 Mon Sep 17 00:00:00 2001 From: "vladimir@pobox.com" Date: Tue, 22 May 2007 20:54:38 -0700 Subject: [PATCH] b=324698, disable bilinear filtering for upscaled images (upscaling causes misrendering), r=roc --- gfx/src/thebes/nsThebesImage.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/gfx/src/thebes/nsThebesImage.cpp b/gfx/src/thebes/nsThebesImage.cpp index 2fa1001caa4..d384fccc31f 100644 --- a/gfx/src/thebes/nsThebesImage.cpp +++ b/gfx/src/thebes/nsThebesImage.cpp @@ -397,6 +397,21 @@ nsThebesImage::Draw(nsIRenderingContext &aContext, nsRefPtr pat = new gfxPattern(ThebesSurface()); pat->SetMatrix(mat); + // XXX bug 324698 +#ifndef XP_MACOSX + if (xscale > 1.0 || yscale > 1.0) { + // See bug 324698. This is a workaround. + // + // Set the filter to CAIRO_FILTER_FAST if we're scaling up -- otherwise, + // pixman's sampling will sample transparency for the outside edges and we'll + // get blurry edges. CAIRO_EXTEND_PAD would also work here, but it's not + // implemented for image sources. + // + // This effectively disables smooth upscaling for images. + pat->SetFilter(0); + } +#endif + ctx->NewPath(); ctx->SetPattern(pat); ctx->Rectangle(destRect); @@ -504,6 +519,14 @@ nsThebesImage::ThebesDrawTile(gfxContext *thebesContext, pat->SetExtend(gfxPattern::EXTEND_REPEAT); pat->SetMatrix(patMat); +#ifndef XP_MACOSX + if (scale > 1.0) { + // See bug 324698. This is a workaround. See comments + // by the earlier SetFilter call. + pat->SetFilter(0); + } +#endif + thebesContext->SetPattern(pat); }