From 212c7c389e81053b84a3ed7775f2031d76d5ee70 Mon Sep 17 00:00:00 2001 From: senorblanco Date: Thu, 18 Aug 2016 10:20:47 -0700 Subject: Tessellator: better fix for reused-edges issue. The GrTessellator fix for doubly-added edges in https://codereview.chromium.org/2259493002/ could leave a MonotonePoly with zero edges. This is a problem for Poly::addEdge(), which assumes that MonotonePolys always have at least one edge. The fix is to move the check and early-out up to Poly::addEdge(). This should also tighten up the vertex count. (Unfortunately, the only repro I have for this issue is very convoluted, and requires non-landed code.) BUG=skia:5636 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2251643008 Review-Url: https://codereview.chromium.org/2251643008 --- src/gpu/GrTessellator.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gpu/GrTessellator.cpp b/src/gpu/GrTessellator.cpp index 50d4af6148..ccffa9ffbe 100644 --- a/src/gpu/GrTessellator.cpp +++ b/src/gpu/GrTessellator.cpp @@ -360,16 +360,12 @@ struct Poly { MonotonePoly* fNext; void addEdge(Edge* edge) { if (fSide == kRight_Side) { - if (edge->fUsedInRightPoly) { - return; - } + SkASSERT(!edge->fUsedInRightPoly); list_insert( edge, fLastEdge, nullptr, &fFirstEdge, &fLastEdge); edge->fUsedInRightPoly = true; } else { - if (edge->fUsedInLeftPoly) { - return; - } + SkASSERT(!edge->fUsedInLeftPoly); list_insert( edge, fLastEdge, nullptr, &fFirstEdge, &fLastEdge); edge->fUsedInLeftPoly = true; @@ -423,6 +419,15 @@ struct Poly { e->fTop->fID, e->fBottom->fID, fID, side == kLeft_Side ? "left" : "right"); Poly* partner = fPartner; Poly* poly = this; + if (side == kRight_Side) { + if (e->fUsedInRightPoly) { + return this; + } + } else { + if (e->fUsedInLeftPoly) { + return this; + } + } if (partner) { fPartner = partner->fPartner = nullptr; } -- cgit v1.2.3