Avoid assertion in MSAA rendering buffer about indexed draw with zero index count

Also add some GrMesh::validate() calls earlier to make future debugging easier. Previously this only asserted when the draws executed, now it asserts as soon as the draw is prepared in the op subclass.

Bug: skia:
Change-Id: Ibdd4488b9a9263f0ed337a2c8c6066bc36297001
Reviewed-on: https://skia-review.googlesource.com/16029
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrGpuCommandBuffer.cpp b/src/gpu/GrGpuCommandBuffer.cpp
index b51d3ea..a57a13f 100644
--- a/src/gpu/GrGpuCommandBuffer.cpp
+++ b/src/gpu/GrGpuCommandBuffer.cpp
@@ -10,6 +10,7 @@
 #include "GrCaps.h"
 #include "GrFixedClip.h"
 #include "GrGpu.h"
+#include "GrMesh.h"
 #include "GrPrimitiveProcessor.h"
 #include "GrRenderTarget.h"
 #include "SkRect.h"
@@ -39,6 +40,7 @@
                               const GrMesh* mesh,
                               int meshCount,
                               const SkRect& bounds) {
+    SkDEBUGCODE(mesh->validate());
     if (pipeline.isBad() || primProc.isBad()) {
         return false;
     }
diff --git a/src/gpu/ops/GrMSAAPathRenderer.cpp b/src/gpu/ops/GrMSAAPathRenderer.cpp
index b2782df..49f8259 100644
--- a/src/gpu/ops/GrMSAAPathRenderer.cpp
+++ b/src/gpu/ops/GrMSAAPathRenderer.cpp
@@ -380,11 +380,9 @@
             quads.indices = nullptr;
             quads.nextIndex = nullptr;
         }
-
         // fill buffers
         for (int i = 0; i < fPaths.count(); i++) {
             const PathInfo& pathInfo = fPaths[i];
-
             if (!this->createGeom(lines,
                                   quads,
                                   pathInfo.fPath,
@@ -423,7 +421,12 @@
             lineMeshes.fVertexCount = lineVertexOffset;
             lineMeshes.fBaseVertex = firstLineVertex;
 
-            target->draw(lineGP.get(), this->pipeline(), lineMeshes);
+            // We can get line vertices from path moveTos with no actual segments and thus no index
+            // count. We assert that indexed draws contain a positive index count, so bail here in
+            // that case.
+            if (!fIsIndexed || lineIndexOffset) {
+                target->draw(lineGP.get(), this->pipeline(), lineMeshes);
+            }
         }
 
         if (quadVertexOffset) {
diff --git a/src/gpu/ops/GrMeshDrawOp.cpp b/src/gpu/ops/GrMeshDrawOp.cpp
index ee7c0a5..c452150 100644
--- a/src/gpu/ops/GrMeshDrawOp.cpp
+++ b/src/gpu/ops/GrMeshDrawOp.cpp
@@ -96,6 +96,7 @@
 
 void GrMeshDrawOp::Target::draw(const GrGeometryProcessor* gp, const GrPipeline* pipeline,
                                 const GrMesh& mesh) {
+    SkDEBUGCODE(mesh.validate());
     GrMeshDrawOp* op = this->meshDrawOp();
     op->fMeshes.push_back(mesh);
     if (!op->fQueuedDraws.empty()) {