Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 465864c

Browse files
lhkbobSkia Commit-Bot
authored andcommitted
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 <[email protected]> Commit-Queue: Michael Ludwig <[email protected]>
1 parent a49de4d commit 465864c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/gpu/ops/GrFillRectOp.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ class FillRectOp final : public GrMeshDrawOp {
8686
IsHairline::kNo);
8787

8888
DrawQuad extra;
89-
int count = GrQuadUtils::ClipToW0(quad, &extra);
89+
// Only clip when there's anti-aliasing. When non-aa, the GPU clips just fine and there's
90+
// no inset/outset math that requires w > 0.
91+
int count = quad->fEdgeFlags != GrQuadAAFlags::kNone ? GrQuadUtils::ClipToW0(quad, &extra)
92+
: 1;
9093
if (count == 0) {
9194
// We can't discard the op at this point, but disable AA flags so it won't go through
9295
// inset/outset processing
@@ -379,7 +382,8 @@ class FillRectOp final : public GrMeshDrawOp {
379382
newBounds.joinPossiblyEmptyRect(quad->fDevice.bounds());
380383

381384
DrawQuad extra;
382-
int count = GrQuadUtils::ClipToW0(quad, &extra);
385+
int count = quad->fEdgeFlags != GrQuadAAFlags::kNone ? GrQuadUtils::ClipToW0(quad, &extra)
386+
: 1;
383387
if (count == 0 ) {
384388
// Just skip the append (trivial success)
385389
return true;

src/gpu/ops/GrTextureOp.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,10 @@ class TextureOp final : public GrMeshDrawOp {
624624

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

0 commit comments

Comments
 (0)