aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/gpu/GrPaint.h3
-rw-r--r--src/gpu/GrPipelineBuilder.h54
-rw-r--r--src/gpu/GrSWMaskHelper.cpp7
-rw-r--r--src/gpu/ops/GrDefaultPathRenderer.cpp11
-rw-r--r--src/gpu/ops/GrMSAAPathRenderer.cpp29
5 files changed, 34 insertions, 70 deletions
diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h
index 0f3b525c1f..6897679e5d 100644
--- a/include/gpu/GrPaint.h
+++ b/include/gpu/GrPaint.h
@@ -199,7 +199,8 @@ public:
}
}
- operator GrPaint&&() { return std::move(*fPaint); }
+ operator GrPaint&&() && { return std::move(*fPaint); }
+ GrPaint& paint() { return *fPaint; }
private:
SkTLazy<GrPaint> fStorage;
diff --git a/src/gpu/GrPipelineBuilder.h b/src/gpu/GrPipelineBuilder.h
index 15af681c34..66459ae9fd 100644
--- a/src/gpu/GrPipelineBuilder.h
+++ b/src/gpu/GrPipelineBuilder.h
@@ -61,41 +61,6 @@ public:
return fCoverageFragmentProcessors[idx].get();
}
- void addColorFragmentProcessor(sk_sp<GrFragmentProcessor> processor) {
- SkASSERT(processor);
- fColorFragmentProcessors.push_back(std::move(processor));
- }
-
- void addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor> processor) {
- SkASSERT(processor);
- fCoverageFragmentProcessors.push_back(std::move(processor));
- }
-
- /**
- * Creates a GrSimpleTextureEffect that uses local coords as texture coordinates.
- */
- void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, nullptr, matrix));
- }
-
- void addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, nullptr, matrix));
- }
-
- void addColorTextureProcessor(GrTexture* texture,
- const SkMatrix& matrix,
- const GrSamplerParams& params) {
- this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, nullptr, matrix,
- params));
- }
-
- void addCoverageTextureProcessor(GrTexture* texture,
- const SkMatrix& matrix,
- const GrSamplerParams& params) {
- this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, nullptr, matrix,
- params));
- }
-
/**
* When this object is destroyed it will remove any color/coverage FPs from the pipeline builder
* that were added after its constructor.
@@ -140,18 +105,6 @@ public:
/// @name Blending
////
- /**
- * Installs a GrXPFactory. This object controls how src color, fractional pixel coverage,
- * and the dst color are blended.
- */
- void setXPFactory(const GrXPFactory* xpFactory) { fXPFactory = xpFactory; }
-
- /**
- * Sets a GrXPFactory that disables color writes to the destination. This is useful when
- * rendering to the stencil buffer.
- */
- void setDisableColorXPFactory() { fXPFactory = GrDisableColorXPFactory::Get(); }
-
const GrXPFactory* getXPFactory() const { return fXPFactory; }
/**
@@ -288,6 +241,13 @@ public:
bool usePLSDstRead(const GrDrawOp*) const;
private:
+ // This exists solely for AutoRestoreFragmentProcessor, which itself exists solely to install
+ // an applied clip's FP. This will be removed soon.
+ void addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor> processor) {
+ SkASSERT(processor);
+ fCoverageFragmentProcessors.push_back(std::move(processor));
+ }
+
// Some of the auto restore objects assume that no effects are removed during their lifetime.
// This is used to assert that this condition holds.
SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;)
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index f85bbe6557..240f9f9c3c 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -183,12 +183,9 @@ void GrSWMaskHelper::DrawToTargetWithShapeMask(GrTexture* texture,
maskMatrix.preConcat(viewMatrix);
std::unique_ptr<GrDrawOp> op = GrRectOpFactory::MakeNonAAFill(paint.getColor(), SkMatrix::I(),
dstRect, nullptr, &invert);
+ paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(
+ texture, nullptr, maskMatrix, GrSamplerParams::kNone_FilterMode));
GrPipelineBuilder pipelineBuilder(std::move(paint), GrAAType::kNone);
pipelineBuilder.setUserStencil(&userStencilSettings);
- pipelineBuilder.addCoverageFragmentProcessor(
- GrSimpleTextureEffect::Make(texture,
- nullptr,
- maskMatrix,
- GrSamplerParams::kNone_FilterMode));
renderTargetContext->addDrawOp(pipelineBuilder, clip, std::move(op));
}
diff --git a/src/gpu/ops/GrDefaultPathRenderer.cpp b/src/gpu/ops/GrDefaultPathRenderer.cpp
index 270dc09251..e76ded3d5a 100644
--- a/src/gpu/ops/GrDefaultPathRenderer.cpp
+++ b/src/gpu/ops/GrDefaultPathRenderer.cpp
@@ -557,14 +557,15 @@ bool GrDefaultPathRenderer::internalDrawPath(GrRenderTargetContext* renderTarget
} else {
std::unique_ptr<GrDrawOp> op =
DefaultPathOp::Make(paint.getColor(), path, srcSpaceTol, newCoverage,
-
viewMatrix, isHairline, devBounds);
- GrPipelineBuilder pipelineBuilder(GrPaint::MoveOrNew(paint, lastPassIsBounds), aaType);
+ bool stencilPass = stencilOnly || passCount > 1;
+ GrPaint::MoveOrNew passPaint(paint, stencilPass);
+ if (stencilPass) {
+ passPaint.paint().setXPFactory(GrDisableColorXPFactory::Get());
+ }
+ GrPipelineBuilder pipelineBuilder(std::move(passPaint), aaType);
pipelineBuilder.setDrawFace(drawFace[p]);
pipelineBuilder.setUserStencil(passes[p]);
- if (passCount > 1) {
- pipelineBuilder.setDisableColorXPFactory();
- }
renderTargetContext->addDrawOp(pipelineBuilder, clip, std::move(op));
}
}
diff --git a/src/gpu/ops/GrMSAAPathRenderer.cpp b/src/gpu/ops/GrMSAAPathRenderer.cpp
index 5c1c110b00..26fdf5da82 100644
--- a/src/gpu/ops/GrMSAAPathRenderer.cpp
+++ b/src/gpu/ops/GrMSAAPathRenderer.cpp
@@ -613,20 +613,25 @@ bool GrMSAAPathRenderer::internalDrawPath(GrRenderTargetContext* renderTargetCon
SkRect devBounds;
GetPathDevBounds(path, renderTargetContext->width(), renderTargetContext->height(), viewMatrix,
&devBounds);
- SkASSERT(passes[0]);
- std::unique_ptr<GrDrawOp> op = MSAAPathOp::Make(paint.getColor(), path, viewMatrix, devBounds);
- if (!op) {
- return false;
- }
- // If we have a cover pass then we ignore the paint in the first pass and apply it in the
- // second.
- GrPipelineBuilder pipelineBuilder(GrPaint::MoveOrNew(paint, passes[1]), aaType);
- pipelineBuilder.setUserStencil(passes[0]);
- if (passes[1]) {
- pipelineBuilder.setDisableColorXPFactory();
+ SkASSERT(passes[0]);
+ { // First pass
+ std::unique_ptr<GrDrawOp> op =
+ MSAAPathOp::Make(paint.getColor(), path, viewMatrix, devBounds);
+ if (!op) {
+ return false;
+ }
+ bool firstPassIsStencil = stencilOnly || passes[1];
+ // If we have a cover pass then we ignore the paint in the first pass and apply it in the
+ // second.
+ GrPaint::MoveOrNew firstPassPaint(paint, firstPassIsStencil);
+ if (firstPassIsStencil) {
+ firstPassPaint.paint().setXPFactory(GrDisableColorXPFactory::Get());
+ }
+ GrPipelineBuilder pipelineBuilder(std::move(firstPassPaint), aaType);
+ pipelineBuilder.setUserStencil(passes[0]);
+ renderTargetContext->addDrawOp(pipelineBuilder, clip, std::move(op));
}
- renderTargetContext->addDrawOp(pipelineBuilder, clip, std::move(op));
if (passes[1]) {
SkRect bounds;