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 GrScissorState& scissorState() const { return fScissorState; }
|
||||||
const GrWindowRectsState& windowRectsState() const { return fWindowRectsState; }
|
const GrWindowRectsState& windowRectsState() const { return fWindowRectsState; }
|
||||||
GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fClipCoverageFP.get(); }
|
int numClipCoverageFragmentProcessors() const { return fClipCoverageFPs.count(); }
|
||||||
std::unique_ptr<GrFragmentProcessor> detachClipCoverageFragmentProcessor() {
|
const GrFragmentProcessor* clipCoverageFragmentProcessor(int i) const {
|
||||||
return std::move(fClipCoverageFP);
|
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; }
|
bool hasStencilClip() const { return SkClipStack::kInvalidGenID != fClipStackID; }
|
||||||
|
|
||||||
@ -52,8 +57,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void addCoverageFP(std::unique_ptr<GrFragmentProcessor> fp) {
|
void addCoverageFP(std::unique_ptr<GrFragmentProcessor> fp) {
|
||||||
SkASSERT(!fClipCoverageFP);
|
SkASSERT(fp);
|
||||||
fClipCoverageFP = std::move(fp);
|
fClipCoverageFPs.push_back(std::move(fp));
|
||||||
}
|
}
|
||||||
|
|
||||||
void addStencilClip(uint32_t clipStackID) {
|
void addStencilClip(uint32_t clipStackID) {
|
||||||
@ -62,36 +67,44 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool doesClip() const {
|
bool doesClip() const {
|
||||||
return fScissorState.enabled() || fClipCoverageFP || this->hasStencilClip() ||
|
return fScissorState.enabled() || !fClipCoverageFPs.empty() || this->hasStencilClip() ||
|
||||||
fWindowRectsState.enabled();
|
fWindowRectsState.enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const GrAppliedClip& that) const {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
if (SkToBool(fClipCoverageFP)) {
|
for (int i = 0; i < fClipCoverageFPs.count(); ++i) {
|
||||||
if (!SkToBool(that.fClipCoverageFP) ||
|
if (!fClipCoverageFPs[i] || !that.fClipCoverageFPs[i]) {
|
||||||
!that.fClipCoverageFP->isEqual(*fClipCoverageFP)) {
|
if (fClipCoverageFPs[i] == that.fClipCoverageFPs[i]) {
|
||||||
|
continue; // Both are null.
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!fClipCoverageFPs[i]->isEqual(*that.fClipCoverageFPs[i])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (SkToBool(that.fClipCoverageFP)) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return fWindowRectsState == that.fWindowRectsState;
|
return true;
|
||||||
}
|
}
|
||||||
bool operator!=(const GrAppliedClip& that) const { return !(*this == that); }
|
bool operator!=(const GrAppliedClip& that) const { return !(*this == that); }
|
||||||
|
|
||||||
void visitProxies(const std::function<void(GrSurfaceProxy*)>& func) const {
|
void visitProxies(const std::function<void(GrSurfaceProxy*)>& func) const {
|
||||||
if (fClipCoverageFP) {
|
for (const std::unique_ptr<GrFragmentProcessor>& fp : fClipCoverageFPs) {
|
||||||
fClipCoverageFP->visitProxies(func);
|
if (fp) { // This might be called after detach.
|
||||||
|
fp->visitProxies(func);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GrScissorState fScissorState;
|
GrScissorState fScissorState;
|
||||||
GrWindowRectsState fWindowRectsState;
|
GrWindowRectsState fWindowRectsState;
|
||||||
std::unique_ptr<GrFragmentProcessor> fClipCoverageFP;
|
SkSTArray<4, std::unique_ptr<GrFragmentProcessor>> fClipCoverageFPs;
|
||||||
uint32_t fClipStackID = SkClipStack::kInvalidGenID;
|
uint32_t fClipStackID = SkClipStack::kInvalidGenID;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -314,7 +314,9 @@ bool GrClipStackClip::apply(GrContext* context, GrRenderTargetContext* renderTar
|
|||||||
if ((reducedClip.maskRequiresAA() || avoidStencilBuffers) &&
|
if ((reducedClip.maskRequiresAA() || avoidStencilBuffers) &&
|
||||||
get_analytic_clip_processor(reducedClip.maskElements(), disallowAnalyticAA, devBounds,
|
get_analytic_clip_processor(reducedClip.maskElements(), disallowAnalyticAA, devBounds,
|
||||||
&clipFP)) {
|
&clipFP)) {
|
||||||
out->addCoverageFP(std::move(clipFP));
|
if (clipFP) {
|
||||||
|
out->addCoverageFP(std::move(clipFP));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,12 +48,9 @@ GrPipeline::GrPipeline(const InitArgs& args, GrProcessorSet&& processors,
|
|||||||
|
|
||||||
// Copy GrFragmentProcessors from GrProcessorSet to Pipeline
|
// Copy GrFragmentProcessors from GrProcessorSet to Pipeline
|
||||||
fNumColorProcessors = processors.numColorFragmentProcessors();
|
fNumColorProcessors = processors.numColorFragmentProcessors();
|
||||||
int numTotalProcessors =
|
int numTotalProcessors = fNumColorProcessors +
|
||||||
fNumColorProcessors + processors.numCoverageFragmentProcessors();
|
processors.numCoverageFragmentProcessors() +
|
||||||
auto clipFP = appliedClip.detachClipCoverageFragmentProcessor();
|
appliedClip.numClipCoverageFragmentProcessors();
|
||||||
if (clipFP) {
|
|
||||||
++numTotalProcessors;
|
|
||||||
}
|
|
||||||
fFragmentProcessors.reset(numTotalProcessors);
|
fFragmentProcessors.reset(numTotalProcessors);
|
||||||
int currFPIdx = 0;
|
int currFPIdx = 0;
|
||||||
for (int i = 0; i < processors.numColorFragmentProcessors(); ++i, ++currFPIdx) {
|
for (int i = 0; i < processors.numColorFragmentProcessors(); ++i, ++currFPIdx) {
|
||||||
@ -62,15 +59,14 @@ GrPipeline::GrPipeline(const InitArgs& args, GrProcessorSet&& processors,
|
|||||||
this->markAsBad();
|
this->markAsBad();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < processors.numCoverageFragmentProcessors(); ++i, ++currFPIdx) {
|
for (int i = 0; i < processors.numCoverageFragmentProcessors(); ++i, ++currFPIdx) {
|
||||||
fFragmentProcessors[currFPIdx] = processors.detachCoverageFragmentProcessor(i);
|
fFragmentProcessors[currFPIdx] = processors.detachCoverageFragmentProcessor(i);
|
||||||
if (!fFragmentProcessors[currFPIdx]->instantiate(args.fResourceProvider)) {
|
if (!fFragmentProcessors[currFPIdx]->instantiate(args.fResourceProvider)) {
|
||||||
this->markAsBad();
|
this->markAsBad();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (clipFP) {
|
for (int i = 0; i < appliedClip.numClipCoverageFragmentProcessors(); ++i, ++currFPIdx) {
|
||||||
fFragmentProcessors[currFPIdx] = std::move(clipFP);
|
fFragmentProcessors[currFPIdx] = appliedClip.detachClipCoverageFragmentProcessor(i);
|
||||||
if (!fFragmentProcessors[currFPIdx]->instantiate(args.fResourceProvider)) {
|
if (!fFragmentProcessors[currFPIdx]->instantiate(args.fResourceProvider)) {
|
||||||
this->markAsBad();
|
this->markAsBad();
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,6 @@ GrProcessorSet::Analysis GrProcessorSet::finalize(const GrProcessorAnalysisColor
|
|||||||
GrProcessorSet::Analysis analysis;
|
GrProcessorSet::Analysis analysis;
|
||||||
analysis.fCompatibleWithCoverageAsAlpha = GrProcessorAnalysisCoverage::kLCD != coverageInput;
|
analysis.fCompatibleWithCoverageAsAlpha = GrProcessorAnalysisCoverage::kLCD != coverageInput;
|
||||||
|
|
||||||
const GrFragmentProcessor* clipFP = clip ? clip->clipCoverageFragmentProcessor() : nullptr;
|
|
||||||
const std::unique_ptr<const GrFragmentProcessor>* fps =
|
const std::unique_ptr<const GrFragmentProcessor>* fps =
|
||||||
fFragmentProcessors.get() + fFragmentProcessorOffset;
|
fFragmentProcessors.get() + fFragmentProcessorOffset;
|
||||||
GrColorFragmentProcessorAnalysis colorAnalysis(
|
GrColorFragmentProcessorAnalysis colorAnalysis(
|
||||||
@ -188,11 +187,13 @@ GrProcessorSet::Analysis GrProcessorSet::finalize(const GrProcessorAnalysisColor
|
|||||||
}
|
}
|
||||||
coverageUsesLocalCoords |= fps[i]->usesLocalCoords();
|
coverageUsesLocalCoords |= fps[i]->usesLocalCoords();
|
||||||
}
|
}
|
||||||
|
if (clip) {
|
||||||
if (clipFP) {
|
hasCoverageFP = hasCoverageFP || clip->numClipCoverageFragmentProcessors();
|
||||||
analysis.fCompatibleWithCoverageAsAlpha &= clipFP->compatibleWithCoverageAsAlpha();
|
for (int i = 0; i < clip->numClipCoverageFragmentProcessors(); ++i) {
|
||||||
coverageUsesLocalCoords |= clipFP->usesLocalCoords();
|
const GrFragmentProcessor* clipFP = clip->clipCoverageFragmentProcessor(i);
|
||||||
hasCoverageFP = true;
|
analysis.fCompatibleWithCoverageAsAlpha &= clipFP->compatibleWithCoverageAsAlpha();
|
||||||
|
coverageUsesLocalCoords |= clipFP->usesLocalCoords();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int colorFPsToEliminate = colorAnalysis.initialProcessorsToEliminate(overrideInputColor);
|
int colorFPsToEliminate = colorAnalysis.initialProcessorsToEliminate(overrideInputColor);
|
||||||
analysis.fInputColorType = static_cast<Analysis::PackedInputColorType>(
|
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.
|
// account for floating point rounding error that may have occurred during coord transforms.
|
||||||
SkRect relaxedQueryBounds = queryBounds.makeInset(GrClip::kBoundsTolerance,
|
SkRect relaxedQueryBounds = queryBounds.makeInset(GrClip::kBoundsTolerance,
|
||||||
GrClip::kBoundsTolerance);
|
GrClip::kBoundsTolerance);
|
||||||
|
if (relaxedQueryBounds.isEmpty()) {
|
||||||
|
relaxedQueryBounds = queryBounds;
|
||||||
|
}
|
||||||
|
|
||||||
SkClipStack::Iter iter(stack, SkClipStack::Iter::kTop_IterStart);
|
SkClipStack::Iter iter(stack, SkClipStack::Iter::kTop_IterStart);
|
||||||
int numAAElements = 0;
|
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
|
// 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.
|
// attempt this in a situation that would require coverage AA.
|
||||||
SkASSERT(!appliedClip.clipCoverageFragmentProcessor());
|
SkASSERT(!appliedClip.numClipCoverageFragmentProcessors());
|
||||||
|
|
||||||
fRenderTargetContext->setNeedsStencil();
|
fRenderTargetContext->setNeedsStencil();
|
||||||
|
|
||||||
|
@ -299,7 +299,7 @@ public:
|
|||||||
RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip,
|
RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip,
|
||||||
GrPixelConfigIsClamped dstIsClamped) override {
|
GrPixelConfigIsClamped dstIsClamped) override {
|
||||||
GrProcessorAnalysisCoverage coverage;
|
GrProcessorAnalysisCoverage coverage;
|
||||||
if (AAMode::kNone == fAAMode && !clip->clipCoverageFragmentProcessor()) {
|
if (AAMode::kNone == fAAMode && !clip->numClipCoverageFragmentProcessors()) {
|
||||||
coverage = GrProcessorAnalysisCoverage::kNone;
|
coverage = GrProcessorAnalysisCoverage::kNone;
|
||||||
} else {
|
} else {
|
||||||
coverage = GrProcessorAnalysisCoverage::kSingleChannel;
|
coverage = GrProcessorAnalysisCoverage::kSingleChannel;
|
||||||
|
@ -71,7 +71,7 @@ GrDrawOp::RequiresDstTexture GrSimpleMeshDrawOpHelper::xpRequiresDstTexture(
|
|||||||
if (fProcessors) {
|
if (fProcessors) {
|
||||||
GrProcessorAnalysisCoverage coverage = geometryCoverage;
|
GrProcessorAnalysisCoverage coverage = geometryCoverage;
|
||||||
if (GrProcessorAnalysisCoverage::kNone == coverage) {
|
if (GrProcessorAnalysisCoverage::kNone == coverage) {
|
||||||
coverage = clip->clipCoverageFragmentProcessor()
|
coverage = clip->numClipCoverageFragmentProcessors()
|
||||||
? GrProcessorAnalysisCoverage::kSingleChannel
|
? GrProcessorAnalysisCoverage::kSingleChannel
|
||||||
: GrProcessorAnalysisCoverage::kNone;
|
: GrProcessorAnalysisCoverage::kNone;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user