Don't simplify strokes that could have been tessellated
Bug: chromium:1172543
Change-Id: I3be0d822ca0a338118059c7aa37b2fd7822869b8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362936
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrSurfaceDrawContext.cpp b/src/gpu/GrSurfaceDrawContext.cpp
index a95319b..b318360 100644
--- a/src/gpu/GrSurfaceDrawContext.cpp
+++ b/src/gpu/GrSurfaceDrawContext.cpp
@@ -1787,19 +1787,6 @@
return;
}
- // Always simplify the stroke for now. In the future we will give the tessellator a chance to
- // claim strokes before trying to simplify them.
- shape.simplifyStroke();
-
- if (attemptDrawSimple || shape.simplified()) {
- // Usually we enter drawShapeUsingPathRenderer() because the shape+style was too
- // complex for dedicated draw ops. However, if GrStyledShape was able to reduce something
- // we ought to try again instead of going right to path rendering.
- if (this->drawSimpleShape(clip, &paint, aa, viewMatrix, shape)) {
- return;
- }
- }
-
SkIRect clipConservativeBounds = get_clip_bounds(this, clip);
GrAAType aaType = this->chooseAAType(aa);
@@ -1813,17 +1800,43 @@
canDrawArgs.fClipConservativeBounds = &clipConservativeBounds;
canDrawArgs.fTargetIsWrappedVkSecondaryCB = this->wrapsVkSecondaryCB();
canDrawArgs.fHasUserStencilSettings = false;
-
- GrPathRenderer* pr;
- static constexpr GrPathRendererChain::DrawType kType = GrPathRendererChain::DrawType::kColor;
- if (shape.isEmpty() && !shape.inverseFilled()) {
- return;
- }
-
canDrawArgs.fAAType = aaType;
- // Try a 1st time without applying any of the style to the geometry (and barring sw)
- pr = this->drawingManager()->getPathRenderer(canDrawArgs, false, kType);
+ constexpr static bool kDisallowSWPathRenderer = false;
+ constexpr static bool kAllowSWPathRenderer = true;
+ using DrawType = GrPathRendererChain::DrawType;
+
+ GrPathRenderer* pr = nullptr;
+
+ if (!shape.style().strokeRec().isFillStyle() && !shape.isEmpty()) {
+ // Give path renderers with dedicated stroke handling (e.g., tessellation) a chance to claim
+ // this stroke before we attempt to simplify it.
+ pr = this->drawingManager()->getPathRenderer(canDrawArgs, kDisallowSWPathRenderer,
+ DrawType::kColor);
+ }
+
+ if (!pr) {
+ // The shape isn't a stroke that can be drawn directly. Simplify if possible.
+ shape.simplifyStroke();
+
+ if (shape.isEmpty() && !shape.inverseFilled()) {
+ return;
+ }
+
+ if (attemptDrawSimple || shape.simplified()) {
+ // Usually we enter drawShapeUsingPathRenderer() because the shape+style was too complex
+ // for dedicated draw ops. However, if GrStyledShape was able to reduce something we
+ // ought to try again instead of going right to path rendering.
+ if (this->drawSimpleShape(clip, &paint, aa, viewMatrix, shape)) {
+ return;
+ }
+ }
+
+ // Try a 1st time without applying any of the style to the geometry (and barring sw)
+ pr = this->drawingManager()->getPathRenderer(canDrawArgs, kDisallowSWPathRenderer,
+ DrawType::kColor);
+ }
+
SkScalar styleScale = GrStyle::MatrixToScaleFactor(viewMatrix);
if (!pr && shape.style().pathEffect()) {
@@ -1832,7 +1845,8 @@
if (shape.isEmpty()) {
return;
}
- pr = this->drawingManager()->getPathRenderer(canDrawArgs, false, kType);
+ pr = this->drawingManager()->getPathRenderer(canDrawArgs, kDisallowSWPathRenderer,
+ DrawType::kColor);
}
if (!pr) {
if (shape.style().applies()) {
@@ -1841,7 +1855,8 @@
return;
}
// This time, allow SW renderer
- pr = this->drawingManager()->getPathRenderer(canDrawArgs, true, kType);
+ pr = this->drawingManager()->getPathRenderer(canDrawArgs, kAllowSWPathRenderer,
+ DrawType::kColor);
} else {
pr = this->drawingManager()->getSoftwarePathRenderer();
#if GR_PATH_RENDERER_SPEW