Remove support for multiple coverage processors from GrPaint API.

Change-Id: I82276e38ea4a5524127176eb5a34066b6cb06d88
Bug: skia:10217
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/304799
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2020-07-21 14:39:40 -04:00 committed by Skia Commit-Bot
parent 1d4c08f615
commit 41d91b68b5
15 changed files with 38 additions and 44 deletions

View File

@ -98,7 +98,7 @@ protected:
GrPaint grPaint;
grPaint.setColor4f({ 0, 0, 0, 1.f });
grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
grPaint.addCoverageFragmentProcessor(std::move(fp));
grPaint.setCoverageFragmentProcessor(std::move(fp));
SkRect bounds = testBounds;
bounds.offset(SkIntToScalar(x), SkIntToScalar(y));

View File

@ -133,7 +133,7 @@ protected:
GrPaint grPaint;
grPaint.setColor4f({ 0, 0, 0, 1.f });
grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
grPaint.addCoverageFragmentProcessor(std::move(fp));
grPaint.setCoverageFragmentProcessor(std::move(fp));
auto rect = p.getBounds().makeOutset(kOutset, kOutset);
auto op = sk_gpu_test::test_ops::MakeRect(context, std::move(grPaint), rect);
@ -172,7 +172,7 @@ protected:
GrPaint grPaint;
grPaint.setColor4f({ 0, 0, 0, 1.f });
grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
grPaint.addCoverageFragmentProcessor(std::move(fp));
grPaint.setCoverageFragmentProcessor(std::move(fp));
auto drawRect = rect.makeOutset(kOutset, kOutset);
auto op = sk_gpu_test::test_ops::MakeRect(context, std::move(grPaint), drawRect);

View File

@ -89,7 +89,7 @@ DEF_SIMPLE_GPU_GM_BG(fpcoordinateoverride, ctx, rtCtx, canvas, 512, 512,
auto fp = std::unique_ptr<GrFragmentProcessor>(new SampleCoordEffect(std::move(imgFP)));
GrPaint grPaint;
grPaint.addCoverageFragmentProcessor(std::move(fp));
grPaint.setCoverageFragmentProcessor(std::move(fp));
rtCtx->priv().testingOnly_addDrawOp(GrFillRectOp::MakeNonAARect(ctx,
std::move(grPaint),

View File

@ -124,7 +124,7 @@ protected:
if (success) {
GrPaint grPaint;
grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
grPaint.addCoverageFragmentProcessor(std::move(fp));
grPaint.setCoverageFragmentProcessor(std::move(fp));
grPaint.setColor4f({ 0, 0, 0, 1.f });
SkRect bounds = rrect.getBounds();

View File

@ -769,7 +769,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrRecordingContext* context,
if (!fp) {
return false;
}
paint.addCoverageFragmentProcessor(std::move(fp));
paint.setCoverageFragmentProcessor(std::move(fp));
SkRect srcProxyRect = srcRRect.rect();
SkScalar outsetX = 3.0f*fSigma;
@ -804,7 +804,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrRecordingContext* context,
memcpy(builder.indices(), fullIndices, sizeof(fullIndices));
sk_sp<SkVertices> vertices = builder.detach();
paint.addCoverageFragmentProcessor(std::move(fp));
paint.setCoverageFragmentProcessor(std::move(fp));
SkSimpleMatrixProvider matrixProvider(viewMatrix);
renderTargetContext->drawVertices(clip, std::move(paint), matrixProvider,
std::move(vertices));
@ -818,7 +818,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrRecordingContext* context,
SkRect proxyRect = devRRect.rect();
proxyRect.outset(extra, extra);
paint.addCoverageFragmentProcessor(std::move(fp));
paint.setCoverageFragmentProcessor(std::move(fp));
renderTargetContext->fillRectWithLocalMatrix(clip, std::move(paint), GrAA::kNo,
SkMatrix::I(), proxyRect, inverse);
}
@ -896,7 +896,7 @@ GrSurfaceProxyView SkBlurMaskFilterImpl::filterMaskGPU(GrRecordingContext* conte
if (!isNormalBlur) {
GrPaint paint;
// Blend pathTexture over blurTexture.
paint.addCoverageFragmentProcessor(GrTextureEffect::Make(std::move(srcView), srcAlphaType));
paint.setCoverageFragmentProcessor(GrTextureEffect::Make(std::move(srcView), srcAlphaType));
if (kInner_SkBlurStyle == fBlurStyle) {
// inner: dst = dst * src
paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op);

View File

@ -56,7 +56,7 @@ static bool draw_mask(GrRenderTargetContext* renderTargetContext,
SkMatrix matrix = SkMatrix::Translate(-SkIntToScalar(maskRect.fLeft),
-SkIntToScalar(maskRect.fTop));
matrix.preConcat(viewMatrix);
paint.addCoverageFragmentProcessor(
paint.setCoverageFragmentProcessor(
GrTextureEffect::Make(std::move(mask), kUnknown_SkAlphaType, matrix));
renderTargetContext->fillRectWithLocalMatrix(clip, std::move(paint), GrAA::kNo, SkMatrix::I(),

View File

@ -481,8 +481,8 @@ std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::RunInSeries(
//////////////////////////////////////////////////////////////////////////////
GrFragmentProcessor::CIter::CIter(const GrPaint& paint) {
for (int i = paint.numCoverageFragmentProcessors() - 1; i >= 0; --i) {
fFPStack.push_back(paint.getCoverageFragmentProcessor(i));
if (paint.hasCoverageFragmentProcessor()) {
fFPStack.push_back(paint.getCoverageFragmentProcessor());
}
if (paint.hasColorFragmentProcessor()) {
fFPStack.push_back(paint.getColorFragmentProcessor());

View File

@ -13,16 +13,15 @@
GrPaint::GrPaint(const GrPaint& that)
: fXPFactory(that.fXPFactory)
, fCoverageFragmentProcessors(that.fCoverageFragmentProcessors.count())
, fTrivial(that.fTrivial)
, fColor(that.fColor) {
if (that.fColorFragmentProcessor) {
fColorFragmentProcessor = that.fColorFragmentProcessor->clone();
SkASSERT(fColorFragmentProcessor);
}
for (int i = 0; i < that.fCoverageFragmentProcessors.count(); ++i) {
fCoverageFragmentProcessors.push_back(that.fCoverageFragmentProcessors[i]->clone());
SkASSERT(fCoverageFragmentProcessors[i]);
if (that.fCoverageFragmentProcessor) {
fCoverageFragmentProcessor = that.fCoverageFragmentProcessor->clone();
SkASSERT(fCoverageFragmentProcessor);
}
}

View File

@ -72,16 +72,18 @@ public:
/**
* Appends an additional coverage processor to the coverage computation.
*/
void addCoverageFragmentProcessor(std::unique_ptr<GrFragmentProcessor> fp) {
void setCoverageFragmentProcessor(std::unique_ptr<GrFragmentProcessor> fp) {
SkASSERT(fp);
fCoverageFragmentProcessors.push_back(std::move(fp));
SkASSERT(fCoverageFragmentProcessor == nullptr);
fCoverageFragmentProcessor = std::move(fp);
fTrivial = false;
}
bool hasColorFragmentProcessor() const { return fColorFragmentProcessor ? true : false; }
int numCoverageFragmentProcessors() const { return fCoverageFragmentProcessors.count(); }
int hasCoverageFragmentProcessor() const { return fCoverageFragmentProcessor ? true : false; }
int numTotalFragmentProcessors() const {
return (this->hasColorFragmentProcessor() ? 1 : 0) + this->numCoverageFragmentProcessors();
return (this->hasColorFragmentProcessor() ? 1 : 0) +
(this->hasCoverageFragmentProcessor() ? 1 : 0);
}
const GrXPFactory* getXPFactory() const { return fXPFactory; }
@ -89,8 +91,8 @@ public:
GrFragmentProcessor* getColorFragmentProcessor() const {
return fColorFragmentProcessor.get();
}
GrFragmentProcessor* getCoverageFragmentProcessor(int i) const {
return fCoverageFragmentProcessors[i].get();
GrFragmentProcessor* getCoverageFragmentProcessor() const {
return fCoverageFragmentProcessor.get();
}
/**
@ -121,7 +123,7 @@ private:
const GrXPFactory* fXPFactory = nullptr;
std::unique_ptr<GrFragmentProcessor> fColorFragmentProcessor;
SkSTArray<2, std::unique_ptr<GrFragmentProcessor>> fCoverageFragmentProcessors;
std::unique_ptr<GrFragmentProcessor> fCoverageFragmentProcessor;
bool fTrivial = true;
SkPMColor4f fColor = SK_PMColor4fWHITE;
SkDEBUGCODE(bool fAlive = true;) // Set false after moved from.

View File

@ -31,9 +31,8 @@ GrProcessorSet::GrProcessorSet(GrPaint&& paint) : fXP(paint.getXPFactory()) {
if (paint.fColorFragmentProcessor) {
fFragmentProcessors[i++] = std::move(paint.fColorFragmentProcessor);
}
for (auto& fp : paint.fCoverageFragmentProcessors) {
SkASSERT(fp.get());
fFragmentProcessors[i++] = std::move(fp);
if (paint.fCoverageFragmentProcessor) {
fFragmentProcessors[i++] = std::move(paint.fCoverageFragmentProcessor);
}
SkDEBUGCODE(paint.fAlive = false;)

View File

@ -776,8 +776,7 @@ void GrRenderTargetContext::drawFilledQuad(const GrClip* clip,
SkPMColor4f* constColor = nullptr;
SkPMColor4f paintColor;
if (!ss && !paint.numCoverageFragmentProcessors() &&
paint.isConstantBlendedColor(&paintColor)) {
if (!ss && !paint.hasCoverageFragmentProcessor() && paint.isConstantBlendedColor(&paintColor)) {
// Only consider clears/rrects when it's easy to guarantee 100% fill with single color
constColor = &paintColor;
}
@ -1444,7 +1443,7 @@ bool GrRenderTargetContext::drawFilledDRRect(const GrClip* clip,
return false;
}
paint.addCoverageFragmentProcessor(std::move(fp));
paint.setCoverageFragmentProcessor(std::move(fp));
SkRect bounds = outer->getBounds();
if (GrAAType::kCoverage == aaType) {

View File

@ -167,7 +167,7 @@ void GrSoftwarePathRenderer::DrawToTargetWithShapeMask(
SkIntToScalar(-textureOriginInDeviceSpace.fY));
maskMatrix.preConcat(viewMatrix);
paint.addCoverageFragmentProcessor(GrTextureEffect::Make(
paint.setCoverageFragmentProcessor(GrTextureEffect::Make(
std::move(view), kPremul_SkAlphaType, maskMatrix, GrSamplerState::Filter::kNearest));
DrawNonAARect(renderTargetContext, std::move(paint), userStencilSettings, clip, SkMatrix::I(),
dstRect, invert);

View File

@ -313,7 +313,7 @@ static inline bool skpaint_to_grpaint_impl(GrRecordingContext* context,
// We may have set this before passing to the SkShader.
fpArgs.fInputColorIsOpaque = false;
if (auto mfFP = maskFilter->asFragmentProcessor(fpArgs)) {
grPaint->addCoverageFragmentProcessor(std::move(mfFP));
grPaint->setCoverageFragmentProcessor(std::move(mfFP));
}
}

View File

@ -143,7 +143,7 @@ GrPathRenderer::CanDrawPath GrTessellationPathRenderer::onCanDrawPath(
!args.fCaps->shaderCaps()->tessellationSupport() ||
GrAAType::kCoverage == args.fAAType || !args.fViewMatrix->isSimilarity() ||
!args.fPaint->isConstantBlendedColor(&constantColor) ||
args.fPaint->numCoverageFragmentProcessors()) {
args.fPaint->hasCoverageFragmentProcessor()) {
return CanDrawPath::kNo;
}
}

View File

@ -232,19 +232,14 @@ static void set_random_color_coverage_stages(GrPaint* paint,
paint->setColorFragmentProcessor(std::move(fp));
}
} else {
int numProcs = d->fRandom->nextULessThan(maxStages + 1);
int numColorProcs = 1;
for (int s = 0; s < numProcs; ++s) {
std::unique_ptr<GrFragmentProcessor> fp(GrFragmentProcessorTestFactory::Make(d));
if (!fp) {
continue;
}
// finally add the stage to the correct pipeline in the drawstate
if (s < numColorProcs) {
if (maxStages >= 1) {
if (std::unique_ptr<GrFragmentProcessor> fp = GrFragmentProcessorTestFactory::Make(d)) {
paint->setColorFragmentProcessor(std::move(fp));
} else {
paint->addCoverageFragmentProcessor(std::move(fp));
}
}
if (maxStages >= 2) {
if (std::unique_ptr<GrFragmentProcessor> fp = GrFragmentProcessorTestFactory::Make(d)) {
paint->setCoverageFragmentProcessor(std::move(fp));
}
}
}