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

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: Fix typo 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
« no previous file with comments | « gyp/gpu.gypi ('k') | src/gpu/GrDrawTarget.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawContext.cpp
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index a86e01e72b385328b069f84f412f43bfcc58e604..80b18ecf884c27d9c95e201772a44e5b2050c7a6 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 = GrClearBatch::Make(*rect, color, this->accessRenderTarget());
+ 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698