}
}
- operator GrPaint&&() { return std::move(*fPaint); }
+ operator GrPaint&&() && { return std::move(*fPaint); }
+ GrPaint& paint() { return *fPaint; }
private:
SkTLazy<GrPaint> fStorage;
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.
/// @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; }
/**
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;)
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));
}
} 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));
}
}
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;