diff options
author | senorblanco <senorblanco@chromium.org> | 2015-09-02 09:05:17 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-02 09:05:17 -0700 |
commit | 06f989a61e4b0237e338a54d2cc0efd531cf0041 (patch) | |
tree | cf44911628f6a896da9fd5cc0311b08ffd08d16b /src/gpu/batches | |
parent | 0cffb171eb2c8b94ec61fcd833df03870eece1b2 (diff) |
Revert of Minor cleanup in GrTessellatingPathRenderer. (patchset #1 id:1 of https://codereview.chromium.org/1322023002/ )
Reason for revert:
Patch is incorrect -- floating point errors can cause zero-area monotone polys to be skipped, resulting in a smaller vertex count than estimated.
Reproduce as follows:
out/Debug/SampleApp --slide Fuzzer --msaa 4
switch to GPU mode. Result:
../../src/gpu/batches/GrTessellatingPathRenderer.cpp:1500: failed assertion "static_cast<int>(end - verts) == vertexCount"
Original issue's description:
> Minor cleanup in GrTessellatingPathRenderer.
>
> Vertex counts are always exact, so don't bother handling the case
> where they're different. Just assert.
> Rename variables to reflect.
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/9389b871c3b0f06bb34626cf9bdbfe0c93779327
TBR=bsalomon@google.com,senorblanco@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/1321723006
Diffstat (limited to 'src/gpu/batches')
-rw-r--r-- | src/gpu/batches/GrTessellatingPathRenderer.cpp | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/gpu/batches/GrTessellatingPathRenderer.cpp b/src/gpu/batches/GrTessellatingPathRenderer.cpp index bc9a6b5d04..46fa280cfd 100644 --- a/src/gpu/batches/GrTessellatingPathRenderer.cpp +++ b/src/gpu/batches/GrTessellatingPathRenderer.cpp @@ -1337,10 +1337,10 @@ SkPoint* polys_to_triangles(Poly* polys, SkPath::FillType fillType, SkPoint* dat struct TessInfo { SkScalar fTolerance; - int fVertexCount; + int fCount; }; -bool cache_match(GrVertexBuffer* vertexBuffer, SkScalar tol, int* vertexCount) { +bool cache_match(GrVertexBuffer* vertexBuffer, SkScalar tol, int* actualCount) { if (!vertexBuffer) { return false; } @@ -1348,7 +1348,7 @@ bool cache_match(GrVertexBuffer* vertexBuffer, SkScalar tol, int* vertexCount) { SkASSERT(data); const TessInfo* info = static_cast<const TessInfo*>(data->data()); if (info->fTolerance == 0 || info->fTolerance < 3.0f * tol) { - *vertexCount = info->fVertexCount; + *actualCount = info->fCount; return true; } return false; @@ -1471,17 +1471,17 @@ private: path_to_contours(path, tol, fClipBounds, contours.get(), alloc, &isLinear); Poly* polys; polys = contours_to_polys(contours.get(), contourCnt, c, alloc); - int vertexCount = 0; + int count = 0; for (Poly* poly = polys; poly; poly = poly->fNext) { if (apply_fill_type(fillType, poly->fWinding) && poly->fCount >= 3) { - vertexCount += (poly->fCount - 2) * (WIREFRAME ? 6 : 3); + count += (poly->fCount - 2) * (WIREFRAME ? 6 : 3); } } - if (0 == vertexCount) { + if (0 == count) { return 0; } - size_t size = vertexCount * sizeof(SkPoint); + size_t size = count * sizeof(SkPoint); if (!vertexBuffer.get() || vertexBuffer->gpuMemorySize() < size) { vertexBuffer.reset(resourceProvider->createVertexBuffer( size, GrResourceProvider::kStatic_BufferUsage, 0)); @@ -1494,15 +1494,16 @@ private: if (canMapVB) { verts = static_cast<SkPoint*>(vertexBuffer->map()); } else { - verts = new SkPoint[vertexCount]; + verts = new SkPoint[count]; } - SkDEBUGCODE(SkPoint* end = ) polys_to_triangles(polys, fillType, verts); - SkASSERT(static_cast<int>(end - verts) == vertexCount); - LOG("vertex count: %d\n", vertexCount); + SkPoint* end = polys_to_triangles(polys, fillType, verts); + int actualCount = static_cast<int>(end - verts); + LOG("actual count: %d\n", actualCount); + SkASSERT(actualCount <= count); if (canMapVB) { vertexBuffer->unmap(); } else { - vertexBuffer->updateData(verts, vertexCount * sizeof(SkPoint)); + vertexBuffer->updateData(verts, actualCount * sizeof(SkPoint)); delete[] verts; } @@ -1510,13 +1511,13 @@ private: if (!fPath.isVolatile()) { TessInfo info; info.fTolerance = isLinear ? 0 : tol; - info.fVertexCount = vertexCount; + info.fCount = actualCount; SkAutoTUnref<SkData> data(SkData::NewWithCopy(&info, sizeof(info))); key->setCustomData(data.get()); resourceProvider->assignUniqueKeyToResource(*key, vertexBuffer.get()); SkPathPriv::AddGenIDChangeListener(fPath, new PathInvalidator(*key)); } - return vertexCount; + return actualCount; } void onPrepareDraws(Target* target) override { @@ -1537,16 +1538,16 @@ private: builder.finish(); GrResourceProvider* rp = target->resourceProvider(); SkAutoTUnref<GrVertexBuffer> vertexBuffer(rp->findAndRefTByUniqueKey<GrVertexBuffer>(key)); - int vertexCount; + int actualCount; SkScalar screenSpaceTol = GrPathUtils::kDefaultTolerance; SkScalar tol = GrPathUtils::scaleToleranceToSrc( screenSpaceTol, fViewMatrix, fPath.getBounds()); - if (!cache_match(vertexBuffer.get(), tol, &vertexCount)) { + if (!cache_match(vertexBuffer.get(), tol, &actualCount)) { bool canMapVB = GrCaps::kNone_MapFlags != target->caps().mapBufferFlags(); - vertexCount = tessellate(&key, rp, vertexBuffer, canMapVB); + actualCount = tessellate(&key, rp, vertexBuffer, canMapVB); } - if (vertexCount == 0) { + if (actualCount == 0) { return; } @@ -1575,7 +1576,7 @@ private: GrPrimitiveType primitiveType = WIREFRAME ? kLines_GrPrimitiveType : kTriangles_GrPrimitiveType; GrVertices vertices; - vertices.init(primitiveType, vertexBuffer.get(), 0, vertexCount); + vertices.init(primitiveType, vertexBuffer.get(), 0, actualCount); target->draw(vertices); } |