Index: src/gpu/GrDrawContext.cpp |
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp |
index 3b346b6efd302c68541db2a48701360f57aef9e0..bf2f0fc6f9c4cd3f9fcee63be79d9535bc69ccef 100644 |
--- a/src/gpu/GrDrawContext.cpp |
+++ b/src/gpu/GrDrawContext.cpp |
@@ -195,45 +195,55 @@ void GrDrawContext::clear(const SkIRect* rect, |
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::clear"); |
AutoCheckFlush acf(fDrawingManager); |
+ this->internalClear(rect ? GrFixedClip(*rect) : GrFixedClip::Disabled(), color, canIgnoreRect); |
+} |
- const SkIRect rtRect = SkIRect::MakeWH(this->width(), this->height()); |
- SkIRect clippedRect; |
- bool isFull = false; |
- if (!rect || |
- (canIgnoreRect && fContext->caps()->fullClearIsFree()) || |
- rect->contains(rtRect)) { |
- rect = &rtRect; |
- isFull = true; |
- } else { |
- clippedRect = *rect; |
- if (!clippedRect.intersect(rtRect)) { |
- return; |
csmartdalton
2016/08/23 16:31:23
This is where it used to bail early on a non-inter
|
- } |
- rect = &clippedRect; |
- } |
+void GrDrawContextPriv::clear(const GrFixedClip& clip, |
+ const GrColor color, |
+ bool canIgnoreClip) { |
+ ASSERT_SINGLE_OWNER_PRIV |
+ RETURN_IF_ABANDONED_PRIV |
+ SkDEBUGCODE(fDrawContext->validate();) |
+ GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContextPriv::clear"); |
+ |
+ AutoCheckFlush acf(fDrawContext->fDrawingManager); |
+ fDrawContext->internalClear(clip, color, canIgnoreClip); |
+} |
+ |
+void GrDrawContext::internalClear(const GrFixedClip& clip, |
+ const GrColor color, |
+ bool canIgnoreClip) { |
+ bool isFull = !clip.scissorEnabled() || |
+ (canIgnoreClip && fContext->caps()->fullClearIsFree()) || |
+ clip.scissorRect().contains(SkIRect::MakeWH(this->width(), this->height())); |
if (fContext->caps()->useDrawInsteadOfClear()) { |
// This works around a driver bug with clear by drawing a rect instead. |
// The driver will ignore a clear if it is the only thing rendered to a |
// target before the target is read. |
- if (rect == &rtRect) { |
+ SkRect clearRect = SkRect::MakeIWH(this->width(), this->height()); |
+ if (isFull) { |
this->discard(); |
+ } else if (!clearRect.intersect(SkRect::Make(clip.scissorRect()))) { |
+ return; |
csmartdalton
2016/08/23 16:31:23
Still bails in the "draw instead of clear" case.
|
} |
GrPaint paint; |
paint.setColor4f(GrColor4f::FromGrColor(color)); |
paint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode)); |
- this->drawRect(GrNoClip(), paint, SkMatrix::I(), SkRect::Make(*rect)); |
+ this->drawRect(clip, paint, SkMatrix::I(), clearRect); |
} else if (isFull) { |
this->getDrawTarget()->fullClear(this->accessRenderTarget(), color); |
} else { |
- sk_sp<GrBatch> batch(GrClearBatch::Make(*rect, color, this->accessRenderTarget())); |
+ sk_sp<GrBatch> batch(GrClearBatch::Make(clip, color, this->accessRenderTarget())); |
+ if (!batch) { |
+ return; |
csmartdalton
2016/08/23 16:31:23
But now it relies on GrClearBatch::Make to detect
bsalomon
2016/08/23 16:57:29
Sounds reasonable. lgtm,
|
+ } |
this->getDrawTarget()->addBatch(std::move(batch)); |
} |
} |
- |
void GrDrawContext::drawPaint(const GrClip& clip, |
const GrPaint& origPaint, |
const SkMatrix& viewMatrix) { |
@@ -528,14 +538,14 @@ void GrDrawContext::drawRect(const GrClip& clip, |
this->internalDrawPath(clip, paint, viewMatrix, path, *style); |
} |
-void GrDrawContextPriv::clearStencilClip(const SkIRect& rect, bool insideClip) { |
+void GrDrawContextPriv::clearStencilClip(const GrFixedClip& clip, bool insideStencilMask) { |
ASSERT_SINGLE_OWNER_PRIV |
RETURN_IF_ABANDONED_PRIV |
SkDEBUGCODE(fDrawContext->validate();) |
GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContextPriv::clearStencilClip"); |
AutoCheckFlush acf(fDrawContext->fDrawingManager); |
- fDrawContext->getDrawTarget()->clearStencilClip(rect, insideClip, |
+ fDrawContext->getDrawTarget()->clearStencilClip(clip, insideStencilMask, |
fDrawContext->accessRenderTarget()); |
} |