diff options
author | 2016-07-06 14:38:34 -0700 | |
---|---|---|
committer | 2016-07-06 14:38:34 -0700 | |
commit | 7e8cc21d574e00d13391da59f00be6bba62c31cd (patch) | |
tree | 4a2d45a7dbb02e38f59bbca1f35e504ad72dded2 /src/gpu | |
parent | 47e3dbaab5396febbe6173000ea88cca1cf9c211 (diff) |
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
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/batches/GrNonAAStrokeRectBatch.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
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(); } } |