From c1faf25e49b7402a55f29d8612f406551f4f0383 Mon Sep 17 00:00:00 2001 From: Chris Lord Date: Thu, 8 May 2014 11:39:31 +0100 Subject: [PATCH] Bug 995216 - Compensate for rounding error in DrawSurfaceWithTextureCoords. r=bas Calculating the source rect in DrawSurfaceWithTextureCoords can introduce small floating point errors that result in detectable blending errors. Round to pixels because we know the original values (the visible region) are pixel-aligned. This is also what CompositorOGL does. --- gfx/layers/basic/BasicCompositor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gfx/layers/basic/BasicCompositor.cpp b/gfx/layers/basic/BasicCompositor.cpp index 781025c933da..b64abcaa5f7b 100644 --- a/gfx/layers/basic/BasicCompositor.cpp +++ b/gfx/layers/basic/BasicCompositor.cpp @@ -144,6 +144,11 @@ DrawSurfaceWithTextureCoords(DrawTarget *aDest, aTextureCoords.y * aSource->GetSize().height, aTextureCoords.width * aSource->GetSize().width, aTextureCoords.height * aSource->GetSize().height); + + // Floating point error can accumulate above and we know our visible region + // is integer-aligned, so round it out. + sourceRect.Round(); + // Compute a transform that maps sourceRect to aDestRect. gfxMatrix transform = gfxUtils::TransformRectToRect(sourceRect,