diff --git a/include/private/GrColor.h b/include/private/GrColor.h index 098dda07a2..1d1f54b029 100644 --- a/include/private/GrColor.h +++ b/include/private/GrColor.h @@ -98,8 +98,6 @@ public: } } - size_t size() const { return fWideColor ? 8 : 4; } - private: friend struct GrVertexWriter; diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp index 6b8f6c67c3..19e77274b1 100644 --- a/src/gpu/ops/GrAAConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp @@ -350,7 +350,7 @@ typedef SkTArray DrawArray; static void create_vertices(const SegmentArray& segments, const SkPoint& fanPt, - const GrVertexColor& color, + GrColor color, DrawArray* draws, GrVertexWriter& verts, uint16_t* idxs, @@ -359,7 +359,6 @@ static void create_vertices(const SegmentArray& segments, // alias just to make vert/index assignments easier to read. int* v = &draw->fVertexCnt; int* i = &draw->fIndexCnt; - const size_t uvOffset = sizeof(SkPoint) + color.size(); int count = segments.count(); for (int a = 0; a < count; ++a) { @@ -480,7 +479,7 @@ static void create_vertices(const SegmentArray& segments, -SK_ScalarMax/100); GrPathUtils::QuadUVMatrix toUV(qpts); - toUV.apply(quadVertsBegin, 6, vertexStride, uvOffset); + toUV.apply(quadVertsBegin, 6, vertexStride, sizeof(SkPoint) + sizeof(GrColor)); idxs[*i + 0] = *v + 3; idxs[*i + 1] = *v + 1; @@ -525,10 +524,8 @@ static void create_vertices(const SegmentArray& segments, class QuadEdgeEffect : public GrGeometryProcessor { public: - static sk_sp Make(const SkMatrix& localMatrix, bool usesLocalCoords, - bool wideColor) { - return sk_sp( - new QuadEdgeEffect(localMatrix, usesLocalCoords, wideColor)); + static sk_sp Make(const SkMatrix& localMatrix, bool usesLocalCoords) { + return sk_sp(new QuadEdgeEffect(localMatrix, usesLocalCoords)); } ~QuadEdgeEffect() override {} @@ -616,12 +613,12 @@ public: } private: - QuadEdgeEffect(const SkMatrix& localMatrix, bool usesLocalCoords, bool wideColor) + QuadEdgeEffect(const SkMatrix& localMatrix, bool usesLocalCoords) : INHERITED(kQuadEdgeEffect_ClassID) , fLocalMatrix(localMatrix) , fUsesLocalCoords(usesLocalCoords) { fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType}; - fInColor = MakeColorAttribute("inColor", wideColor); + fInColor = {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType}; fInQuadEdge = {"inQuadEdge", kFloat4_GrVertexAttribType, kHalf4_GrSLType}; this->setVertexAttributes(&fInPosition, 3); } @@ -644,8 +641,7 @@ GR_DEFINE_GEOMETRY_PROCESSOR_TEST(QuadEdgeEffect); sk_sp QuadEdgeEffect::TestCreate(GrProcessorTestData* d) { // Doesn't work without derivative instructions. return d->caps()->shaderCaps()->shaderDerivativeSupport() - ? QuadEdgeEffect::Make(GrTest::TestMatrix(d->fRandom), d->fRandom->nextBool(), - d->fRandom->nextBool()) + ? QuadEdgeEffect::Make(GrTest::TestMatrix(d->fRandom), d->fRandom->nextBool()) : nullptr; } #endif @@ -686,7 +682,6 @@ public: : INHERITED(ClassID()), fHelper(helperArgs, GrAAType::kCoverage, stencilSettings) { fPaths.emplace_back(PathData{viewMatrix, path, color}); this->setTransformedBounds(path.getBounds(), viewMatrix, HasAABloat::kYes, IsZeroArea::kNo); - fWideColor = !SkPMColor4fFitsInBytes(color); } const char* name() const override { return "AAConvexPathOp"; } @@ -724,8 +719,7 @@ private: // Setup GrGeometryProcessor sk_sp quadProcessor( - QuadEdgeEffect::Make(invert, fHelper.usesLocalCoords(), fWideColor)); - const size_t kVertexStride = quadProcessor->vertexStride(); + QuadEdgeEffect::Make(invert, fHelper.usesLocalCoords())); // TODO generate all segments for all paths and use one vertex buffer for (int i = 0; i < instanceCount; i++) { @@ -764,6 +758,7 @@ private: const GrBuffer* vertexBuffer; int firstVertex; + const size_t kVertexStride = quadProcessor->vertexStride(); GrVertexWriter verts{target->makeVertexSpace(kVertexStride, vertexCount, &vertexBuffer, &firstVertex)}; @@ -782,8 +777,9 @@ private: } SkSTArray draws; - GrVertexColor color(args.fColor, fWideColor); - create_vertices(segments, fanPt, color, &draws, verts, idxs, kVertexStride); + // TODO4F: Preserve float colors + create_vertices(segments, fanPt, args.fColor.toBytes_RGBA(), &draws, verts, idxs, + kVertexStride); GrMesh* meshes = target->allocMeshes(draws.count()); for (int j = 0; j < draws.count(); ++j) { @@ -811,7 +807,6 @@ private: } fPaths.push_back_n(that->fPaths.count(), that->fPaths.begin()); - fWideColor |= that->fWideColor; return CombineResult::kMerged; } @@ -823,7 +818,6 @@ private: Helper fHelper; SkSTArray<1, PathData, true> fPaths; - bool fWideColor; typedef GrMeshDrawOp INHERITED; };