Chromium Code Reviews| Index: src/gpu/GrDrawContext.cpp |
| diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp |
| index a86e01e72b385328b069f84f412f43bfcc58e604..1d72286d0c5cfdbfa6e2518a7ee8145330d769ec 100644 |
| --- a/src/gpu/GrDrawContext.cpp |
| +++ b/src/gpu/GrDrawContext.cpp |
| @@ -18,6 +18,7 @@ |
| #include "SkSurfacePriv.h" |
| #include "batches/GrBatch.h" |
| +#include "batches/GrClearBatch.h" |
| #include "batches/GrDrawAtlasBatch.h" |
| #include "batches/GrDrawVerticesBatch.h" |
| #include "batches/GrRectBatchFactory.h" |
| @@ -195,7 +196,38 @@ void GrDrawContext::clear(const SkIRect* rect, |
| GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::clear"); |
| AutoCheckFlush acf(fDrawingManager); |
| - this->getDrawTarget()->clear(rect, color, canIgnoreRect, this); |
| + |
| + const SkIRect rtRect = SkIRect::MakeWH(this->width(), this->height()); |
| + SkIRect clippedRect; |
| + if (!rect || |
| + (canIgnoreRect && fContext->caps()->fullClearIsFree()) || |
| + rect->contains(rtRect)) { |
| + rect = &rtRect; |
| + } else { |
| + clippedRect = *rect; |
| + if (!clippedRect.intersect(rtRect)) { |
| + return; |
| + } |
| + rect = &clippedRect; |
| + } |
| + |
| + 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) { |
| + this->discard(); |
| + } |
| + |
| + GrPaint paint; |
| + paint.setColor4f(GrColor4f::FromGrColor(color)); |
| + paint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode)); |
| + |
| + this->drawRect(GrNoClip(), paint, SkMatrix::I(), SkRect::Make(*rect)); |
| + } else { |
| + sk_sp<GrBatch> batch(sk_make_sp<GrClearBatch>(*rect, color, this->accessRenderTarget())); |
|
bsalomon
2016/07/12 18:54:26
It seems to me like this use of sk_sp is hurting r
robertphillips
2016/07/12 19:22:47
Let's try this - hopefully improved.
|
| + this->getDrawTarget()->addBatch(std::move(batch)); |
| + } |
| } |
| @@ -360,7 +392,7 @@ void GrDrawContext::drawRect(const GrClip& clip, |
| // Will it blend? |
| GrColor clearColor; |
| if (paint.isConstantBlendedColor(&clearColor)) { |
| - this->getDrawTarget()->clear(nullptr, clearColor, true, this); |
| + this->clear(nullptr, clearColor, true); |
| return; |
| } |
| } |