Don't clip non-AA quads

Minor optimization. When non-AA, the quad corners are never moved so it
won't go through the math that requires w > 0. The GPU is perfectly
capable of clipping to w > 0, except that it produces a non-AA edge;
for AA quads this is a problem, but not so when the draw was non-AA.

Change-Id: Ibf77b678f5b3b90a5a88fb3670a31cd12ff3775f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269762
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
Michael Ludwig 2020-02-10 09:30:04 -05:00 committed by Skia Commit-Bot
parent a49de4de63
commit 465864cad5
2 changed files with 10 additions and 3 deletions

View File

@ -86,7 +86,10 @@ public:
IsHairline::kNo);
DrawQuad extra;
int count = GrQuadUtils::ClipToW0(quad, &extra);
// Only clip when there's anti-aliasing. When non-aa, the GPU clips just fine and there's
// no inset/outset math that requires w > 0.
int count = quad->fEdgeFlags != GrQuadAAFlags::kNone ? GrQuadUtils::ClipToW0(quad, &extra)
: 1;
if (count == 0) {
// We can't discard the op at this point, but disable AA flags so it won't go through
// inset/outset processing
@ -379,7 +382,8 @@ private:
newBounds.joinPossiblyEmptyRect(quad->fDevice.bounds());
DrawQuad extra;
int count = GrQuadUtils::ClipToW0(quad, &extra);
int count = quad->fEdgeFlags != GrQuadAAFlags::kNone ? GrQuadUtils::ClipToW0(quad, &extra)
: 1;
if (count == 0 ) {
// Just skip the append (trivial success)
return true;

View File

@ -624,7 +624,10 @@ private:
int appendQuad(DrawQuad* quad, const SkPMColor4f& color, const SkRect& domain) {
DrawQuad extra;
int quadCount = GrQuadUtils::ClipToW0(quad, &extra);
// Only clip when there's anti-aliasing. When non-aa, the GPU clips just fine and there's
// no inset/outset math that requires w > 0.
int quadCount = quad->fEdgeFlags != GrQuadAAFlags::kNone ?
GrQuadUtils::ClipToW0(quad, &extra) : 1;
if (quadCount == 0) {
// We can't discard the op at this point, but disable AA flags so it won't go through
// inset/outset processing