From a098dd490cc4e434f054b7506c2f6e08f519585b Mon Sep 17 00:00:00 2001 From: bsalomon Date: Wed, 6 Aug 2014 11:01:44 -0700 Subject: [PATCH] Fix drawVertices() on GPU when texs=colors=shaders=indices=null R=reed@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/449433003 --- src/gpu/SkGpuDevice.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 7c4f451..48ae845 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1622,7 +1622,7 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, SkAutoTDeleteArray outAlloc(NULL); GrPrimitiveType primType; GrPaint grPaint; - + // If both textures and vertex-colors are NULL, strokes hairlines with the paint's color. if ((NULL == texs || NULL == paint.getShader()) && NULL == colors) { @@ -1638,13 +1638,14 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, primType = kLines_GrPrimitiveType; int triangleCount = 0; + int n = (NULL == indices) ? vertexCount : indexCount; switch (vmode) { case SkCanvas::kTriangles_VertexMode: - triangleCount = indexCount / 3; + triangleCount = n / 3; break; case SkCanvas::kTriangleStrip_VertexMode: case SkCanvas::kTriangleFan_VertexMode: - triangleCount = indexCount - 2; + triangleCount = n - 2; break; } -- 2.7.4