From d4652ca1b7989af5ef4e81b0de4eba529f804618 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Fri, 13 Jan 2017 12:11:36 -0500 Subject: Remove most modifiers of processors on GrPipelineBuilder Change-Id: I2fc12a97d694e5c0d86c9a4e0818a058905c8cf0 Reviewed-on: https://skia-review.googlesource.com/6993 Commit-Queue: Brian Salomon Reviewed-by: Robert Phillips --- src/gpu/GrPipelineBuilder.h | 54 +++++------------------------------ src/gpu/GrSWMaskHelper.cpp | 7 ++--- src/gpu/ops/GrDefaultPathRenderer.cpp | 11 +++---- src/gpu/ops/GrMSAAPathRenderer.cpp | 29 +++++++++++-------- 4 files changed, 32 insertions(+), 69 deletions(-) (limited to 'src/gpu') 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 processor) { - SkASSERT(processor); - fColorFragmentProcessors.push_back(std::move(processor)); - } - - void addCoverageFragmentProcessor(sk_sp 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 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 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 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 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 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; -- cgit v1.2.3