Index: src/gpu/batches/GrTessellatingPathRenderer.cpp |
diff --git a/src/gpu/batches/GrTessellatingPathRenderer.cpp b/src/gpu/batches/GrTessellatingPathRenderer.cpp |
index bc9a6b5d040b362a96b6a86451ed1227a813c93c..46fa280cfd86c6e67a429c547a1e987e1af6f135 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); |
} |