Remove origin from GrClipStackClip and GrWindowRectsState.
Change-Id: I993f426fee0f21cf1f529f58d242de3017253678
Reviewed-on: https://skia-review.googlesource.com/9623
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index a0682f4..b2dd936 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -33,16 +33,14 @@
if (!fStack || fStack->isWideOpen()) {
return true;
}
- return fStack->quickContains(rect.makeOffset(SkIntToScalar(fOrigin.x()),
- SkIntToScalar(fOrigin.y())));
+ return fStack->quickContains(rect);
}
bool GrClipStackClip::quickContains(const SkRRect& rrect) const {
if (!fStack || fStack->isWideOpen()) {
return true;
}
- return fStack->quickContains(rrect.makeOffset(SkIntToScalar(fOrigin.fX),
- SkIntToScalar(fOrigin.fY)));
+ return fStack->quickContains(rrect);
}
bool GrClipStackClip::isRRect(const SkRect& origRTBounds, SkRRect* rr, GrAA* aa) const {
@@ -50,19 +48,9 @@
return false;
}
const SkRect* rtBounds = &origRTBounds;
- SkRect tempRTBounds;
- bool origin = fOrigin.fX || fOrigin.fY;
- if (origin) {
- tempRTBounds = origRTBounds;
- tempRTBounds.offset(SkIntToScalar(fOrigin.fX), SkIntToScalar(fOrigin.fY));
- rtBounds = &tempRTBounds;
- }
bool isAA;
if (fStack->isRRect(*rtBounds, rr, &isAA)) {
*aa = GrBoolToAA(isAA);
- if (origin) {
- rr->offset(-SkIntToScalar(fOrigin.fX), -SkIntToScalar(fOrigin.fY));
- }
return true;
}
return false;
@@ -78,8 +66,7 @@
return;
}
SkRect devBounds;
- fStack->getConservativeBounds(-fOrigin.x(), -fOrigin.y(), width, height, &devBounds,
- isIntersectionOfRects);
+ fStack->getConservativeBounds(0, 0, width, height, &devBounds, isIntersectionOfRects);
devBounds.roundOut(devResult);
}
@@ -187,11 +174,8 @@
static bool get_analytic_clip_processor(const ElementList& elements,
bool abortIfAA,
- const SkVector& clipToRTOffset,
- const SkRect& drawBounds,
+ const SkRect& drawDevBounds,
sk_sp<GrFragmentProcessor>* resultFP) {
- SkRect boundsInClipSpace;
- boundsInClipSpace = drawBounds.makeOffset(-clipToRTOffset.fX, -clipToRTOffset.fY);
SkASSERT(elements.count() <= kMaxAnalyticElements);
SkSTArray<kMaxAnalyticElements, sk_sp<GrFragmentProcessor>> fps;
ElementList::Iter iter(elements);
@@ -205,7 +189,7 @@
// Fallthrough, handled same as intersect.
case kIntersect_SkClipOp:
invert = false;
- if (iter.get()->contains(boundsInClipSpace)) {
+ if (iter.get()->contains(drawDevBounds)) {
skip = true;
}
break;
@@ -232,19 +216,14 @@
switch (iter.get()->getType()) {
case SkClipStack::Element::kPath_Type:
- fps.emplace_back(GrConvexPolyEffect::Make(edgeType, iter.get()->getPath(),
- &clipToRTOffset));
+ fps.emplace_back(GrConvexPolyEffect::Make(edgeType, iter.get()->getPath()));
break;
case SkClipStack::Element::kRRect_Type: {
- SkRRect rrect = iter.get()->getRRect();
- rrect.offset(clipToRTOffset.fX, clipToRTOffset.fY);
- fps.emplace_back(GrRRectEffect::Make(edgeType, rrect));
+ fps.emplace_back(GrRRectEffect::Make(edgeType, iter.get()->getRRect()));
break;
}
case SkClipStack::Element::kRect_Type: {
- SkRect rect = iter.get()->getRect();
- rect.offset(clipToRTOffset.fX, clipToRTOffset.fY);
- fps.emplace_back(GrConvexPolyEffect::Make(edgeType, rect));
+ fps.emplace_back(GrConvexPolyEffect::Make(edgeType, iter.get()->getRect()));
break;
}
default:
@@ -279,22 +258,15 @@
return false;
}
- const SkScalar clipX = SkIntToScalar(fOrigin.x()),
- clipY = SkIntToScalar(fOrigin.y());
-
- SkRect clipSpaceDevBounds = devBounds.makeOffset(clipX, clipY);
- const GrReducedClip reducedClip(*fStack, clipSpaceDevBounds,
+ const GrReducedClip reducedClip(*fStack, devBounds,
renderTargetContext->priv().maxWindowRectangles());
- if (reducedClip.hasIBounds() &&
- !GrClip::IsInsideClip(reducedClip.ibounds(), clipSpaceDevBounds)) {
- SkIRect scissorSpaceIBounds(reducedClip.ibounds());
- scissorSpaceIBounds.offset(-fOrigin);
- out->addScissor(scissorSpaceIBounds);
+ if (reducedClip.hasIBounds() && !GrClip::IsInsideClip(reducedClip.ibounds(), devBounds)) {
+ out->addScissor(reducedClip.ibounds());
}
if (!reducedClip.windowRectangles().empty()) {
- out->addWindowRectangles(reducedClip.windowRectangles(), fOrigin,
+ out->addWindowRectangles(reducedClip.windowRectangles(),
GrWindowRectsState::Mode::kExclusive);
}
@@ -306,7 +278,7 @@
SkASSERT(reducedClip.hasIBounds());
SkIRect rtIBounds = SkIRect::MakeWH(renderTargetContext->width(),
renderTargetContext->height());
- SkIRect clipIBounds = reducedClip.ibounds().makeOffset(-fOrigin.x(), -fOrigin.y());
+ const SkIRect& clipIBounds = reducedClip.ibounds();
SkASSERT(rtIBounds.contains(clipIBounds)); // Mask shouldn't be larger than the RT.
#endif
@@ -330,8 +302,8 @@
}
sk_sp<GrFragmentProcessor> clipFP;
if (reducedClip.requiresAA() &&
- get_analytic_clip_processor(reducedClip.elements(), disallowAnalyticAA,
- {-clipX, -clipY}, devBounds, &clipFP)) {
+ get_analytic_clip_processor(reducedClip.elements(), disallowAnalyticAA, devBounds,
+ &clipFP)) {
out->addCoverageFP(std::move(clipFP));
return true;
}
@@ -350,10 +322,9 @@
if (result) {
// The mask's top left coord should be pinned to the rounded-out top left corner of
- // clipSpace bounds. We determine the mask's position WRT to the render target here.
- SkIRect rtSpaceMaskBounds = reducedClip.ibounds();
- rtSpaceMaskBounds.offset(-fOrigin);
- out->addCoverageFP(create_fp_for_mask(context, std::move(result), rtSpaceMaskBounds));
+ // the clip's device space bounds.
+ out->addCoverageFP(create_fp_for_mask(context, std::move(result),
+ reducedClip.ibounds()));
return true;
}
// if alpha clip mask creation fails fall through to the non-AA code paths
@@ -374,10 +345,9 @@
// relevant window rectangles that were in the last clip. This subtle requirement will go away
// after clipping is overhauled.
if (renderTargetContext->priv().mustRenderClip(reducedClip.elementsGenID(),
- reducedClip.ibounds(), fOrigin)) {
- reducedClip.drawStencilClipMask(context, renderTargetContext, fOrigin);
- renderTargetContext->priv().setLastClip(reducedClip.elementsGenID(), reducedClip.ibounds(),
- fOrigin);
+ reducedClip.ibounds())) {
+ reducedClip.drawStencilClipMask(context, renderTargetContext);
+ renderTargetContext->priv().setLastClip(reducedClip.elementsGenID(), reducedClip.ibounds());
}
out->addStencilClip();
return true;
@@ -391,7 +361,7 @@
GrUniqueKey::Builder builder(key, kDomain, 3, GrClipStackClip::kMaskTestTag);
builder[0] = clipGenID;
// SkToS16 because image filters outset layers to a size indicated by the filter, which can
- // sometimes result in negative coordinates from clip space.
+ // sometimes result in negative coordinates from device space.
builder[1] = SkToS16(bounds.fLeft) | (SkToS16(bounds.fRight) << 16);
builder[2] = SkToS16(bounds.fTop) | (SkToS16(bounds.fBottom) << 16);
}
@@ -464,8 +434,8 @@
return GrSurfaceProxy::MakeWrapped(std::move(texture));
}
- // The mask texture may be larger than necessary. We round out the clip space bounds and pin
- // the top left corner of the resulting rect to the top left of the texture.
+ // The mask texture may be larger than necessary. We round out the clip bounds and pin the top
+ // left corner of the resulting rect to the top left of the texture.
SkIRect maskSpaceIBounds = SkIRect::MakeWH(reducedClip.width(), reducedClip.height());
GrSWMaskHelper helper;