Update how we send draws to gpu backend to reduce state setting.
The main change here is that we pull primitive type off of the vertices, we set the gpu state on gpu once per pipeline/prim proc draw batch, and we create the ProgramDescriptor only for the Cache/ProgramBuilder.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1806983002
Review URL: https://codereview.chromium.org/1806983002
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 512ce9b..f3f00f1 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -12,6 +12,7 @@
#include "GrContext.h"
#include "GrGpuResourcePriv.h"
#include "GrIndexBuffer.h"
+#include "GrMesh.h"
#include "GrPathRendering.h"
#include "GrPipeline.h"
#include "GrResourceCache.h"
@@ -21,10 +22,9 @@
#include "GrSurfacePriv.h"
#include "GrTransferBuffer.h"
#include "GrVertexBuffer.h"
-#include "GrVertices.h"
#include "SkTypes.h"
-GrVertices& GrVertices::operator =(const GrVertices& di) {
+GrMesh& GrMesh::operator =(const GrMesh& di) {
fPrimitiveType = di.fPrimitiveType;
fStartVertex = di.fStartVertex;
fStartIndex = di.fStartIndex;
@@ -492,17 +492,12 @@
////////////////////////////////////////////////////////////////////////////////
-void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) {
+void GrGpu::draw(const GrPipeline& pipeline,
+ const GrPrimitiveProcessor& primProc,
+ const GrMesh* meshes,
+ int meshCount) {
this->handleDirtyContext();
- if (GrXferBarrierType barrierType = args.fPipeline->xferBarrierType(*this->caps())) {
- this->xferBarrier(args.fPipeline->getRenderTarget(), barrierType);
- }
- GrVertices::Iterator iter;
- const GrNonInstancedVertices* verts = iter.init(vertices);
- do {
- this->onDraw(args, *verts);
- fStats.incNumDraws();
- } while ((verts = iter.next()));
+ this->onDraw(pipeline, primProc, meshes, meshCount);
}