From 60b6bc3c295014db4cefbce1898aa64dea756bff Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Tue, 13 Nov 2018 09:16:15 -0500 Subject: [PATCH] Use WriteVertexData in GrTessellator, remove all DefaultGeoProc structs The structs were previously used to compute vertex strides, and in a couple places to do vertex writing (like this). We're moving to get stride from the GP, and using WriteVertexData to serialize into buffers, so these aren't needed. Bug: skia: Change-Id: If7eb89564e43231633290c8d19b68181e0efa89a Reviewed-on: https://skia-review.googlesource.com/c/170720 Reviewed-by: Brian Salomon Commit-Queue: Brian Osman --- src/gpu/GrDefaultGeoProcFactory.h | 45 ------------------------------- src/gpu/GrTessellator.cpp | 22 +++++---------- 2 files changed, 7 insertions(+), 60 deletions(-) diff --git a/src/gpu/GrDefaultGeoProcFactory.h b/src/gpu/GrDefaultGeoProcFactory.h index 007aea28ead49..3b014f745957a 100644 --- a/src/gpu/GrDefaultGeoProcFactory.h +++ b/src/gpu/GrDefaultGeoProcFactory.h @@ -19,51 +19,6 @@ constexpr int kMaxBones = 80; // Supports up to 80 bones per mesh. * view matrix and wire through color, coverage, UV coords if requested. */ namespace GrDefaultGeoProcFactory { - // Structs for adding vertex attributes - struct PositionAttr { - SkPoint fPosition; - }; - - struct PositionCoverageAttr { - SkPoint fPosition; - float fCoverage; - }; - - struct PositionColorAttr { - SkPoint fPosition; - SkColor fColor; - }; - - struct PositionColorCoverageAttr { - SkPoint fPosition; - SkColor fColor; - float fCoverage; - }; - - struct PositionLocalCoordAttr { - SkPoint fPosition; - SkPoint fLocalCoord; - }; - - struct PositionLocalCoordCoverageAttr { - SkPoint fPosition; - SkPoint fLocalCoord; - float fCoverage; - }; - - struct PositionColorLocalCoordAttr { - SkPoint fPosition; - GrColor fColor; - SkPoint fLocalCoord; - }; - - struct PositionColorLocalCoordCoverageAttr { - SkPoint fPosition; - GrColor fColor; - SkPoint fLocalCoord; - float fCoverage; - }; - struct Color { enum Type { kPremulGrColorUniform_Type, diff --git a/src/gpu/GrTessellator.cpp b/src/gpu/GrTessellator.cpp index 70dd27b23cbc6..b5209a342a042 100644 --- a/src/gpu/GrTessellator.cpp +++ b/src/gpu/GrTessellator.cpp @@ -9,6 +9,7 @@ #include "GrDefaultGeoProcFactory.h" #include "GrPathUtils.h" +#include "ops/GrMeshDrawOp.h" #include "SkArenaAlloc.h" #include "SkGeometry.h" @@ -200,23 +201,14 @@ struct Comparator { inline void* emit_vertex(Vertex* v, const AAParams* aaParams, void* data) { if (!aaParams) { - SkPoint* d = static_cast(data); - *d++ = v->fPoint; - return d; + return GrMeshDrawOp::WriteVertexData(data, v->fPoint); } if (aaParams->fTweakAlpha) { - auto d = static_cast(data); - d->fPosition = v->fPoint; - d->fColor = SkAlphaMulQ(aaParams->fColor, SkAlpha255To256(v->fAlpha)); - d++; - return d; - } - auto d = static_cast(data); - d->fPosition = v->fPoint; - d->fColor = aaParams->fColor; - d->fCoverage = GrNormalizeByteToFloat(v->fAlpha); - d++; - return d; + GrColor color = SkAlphaMulQ(aaParams->fColor, SkAlpha255To256(v->fAlpha)); + return GrMeshDrawOp::WriteVertexData(data, v->fPoint, color); + } + float coverage = GrNormalizeByteToFloat(v->fAlpha); + return GrMeshDrawOp::WriteVertexData(data, v->fPoint, aaParams->fColor, coverage); } void* emit_triangle(Vertex* v0, Vertex* v1, Vertex* v2, const AAParams* aaParams, void* data) {