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

Unified Diff: src/gpu/batches/GrMSAAPathRenderer.cpp

Issue 2035823002: Make GrClipMaskManager stateless and push GrPipelineBuilder construction downstack (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address code review comments Created 4 years, 6 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/batches/GrMSAAPathRenderer.cpp
diff --git a/src/gpu/batches/GrMSAAPathRenderer.cpp b/src/gpu/batches/GrMSAAPathRenderer.cpp
index 2072175ef5ff55462f4b38dae6eec70581ee9c17..887c5273647822e5e6282018d2aa1fad9db80d40 100644
--- a/src/gpu/batches/GrMSAAPathRenderer.cpp
+++ b/src/gpu/batches/GrMSAAPathRenderer.cpp
@@ -7,7 +7,9 @@
#include "GrMSAAPathRenderer.h"
+#include "GrAuditTrail.h"
#include "GrBatchFlushState.h"
+#include "GrClip.h"
#include "GrDefaultGeoProcFactory.h"
#include "GrPathStencilSettings.h"
#include "GrPathUtils.h"
@@ -566,19 +568,14 @@ private:
typedef GrVertexBatch INHERITED;
};
-bool GrMSAAPathRenderer::internalDrawPath(GrDrawTarget* target,
- GrPipelineBuilder* pipelineBuilder,
+bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext,
+ const GrPaint& paint,
+ const GrUserStencilSettings* userStencilSettings,
const GrClip& clip,
GrColor color,
const SkMatrix& viewMatrix,
const SkPath& path,
bool stencilOnly) {
-
- const GrXPFactory* xpFactory = pipelineBuilder->getXPFactory();
- SkAutoTUnref<const GrXPFactory> backupXPFactory(SkSafeRef(xpFactory));
- // face culling doesn't make sense here
- SkASSERT(GrPipelineBuilder::kBoth_DrawFace == pipelineBuilder->getDrawFace());
-
int passCount = 0;
const GrUserStencilSettings* passes[3];
GrPipelineBuilder::DrawFace drawFace[3];
@@ -643,21 +640,13 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawTarget* target,
}
SkRect devBounds;
- GetPathDevBounds(path, pipelineBuilder->getRenderTarget(), viewMatrix, &devBounds);
+ GetPathDevBounds(path, drawContext->width(), drawContext->height(), viewMatrix, &devBounds);
for (int p = 0; p < passCount; ++p) {
- pipelineBuilder->setDrawFace(drawFace[p]);
- if (passes[p]) {
- pipelineBuilder->setUserStencil(passes[p]);
- }
-
if (lastPassIsBounds && (p == passCount-1)) {
- // Reset the XP Factory on pipelineBuilder
- pipelineBuilder->setXPFactory(backupXPFactory);
SkRect bounds;
SkMatrix localMatrix = SkMatrix::I();
if (reverse) {
- SkASSERT(pipelineBuilder->getRenderTarget());
// draw over the dev bounds (which will be the whole dst surface for inv fill).
bounds = devBounds;
SkMatrix vmi;
@@ -677,12 +666,18 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawTarget* target,
SkAutoTUnref<GrDrawBatch> batch(
GrRectBatchFactory::CreateNonAAFill(color, viewM, bounds, nullptr,
&localMatrix));
- target->drawBatch(*pipelineBuilder, clip, batch);
- } else {
- if (passCount > 1) {
- pipelineBuilder->setDisableColorXPFactory();
+
+ GrPipelineBuilder pipelineBuilder(paint, drawContext->isUnifiedMultisampled());
+ pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
+ pipelineBuilder.setDrawFace(drawFace[p]);
+ if (passes[p]) {
+ pipelineBuilder.setUserStencil(passes[p]);
+ } else {
+ pipelineBuilder.setUserStencil(userStencilSettings);
}
+ drawContext->drawBatch(pipelineBuilder, clip, batch);
+ } else {
MSAAPathBatch::Geometry geometry;
geometry.fColor = color;
geometry.fPath = path;
@@ -690,12 +685,23 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawTarget* target,
SkAutoTUnref<MSAAPathBatch> batch(MSAAPathBatch::Create(geometry, viewMatrix,
devBounds));
- if (batch->isValid()) {
- target->drawBatch(*pipelineBuilder, clip, batch);
- }
- else {
+ if (!batch->isValid()) {
return false;
}
+
+ GrPipelineBuilder pipelineBuilder(paint, drawContext->isUnifiedMultisampled());
+ pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
+ pipelineBuilder.setDrawFace(drawFace[p]);
+ if (passes[p]) {
+ pipelineBuilder.setUserStencil(passes[p]);
+ } else {
+ pipelineBuilder.setUserStencil(userStencilSettings);
+ }
+ if (passCount > 1) {
+ pipelineBuilder.setDisableColorXPFactory();
+ }
+
+ drawContext->drawBatch(pipelineBuilder, clip, batch);
}
}
return true;
@@ -711,7 +717,8 @@ bool GrMSAAPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
}
bool GrMSAAPathRenderer::onDrawPath(const DrawPathArgs& args) {
- GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(), "GrMSAAPathRenderer::onDrawPath");
+ GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
+ "GrMSAAPathRenderer::onDrawPath");
SkPath tmpPath;
const SkPath* path;
if (args.fStyle->applies()) {
@@ -727,8 +734,9 @@ bool GrMSAAPathRenderer::onDrawPath(const DrawPathArgs& args) {
} else {
path = args.fPath;
}
- return this->internalDrawPath(args.fTarget,
- args.fPipelineBuilder,
+ return this->internalDrawPath(args.fDrawContext,
+ *args.fPaint,
+ args.fUserStencilSettings,
*args.fClip,
args.fColor,
*args.fViewMatrix,
@@ -737,11 +745,23 @@ bool GrMSAAPathRenderer::onDrawPath(const DrawPathArgs& args) {
}
void GrMSAAPathRenderer::onStencilPath(const StencilPathArgs& args) {
- GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(),"GrMSAAPathRenderer::onStencilPath");
+ GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
+ "GrMSAAPathRenderer::onStencilPath");
SkASSERT(SkPath::kInverseEvenOdd_FillType != args.fPath->getFillType());
SkASSERT(SkPath::kInverseWinding_FillType != args.fPath->getFillType());
- this->internalDrawPath(args.fTarget, args.fPipelineBuilder, *args.fClip, GrColor_WHITE,
- *args.fViewMatrix, *args.fPath, true);
+
+ GrPaint paint;
+ paint.setXPFactory(GrDisableColorXPFactory::Create());
bungeman-skia 2016/06/03 23:57:03 leak
+ paint.setAntiAlias(args.fIsAA);
+
+ this->internalDrawPath(args.fDrawContext,
+ paint,
+ &GrUserStencilSettings::kUnused,
+ *args.fClip,
+ GrColor_WHITE,
+ *args.fViewMatrix,
+ *args.fPath,
+ true);
}
///////////////////////////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698