Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(386)

Unified Diff: src/gpu/GrContext.cpp

Issue 1123253003: fix bounds for BW lines, AA Hairlines (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrAAHairLinePathRenderer.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrContext.cpp
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index b361b671c3b3080b9373ee30a76daf9ce91d7b7a..725cf0359c5938289cb9a90f0b6695dac4a9ecd2 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -522,6 +522,12 @@ private:
SkScalar rad = SkScalarHalf(geometry.fStrokeWidth);
fBounds.outset(rad, rad);
geometry.fViewMatrix.mapRect(&fBounds);
+
robertphillips 2015/05/07 14:42:02 For this case, BW hairline rect draw, I believe we
bsalomon 2015/05/07 14:47:45 Correct. This is an unfortunate case of coupling w
+ // This is conservative but, b.c. the hardware can employ somewhat arbitrary
+ // snapping rules to BW lines, it is the best we can do.
+ if (fBatch.fHairline) {
+ fBounds.outset(0.5f, 0.5f);
+ }
}
/* create a triangle strip that strokes the specified rect. There are 8
@@ -1021,6 +1027,12 @@ void GrContext::drawVertices(GrRenderTarget* rt,
viewMatrix.mapRect(&bounds);
+ // If we don't have AA then we outset for a half pixel in each direction to account for
+ // snapping
+ if (!paint.isAntiAlias()) {
+ bounds.outset(0.5f, 0.5f);
+ }
+
DrawVerticesBatch::Geometry geometry;
geometry.fColor = paint.getColor();
SkAutoTUnref<GrBatch> batch(DrawVerticesBatch::Create(geometry, primitiveType, viewMatrix,
« no previous file with comments | « src/gpu/GrAAHairLinePathRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698