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

Unified Diff: src/gpu/batches/GrRectBatchFactory.cpp

Issue 1359453002: Fix for degenerate stroke rect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: handle degenerate stroke rects Created 5 years, 3 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
Index: src/gpu/batches/GrRectBatchFactory.cpp
diff --git a/src/gpu/batches/GrRectBatchFactory.cpp b/src/gpu/batches/GrRectBatchFactory.cpp
index eed18ad419637e788065495cf2729ae748fb6fa1..1b4255462c3d9c0643a143afefaa7ed038f53ab1 100644
--- a/src/gpu/batches/GrRectBatchFactory.cpp
+++ b/src/gpu/batches/GrRectBatchFactory.cpp
@@ -33,13 +33,6 @@ GrDrawBatch* CreateAAStroke(GrColor color,
const SkScalar rx = SkScalarMul(dx, SK_ScalarHalf);
const SkScalar ry = SkScalarMul(dy, SK_ScalarHalf);
- SkScalar spare;
- {
- SkScalar w = devRect.width() - dx;
- SkScalar h = devRect.height() - dy;
- spare = SkTMin(w, h);
- }
-
SkRect devOutside(devRect);
devOutside.outset(rx, ry);
@@ -51,13 +44,28 @@ GrDrawBatch* CreateAAStroke(GrColor color,
miterStroke = false;
}
- if (spare <= 0 && miterStroke) {
- return CreateAAFill(color, viewMatrix, devOutside, devOutside);
- }
-
SkRect devInside(devRect);
devInside.inset(rx, ry);
+ // If we have a degenerate stroking rect(ie the stroke is larger than inner rect) then we
+ // make a degenerate inside rect to avoid double hitting. We will also jam all of the points
+ // together when we render these rects.
+ SkScalar spare;
+ {
+ SkScalar w = devRect.width() - dx;
+ SkScalar h = devRect.height() - dy;
+ spare = SkTMin(w, h);
+ }
+
+ bool degenerate = spare <= 0;
+ if (degenerate) {
robertphillips 2015/09/21 17:12:44 Just use devRect.centerX() ?
joshualitt 2015/09/21 19:51:25 Acknowledged.
+ SkScalar midPoint = devRect.width() / 2.0f + devRect.fLeft;
+ devInside.fLeft = devInside.fRight = midPoint;
+
robertphillips 2015/09/21 17:12:44 Just use devRect.centerY() ?
joshualitt 2015/09/21 19:51:25 Acknowledged.
+ midPoint = devRect.height() / 2.0f + devRect.fTop;
+ devInside.fTop = devInside.fBottom = midPoint;
+ }
+
SkRect devOutsideAssist(devRect);
// For bevel-stroke, use 2 SkRect instances(devOutside and devOutsideAssist)
@@ -69,7 +77,7 @@ GrDrawBatch* CreateAAStroke(GrColor color,
}
return GrAAStrokeRectBatch::Create(color, viewMatrix, devOutside, devOutsideAssist, devInside,
- miterStroke);
+ miterStroke, degenerate);
}
GrDrawBatch* CreateAAFillNestedRects(GrColor color,
@@ -86,7 +94,8 @@ GrDrawBatch* CreateAAFillNestedRects(GrColor color,
return CreateAAFill(color, viewMatrix, devOutside, devOutside);
}
- return GrAAStrokeRectBatch::Create(color, viewMatrix, devOutside, devOutside, devInside, true);
+ return GrAAStrokeRectBatch::Create(color, viewMatrix, devOutside, devOutside, devInside, true,
+ false);
}
};
« src/gpu/batches/GrAAStrokeRectBatch.cpp ('K') | « src/gpu/batches/GrAAStrokeRectBatch.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698