aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2016-07-06 14:38:34 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-06 14:38:34 -0700
commit7e8cc21d574e00d13391da59f00be6bba62c31cd (patch)
tree4a2d45a7dbb02e38f59bbca1f35e504ad72dded2 /src/gpu
parent47e3dbaab5396febbe6173000ea88cca1cf9c211 (diff)
Fix bounds computation for non-aa hairlines when snapping to pixel centers
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/batches/GrNonAAStrokeRectBatch.cpp10
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();
}
}