Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Unified Diff: src/gpu/GrDrawContext.cpp

Issue 2145643003: Move GrDrawTarget::clear logic into GrDrawContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}
}
« no previous file with comments | « gyp/gpu.gypi ('k') | src/gpu/GrDrawTarget.h » ('j') | src/gpu/batches/GrClearStencilClipBatch.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698