From 7e8cc21d574e00d13391da59f00be6bba62c31cd Mon Sep 17 00:00:00 2001 From: egdaniel Date: Wed, 6 Jul 2016 14:38:34 -0700 Subject: Fix bounds computation for non-aa hairlines when snapping to pixel centers BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2126913002 Review-Url: https://codereview.chromium.org/2126913002 --- src/gpu/batches/GrNonAAStrokeRectBatch.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/gpu') diff --git a/src/gpu/batches/GrNonAAStrokeRectBatch.cpp b/src/gpu/batches/GrNonAAStrokeRectBatch.cpp index fb906081d4..e443851fac 100644 --- a/src/gpu/batches/GrNonAAStrokeRectBatch.cpp +++ b/src/gpu/batches/GrNonAAStrokeRectBatch.cpp @@ -100,6 +100,16 @@ private: // If our caller snaps to pixel centers then we have to round out the bounds if (snapToPixelCenters) { + // We want to be consistent with how we snap non-aa lines. To match what we do in + // GrGLSLVertexShaderBuilder, we first floor all the vertex values and then add half a + // pixel to force us to pixel centers. + bounds->set(SkScalarFloorToScalar(bounds->fLeft), + SkScalarFloorToScalar(bounds->fTop), + SkScalarFloorToScalar(bounds->fRight), + SkScalarFloorToScalar(bounds->fBottom)); + bounds->offset(0.5f, 0.5f); + + // Round out the bounds to integer values bounds->roundOut(); } } -- cgit v1.2.3