Make GrFillRectOp and GrTextureOp consistent re AA-upgrading and size checks
I believe GrFillRectOp wasn't handling AA-upgrading correctly. Both ops now also check that they aren't exceeding the index buffer limits for both AA and non-AA draws.
Change-Id: Iae586b92e1f27a908a54ae881f2b1db21ec1afc8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/251360
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/gpu/ops/GrFillRectOp.cpp b/src/gpu/ops/GrFillRectOp.cpp
index b6bd2f7..bcdd878 100644
--- a/src/gpu/ops/GrFillRectOp.cpp
+++ b/src/gpu/ops/GrFillRectOp.cpp
@@ -247,10 +247,23 @@
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
const auto* that = t->cast<FillRectOp>();
- if ((fHelper.aaType() == GrAAType::kCoverage ||
- that->fHelper.aaType() == GrAAType::kCoverage) &&
- fQuads.count() + that->fQuads.count() > GrResourceProvider::MaxNumAAQuads()) {
- return CombineResult::kCannotCombine;
+ bool upgradeToCoverageAAOnMerge = false;
+ if (fHelper.aaType() != that->fHelper.aaType()) {
+ if (!GrSimpleMeshDrawOpHelper::CanUpgradeAAOnMerge(fHelper.aaType(),
+ that->fHelper.aaType())) {
+ return CombineResult::kCannotCombine;
+ }
+ upgradeToCoverageAAOnMerge = true;
+ }
+
+ if (fHelper.aaType() == GrAAType::kCoverage || upgradeToCoverageAAOnMerge) {
+ if (fQuads.count() + that->fQuads.count() > GrResourceProvider::MaxNumAAQuads()) {
+ return CombineResult::kCannotCombine;
+ }
+ } else {
+ if (fQuads.count() + that->fQuads.count() > GrResourceProvider::MaxNumNonAAQuads()) {
+ return CombineResult::kCannotCombine;
+ }
}
// Unlike most users of the draw op helper, this op can merge none-aa and coverage-aa draw
@@ -270,7 +283,7 @@
// 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
// so that quads with no aa edges can be batched with quads that have some/all edges aa'ed.
- if (fHelper.aaType() == GrAAType::kNone && that->fHelper.aaType() == GrAAType::kCoverage) {
+ if (upgradeToCoverageAAOnMerge) {
fHelper.setAAType(GrAAType::kCoverage);
}