Allow GrAppliedClip to have >1 clip coverage FP
Bug: skia:7190 Change-Id: I07fc689b20968a1b9fe2620bf8a33faacf917823 Reviewed-on: https://skia-review.googlesource.com/65401 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
This commit is contained in:
parent
3cbcb73845
commit
6982400f9a
@ -26,9 +26,14 @@ public:
|
||||
|
||||
const GrScissorState& scissorState() const { return fScissorState; }
|
||||
const GrWindowRectsState& windowRectsState() const { return fWindowRectsState; }
|
||||
GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fClipCoverageFP.get(); }
|
||||
std::unique_ptr<GrFragmentProcessor> detachClipCoverageFragmentProcessor() {
|
||||
return std::move(fClipCoverageFP);
|
||||
int numClipCoverageFragmentProcessors() const { return fClipCoverageFPs.count(); }
|
||||
const GrFragmentProcessor* clipCoverageFragmentProcessor(int i) const {
|
||||
SkASSERT(fClipCoverageFPs[i]);
|
||||
return fClipCoverageFPs[i].get();
|
||||
}
|
||||
std::unique_ptr<const GrFragmentProcessor> detachClipCoverageFragmentProcessor(int i) {
|
||||
SkASSERT(fClipCoverageFPs[i]);
|
||||
return std::move(fClipCoverageFPs[i]);
|
||||
}
|
||||
bool hasStencilClip() const { return SkClipStack::kInvalidGenID != fClipStackID; }
|
||||
|
||||
@ -52,8 +57,8 @@ public:
|
||||
}
|
||||
|
||||
void addCoverageFP(std::unique_ptr<GrFragmentProcessor> fp) {
|
||||
SkASSERT(!fClipCoverageFP);
|
||||
fClipCoverageFP = std::move(fp);
|
||||
SkASSERT(fp);
|
||||
fClipCoverageFPs.push_back(std::move(fp));
|
||||
}
|
||||
|
||||
void addStencilClip(uint32_t clipStackID) {
|
||||
@ -62,36 +67,44 @@ public:
|
||||
}
|
||||
|
||||
bool doesClip() const {
|
||||
return fScissorState.enabled() || fClipCoverageFP || this->hasStencilClip() ||
|
||||
return fScissorState.enabled() || !fClipCoverageFPs.empty() || this->hasStencilClip() ||
|
||||
fWindowRectsState.enabled();
|
||||
}
|
||||
|
||||
bool operator==(const GrAppliedClip& that) const {
|
||||
if (fScissorState != that.fScissorState || fClipStackID != that.fClipStackID) {
|
||||
if (fScissorState != that.fScissorState ||
|
||||
fWindowRectsState != that.fWindowRectsState ||
|
||||
fClipCoverageFPs.count() != that.fClipCoverageFPs.count() ||
|
||||
fClipStackID != that.fClipStackID) {
|
||||
return false;
|
||||
}
|
||||
if (SkToBool(fClipCoverageFP)) {
|
||||
if (!SkToBool(that.fClipCoverageFP) ||
|
||||
!that.fClipCoverageFP->isEqual(*fClipCoverageFP)) {
|
||||
for (int i = 0; i < fClipCoverageFPs.count(); ++i) {
|
||||
if (!fClipCoverageFPs[i] || !that.fClipCoverageFPs[i]) {
|
||||
if (fClipCoverageFPs[i] == that.fClipCoverageFPs[i]) {
|
||||
continue; // Both are null.
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!fClipCoverageFPs[i]->isEqual(*that.fClipCoverageFPs[i])) {
|
||||
return false;
|
||||
}
|
||||
} else if (SkToBool(that.fClipCoverageFP)) {
|
||||
return false;
|
||||
}
|
||||
return fWindowRectsState == that.fWindowRectsState;
|
||||
return true;
|
||||
}
|
||||
bool operator!=(const GrAppliedClip& that) const { return !(*this == that); }
|
||||
|
||||
void visitProxies(const std::function<void(GrSurfaceProxy*)>& func) const {
|
||||
if (fClipCoverageFP) {
|
||||
fClipCoverageFP->visitProxies(func);
|
||||
for (const std::unique_ptr<GrFragmentProcessor>& fp : fClipCoverageFPs) {
|
||||
if (fp) { // This might be called after detach.
|
||||
fp->visitProxies(func);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
GrScissorState fScissorState;
|
||||
GrWindowRectsState fWindowRectsState;
|
||||
std::unique_ptr<GrFragmentProcessor> fClipCoverageFP;
|
||||
SkSTArray<4, std::unique_ptr<GrFragmentProcessor>> fClipCoverageFPs;
|
||||
uint32_t fClipStackID = SkClipStack::kInvalidGenID;
|
||||
};
|
||||
|
||||
|
@ -314,7 +314,9 @@ bool GrClipStackClip::apply(GrContext* context, GrRenderTargetContext* renderTar
|
||||
if ((reducedClip.maskRequiresAA() || avoidStencilBuffers) &&
|
||||
get_analytic_clip_processor(reducedClip.maskElements(), disallowAnalyticAA, devBounds,
|
||||
&clipFP)) {
|
||||
out->addCoverageFP(std::move(clipFP));
|
||||
if (clipFP) {
|
||||
out->addCoverageFP(std::move(clipFP));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -48,12 +48,9 @@ GrPipeline::GrPipeline(const InitArgs& args, GrProcessorSet&& processors,
|
||||
|
||||
// Copy GrFragmentProcessors from GrProcessorSet to Pipeline
|
||||
fNumColorProcessors = processors.numColorFragmentProcessors();
|
||||
int numTotalProcessors =
|
||||
fNumColorProcessors + processors.numCoverageFragmentProcessors();
|
||||
auto clipFP = appliedClip.detachClipCoverageFragmentProcessor();
|
||||
if (clipFP) {
|
||||
++numTotalProcessors;
|
||||
}
|
||||
int numTotalProcessors = fNumColorProcessors +
|
||||
processors.numCoverageFragmentProcessors() +
|
||||
appliedClip.numClipCoverageFragmentProcessors();
|
||||
fFragmentProcessors.reset(numTotalProcessors);
|
||||
int currFPIdx = 0;
|
||||
for (int i = 0; i < processors.numColorFragmentProcessors(); ++i, ++currFPIdx) {
|
||||
@ -62,15 +59,14 @@ GrPipeline::GrPipeline(const InitArgs& args, GrProcessorSet&& processors,
|
||||
this->markAsBad();
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < processors.numCoverageFragmentProcessors(); ++i, ++currFPIdx) {
|
||||
fFragmentProcessors[currFPIdx] = processors.detachCoverageFragmentProcessor(i);
|
||||
if (!fFragmentProcessors[currFPIdx]->instantiate(args.fResourceProvider)) {
|
||||
this->markAsBad();
|
||||
}
|
||||
}
|
||||
if (clipFP) {
|
||||
fFragmentProcessors[currFPIdx] = std::move(clipFP);
|
||||
for (int i = 0; i < appliedClip.numClipCoverageFragmentProcessors(); ++i, ++currFPIdx) {
|
||||
fFragmentProcessors[currFPIdx] = appliedClip.detachClipCoverageFragmentProcessor(i);
|
||||
if (!fFragmentProcessors[currFPIdx]->instantiate(args.fResourceProvider)) {
|
||||
this->markAsBad();
|
||||
}
|
||||
|
@ -168,7 +168,6 @@ GrProcessorSet::Analysis GrProcessorSet::finalize(const GrProcessorAnalysisColor
|
||||
GrProcessorSet::Analysis analysis;
|
||||
analysis.fCompatibleWithCoverageAsAlpha = GrProcessorAnalysisCoverage::kLCD != coverageInput;
|
||||
|
||||
const GrFragmentProcessor* clipFP = clip ? clip->clipCoverageFragmentProcessor() : nullptr;
|
||||
const std::unique_ptr<const GrFragmentProcessor>* fps =
|
||||
fFragmentProcessors.get() + fFragmentProcessorOffset;
|
||||
GrColorFragmentProcessorAnalysis colorAnalysis(
|
||||
@ -188,11 +187,13 @@ GrProcessorSet::Analysis GrProcessorSet::finalize(const GrProcessorAnalysisColor
|
||||
}
|
||||
coverageUsesLocalCoords |= fps[i]->usesLocalCoords();
|
||||
}
|
||||
|
||||
if (clipFP) {
|
||||
analysis.fCompatibleWithCoverageAsAlpha &= clipFP->compatibleWithCoverageAsAlpha();
|
||||
coverageUsesLocalCoords |= clipFP->usesLocalCoords();
|
||||
hasCoverageFP = true;
|
||||
if (clip) {
|
||||
hasCoverageFP = hasCoverageFP || clip->numClipCoverageFragmentProcessors();
|
||||
for (int i = 0; i < clip->numClipCoverageFragmentProcessors(); ++i) {
|
||||
const GrFragmentProcessor* clipFP = clip->clipCoverageFragmentProcessor(i);
|
||||
analysis.fCompatibleWithCoverageAsAlpha &= clipFP->compatibleWithCoverageAsAlpha();
|
||||
coverageUsesLocalCoords |= clipFP->usesLocalCoords();
|
||||
}
|
||||
}
|
||||
int colorFPsToEliminate = colorAnalysis.initialProcessorsToEliminate(overrideInputColor);
|
||||
analysis.fInputColorType = static_cast<Analysis::PackedInputColorType>(
|
||||
|
@ -137,6 +137,9 @@ void GrReducedClip::walkStack(const SkClipStack& stack, const SkRect& queryBound
|
||||
// account for floating point rounding error that may have occurred during coord transforms.
|
||||
SkRect relaxedQueryBounds = queryBounds.makeInset(GrClip::kBoundsTolerance,
|
||||
GrClip::kBoundsTolerance);
|
||||
if (relaxedQueryBounds.isEmpty()) {
|
||||
relaxedQueryBounds = queryBounds;
|
||||
}
|
||||
|
||||
SkClipStack::Iter iter(stack, SkClipStack::Iter::kTop_IterStart);
|
||||
int numAAElements = 0;
|
||||
|
@ -653,7 +653,7 @@ void GrRenderTargetContextPriv::stencilPath(const GrClip& clip,
|
||||
|
||||
// Coverage AA does not make sense when rendering to the stencil buffer. The caller should never
|
||||
// attempt this in a situation that would require coverage AA.
|
||||
SkASSERT(!appliedClip.clipCoverageFragmentProcessor());
|
||||
SkASSERT(!appliedClip.numClipCoverageFragmentProcessors());
|
||||
|
||||
fRenderTargetContext->setNeedsStencil();
|
||||
|
||||
|
@ -299,7 +299,7 @@ public:
|
||||
RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip,
|
||||
GrPixelConfigIsClamped dstIsClamped) override {
|
||||
GrProcessorAnalysisCoverage coverage;
|
||||
if (AAMode::kNone == fAAMode && !clip->clipCoverageFragmentProcessor()) {
|
||||
if (AAMode::kNone == fAAMode && !clip->numClipCoverageFragmentProcessors()) {
|
||||
coverage = GrProcessorAnalysisCoverage::kNone;
|
||||
} else {
|
||||
coverage = GrProcessorAnalysisCoverage::kSingleChannel;
|
||||
|
@ -71,7 +71,7 @@ GrDrawOp::RequiresDstTexture GrSimpleMeshDrawOpHelper::xpRequiresDstTexture(
|
||||
if (fProcessors) {
|
||||
GrProcessorAnalysisCoverage coverage = geometryCoverage;
|
||||
if (GrProcessorAnalysisCoverage::kNone == coverage) {
|
||||
coverage = clip->clipCoverageFragmentProcessor()
|
||||
coverage = clip->numClipCoverageFragmentProcessors()
|
||||
? GrProcessorAnalysisCoverage::kSingleChannel
|
||||
: GrProcessorAnalysisCoverage::kNone;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user