Reland "Try to avoid vertex colors in Texture/FillRect ops when possible."
This is a reland of e0b989e5e3ab64f3585fe1bf0228e964dad0678c
Original change's description:
> Try to avoid vertex colors in Texture/FillRect ops when possible.
>
> Avoids unnecessary fragment shader color multiplication.
>
> Change-Id: I353d3ca91824ce20c9e9af1c5c84ab9953ddd8ab
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201004
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Change-Id: I22125cb7058f528cb368ff30c3c26e3d55056e66
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201222
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/ops/GrFillRectOp.cpp b/src/gpu/ops/GrFillRectOp.cpp
index d9a11c4..94f90b3 100644
--- a/src/gpu/ops/GrFillRectOp.cpp
+++ b/src/gpu/ops/GrFillRectOp.cpp
@@ -79,7 +79,7 @@
const GrPerspQuad& localQuad, GrQuadType localQuadType)
: INHERITED(ClassID())
, fHelper(args, aaType, stencil)
- , fWideColor(!SkPMColor4fFitsInBytes(paintColor)) {
+ , fColorType(GrQuadPerEdgeAA::MinColorType(paintColor)) {
// The color stored with the quad is the clear color if a scissor-clear is decided upon
// when executing the op.
fDeviceQuads.push_back(deviceQuad, deviceQuadType, { paintColor, edgeFlags });
@@ -178,10 +178,9 @@
using Domain = GrQuadPerEdgeAA::Domain;
static constexpr SkRect kEmptyDomain = SkRect::MakeEmpty();
- VertexSpec vertexSpec(fDeviceQuads.quadType(),
- fWideColor ? ColorType::kHalf : ColorType::kByte,
- fLocalQuads.quadType(), fHelper.usesLocalCoords(), Domain::kNo,
- fHelper.aaType(), fHelper.compatibleWithAlphaAsCoverage());
+ VertexSpec vertexSpec(fDeviceQuads.quadType(), fColorType, fLocalQuads.quadType(),
+ fHelper.usesLocalCoords(), Domain::kNo, fHelper.aaType(),
+ fHelper.compatibleWithAlphaAsCoverage());
// Make sure that if the op thought it was a solid color, the vertex spec does not use
// local coords.
SkASSERT(!fHelper.isTrivial() || !fHelper.usesLocalCoords());
@@ -258,7 +257,7 @@
// If the processor sets are compatible, the two ops are always compatible; it just needs to
// adjust the state of the op to be the more general quad and aa types of the two ops and
// then concatenate the per-quad data.
- fWideColor |= that->fWideColor;
+ fColorType = SkTMax(fColorType, that->fColorType);
// The helper stores the aa type, but isCompatible(with true arg) allows the two ops' aa
// types to be none and coverage, in which case this op's aa type must be lifted to coverage
@@ -297,8 +296,8 @@
}
// clear compatible won't need to be updated, since device quad type and paint is the same,
- // but this quad has a new color, so maybe update wide color
- fWideColor |= !SkPMColor4fFitsInBytes(color);
+ // but this quad has a new color, so maybe update color type
+ fColorType = SkTMax(fColorType, GrQuadPerEdgeAA::MinColorType(color));
// Update the bounds and add the quad to this op's storage
SkRect newBounds = this->bounds();
@@ -328,7 +327,7 @@
// No metadata attached to the local quads; this list is empty when local coords are not needed.
GrQuadList fLocalQuads;
- unsigned fWideColor: 1;
+ ColorType fColorType;
typedef GrMeshDrawOp INHERITED;
};