aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrProcessorSet.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-03-28 16:32:05 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-29 13:17:50 +0000
commit318538484f99253b6a2acf97d4d1b420e628b289 (patch)
treea698f31af79a873f16bad8847c50623bb44a19be /src/gpu/GrProcessorSet.cpp
parent02bb6df0819d932a7a7ef8c6fb6914e3c5a0f4a2 (diff)
Remove GrXferProcessor::getOptimizations.
This replaces GrXferProcessor::getOptimizations with a new function on GrXPFactory. The results are made available via FragmentProcessorAnalysis. Bug: skia: Change-Id: I535985458c9d13ad858cac94e957e2fdbe332036 Reviewed-on: https://skia-review.googlesource.com/10218 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrProcessorSet.cpp')
-rw-r--r--src/gpu/GrProcessorSet.cpp50
1 files changed, 43 insertions, 7 deletions
diff --git a/src/gpu/GrProcessorSet.cpp b/src/gpu/GrProcessorSet.cpp
index 4a508921b1..0350ba5758 100644
--- a/src/gpu/GrProcessorSet.cpp
+++ b/src/gpu/GrProcessorSet.cpp
@@ -9,6 +9,7 @@
#include "GrAppliedClip.h"
#include "GrCaps.h"
#include "GrPipelineAnalysis.h"
+#include "GrXferProcessor.h"
GrProcessorSet::GrProcessorSet(GrPaint&& paint) {
fXPFactory = paint.fXPFactory;
@@ -97,7 +98,7 @@ void GrProcessorSet::FragmentProcessorAnalysis::internalInit(
fps += processors.fColorFragmentProcessorCnt;
int n = processors.numCoverageFragmentProcessors();
bool hasCoverageFP = n > 0;
- fUsesLocalCoords = colorInfo.usesLocalCoords();
+ bool coverageUsesLocalCoords = false;
for (int i = 0; i < n; ++i) {
if (!fps[i]->compatibleWithCoverageAsAlpha()) {
fCompatibleWithCoverageAsAlpha = false;
@@ -105,12 +106,12 @@ void GrProcessorSet::FragmentProcessorAnalysis::internalInit(
// compatible with the coverage-as-alpha optimization.
GrCapsDebugf(&caps, "Coverage FP is not compatible with coverage as alpha.\n");
}
- fUsesLocalCoords |= fps[i]->usesLocalCoords();
+ coverageUsesLocalCoords |= fps[i]->usesLocalCoords();
}
if (clipFP) {
fCompatibleWithCoverageAsAlpha &= clipFP->compatibleWithCoverageAsAlpha();
- fUsesLocalCoords |= clipFP->usesLocalCoords();
+ coverageUsesLocalCoords |= clipFP->usesLocalCoords();
hasCoverageFP = true;
}
fInitialColorProcessorsToEliminate = colorInfo.initialProcessorsToEliminate(&fInputColor);
@@ -126,12 +127,44 @@ void GrProcessorSet::FragmentProcessorAnalysis::internalInit(
fOutputColorType = static_cast<unsigned>(ColorType::kUnknown);
}
+ GrPipelineAnalysisCoverage outputCoverage;
if (GrPipelineAnalysisCoverage::kLCD == coverageInput) {
- fOutputCoverageType = static_cast<unsigned>(GrPipelineAnalysisCoverage::kLCD);
+ outputCoverage = GrPipelineAnalysisCoverage::kLCD;
} else if (hasCoverageFP || GrPipelineAnalysisCoverage::kSingleChannel == coverageInput) {
- fOutputCoverageType = static_cast<unsigned>(GrPipelineAnalysisCoverage::kSingleChannel);
+ outputCoverage = GrPipelineAnalysisCoverage::kSingleChannel;
} else {
- fOutputCoverageType = static_cast<unsigned>(GrPipelineAnalysisCoverage::kNone);
+ outputCoverage = GrPipelineAnalysisCoverage::kNone;
+ }
+ fOutputCoverageType = static_cast<unsigned>(outputCoverage);
+
+ GrXPFactory::AnalysisProperties props = GrXPFactory::GetAnalysisProperties(
+ processors.fXPFactory, colorInfo.outputColor(), outputCoverage, caps);
+ if (!processors.numCoverageFragmentProcessors() &&
+ GrPipelineAnalysisCoverage::kNone == coverageInput) {
+ fCanCombineOverlappedStencilAndCover = SkToBool(
+ props & GrXPFactory::AnalysisProperties::kCanCombineOverlappedStencilAndCover);
+ } else {
+ // If we have non-clipping coverage processors we don't try to merge stencil steps as its
+ // unclear whether it will be correct. We don't expect this to happen in practice.
+ fCanCombineOverlappedStencilAndCover = false;
+ }
+ fRequiresDstTexture = SkToBool(props & GrXPFactory::AnalysisProperties::kRequiresDstTexture);
+ fIgnoresInputColor = SkToBool(props & GrXPFactory::AnalysisProperties::kIgnoresInputColor);
+ fCompatibleWithCoverageAsAlpha &=
+ SkToBool(props & GrXPFactory::AnalysisProperties::kCompatibleWithAlphaAsCoverage);
+ if (props & GrXPFactory::AnalysisProperties::kIgnoresInputColor) {
+ fInitialColorProcessorsToEliminate = processors.numColorFragmentProcessors();
+ // If the output of the last color stage is known then the kIgnoresInputColor optimization
+ // may depend upon it being the input to the xp.
+ if (!outputColor.isConstant(&fInputColor)) {
+ // Otherwise, the only property the XP factory could have relied upon to compute
+ // kIgnoresInputColor is opaqueness.
+ fInputColor = GrColor_WHITE;
+ }
+ fValidInputColor = true;
+ fUsesLocalCoords = coverageUsesLocalCoords;
+ } else {
+ fUsesLocalCoords = coverageUsesLocalCoords | colorInfo.usesLocalCoords();
}
}
@@ -149,9 +182,12 @@ void GrProcessorSet::FragmentProcessorAnalysis::init(const GrPipelineAnalysisCol
GrProcessorSet::FragmentProcessorAnalysis::FragmentProcessorAnalysis(
const GrPipelineAnalysisColor& colorInput,
const GrPipelineAnalysisCoverage coverageInput,
+ const GrXPFactory* factory,
const GrCaps& caps)
: FragmentProcessorAnalysis() {
- this->internalInit(colorInput, coverageInput, GrProcessorSet(GrPaint()), nullptr, caps);
+ GrPaint paint;
+ paint.setXPFactory(factory);
+ this->internalInit(colorInput, coverageInput, GrProcessorSet(std::move(paint)), nullptr, caps);
}
void GrProcessorSet::analyzeAndEliminateFragmentProcessors(