No longer round the non-AA clip bounds

By no longer rounding the non-AA clip bounds we increase the probability that a non-AA clip will be dropped when applied to a non-AA rect draw (particularly at half pixel translations).

To make this work in practice we must also make the clip stack check if the non-AA clip is relevant before we preemptively employ a scissor clip.

Note that I have verified that this removes the gross clipping errors from the Chrome repo case but the rounding to scissor clip behavior could still happen in other cases.

Bug: 906496
Change-Id: Iba51b9061fb434144e3a9b3fd91479109fcf67f4
Reviewed-on: https://skia-review.googlesource.com/c/182141
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
Robert Phillips 2019-01-08 12:35:43 -05:00
parent 532c4189b5
commit 9548c3b42f
3 changed files with 9 additions and 13 deletions

View File

@ -507,13 +507,6 @@ void SkClipStack::Element::updateBoundAndGenID(const Element* prior) {
break;
}
if (!fDoAA) {
fFiniteBound.set(SkScalarRoundToScalar(fFiniteBound.fLeft),
SkScalarRoundToScalar(fFiniteBound.fTop),
SkScalarRoundToScalar(fFiniteBound.fRight),
SkScalarRoundToScalar(fFiniteBound.fBottom));
}
// Now determine the previous Element's bound information taking into
// account that there may be no previous clip
SkRect prevFinite;

View File

@ -66,7 +66,14 @@ GrReducedClip::GrReducedClip(const SkClipStack& stack, const SkRect& queryBounds
// "Is intersection of rects" means the clip is a single rect indicated by the stack bounds.
// This should only be true if aa/non-aa status matches among all elements.
SkASSERT(SkClipStack::kNormal_BoundsType == stackBoundsType);
if (GrClip::IsInsideClip(stackBounds, queryBounds)) {
fInitialState = InitialState::kAllIn;
return;
}
SkClipStack::Iter iter(stack, SkClipStack::Iter::kTop_IterStart);
if (!iter.prev()->isAA() || GrClip::IsPixelAligned(stackBounds)) {
// The clip is a non-aa rect. Here we just implement the entire thing using fScissor.
stackBounds.round(&fScissor);
@ -74,10 +81,6 @@ GrReducedClip::GrReducedClip(const SkClipStack& stack, const SkRect& queryBounds
fInitialState = fScissor.isEmpty() ? InitialState::kAllOut : InitialState::kAllIn;
return;
}
if (GrClip::IsInsideClip(stackBounds, queryBounds)) {
fInitialState = InitialState::kAllIn;
return;
}
SkRect tightBounds;
SkAssertResult(tightBounds.intersect(stackBounds, queryBounds));

View File

@ -177,7 +177,7 @@ GrRenderTargetOpList::OpChain::List GrRenderTargetOpList::OpChain::DoConcat(
auto result = a->combineIfPossible(chainB.head(), caps);
SkASSERT(result != GrOp::CombineResult::kCannotCombine);
merged = (result == GrOp::CombineResult::kMerged);
GrOP_INFO("\t\t%d: (%s opID: %u) -> Combining with (%s, opID: %u)\n", i,
GrOP_INFO("\t\t: (%s opID: %u) -> Combining with (%s, opID: %u)\n",
chainB.head()->name(), chainB.head()->uniqueID(), a->name(),
a->uniqueID());
}
@ -254,7 +254,7 @@ GrRenderTargetOpList::OpChain::TryConcat(List chainA, const DstProxy& dstProxyA,
chainA = DoConcat(std::move(chainA), std::move(chainB), caps, pool, auditTrail);
return std::tuple<List, List>(std::move(chainA), List());
case GrOp::CombineResult::kMerged: {
GrOP_INFO("\t\t%d: (%s opID: %u) -> Combining with (%s, opID: %u)\n", i,
GrOP_INFO("\t\t: (%s opID: %u) -> Combining with (%s, opID: %u)\n",
chainB.tail()->name(), chainB.tail()->uniqueID(), chainB.head()->name(),
chainB.head()->uniqueID());
GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(auditTrail, chainA.tail(), chainB.head());