aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrProcOptInfo.h
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-02-10 14:29:38 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-10 20:02:32 +0000
commiteec6f7be5461e588210f383b8af18f324a2bdb46 (patch)
tree1d72e2d8636f65b32e0edaa4a47fe3fa6d6c3b05 /src/gpu/GrProcOptInfo.h
parent2aeae78a2ce3b036f0401fd0381d6fd6e2a7a1fc (diff)
Use new fragment processor optimization queries.
This doesn't yet delete the old virtuals. It still uses the color and component flags model for the pipeline input and blended output but I'm planning to change those as well. Change-Id: I64e2ec0fe9ed9fae3aabf1ca8c9bc0582fc7565a Reviewed-on: https://skia-review.googlesource.com/7760 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/GrProcOptInfo.h')
-rw-r--r--src/gpu/GrProcOptInfo.h83
1 files changed, 52 insertions, 31 deletions
diff --git a/src/gpu/GrProcOptInfo.h b/src/gpu/GrProcOptInfo.h
index 39175fdef6..be46712fa3 100644
--- a/src/gpu/GrProcOptInfo.h
+++ b/src/gpu/GrProcOptInfo.h
@@ -22,10 +22,11 @@ class GrPrimitiveProcessor;
*/
class GrProcOptInfo {
public:
- GrProcOptInfo() : fInOut(0, static_cast<GrColorComponentFlags>(0)) {}
+ GrProcOptInfo() { this->reset(0, kNone_GrColorComponentFlags); }
- GrProcOptInfo(GrColor color, GrColorComponentFlags colorFlags)
- : fInOut(color, colorFlags), fInputColor(color) {}
+ GrProcOptInfo(GrColor color, GrColorComponentFlags colorFlags) {
+ this->reset(color, colorFlags);
+ }
void resetToLCDCoverage(GrColor color, GrColorComponentFlags colorFlags) {
this->internalReset(color, colorFlags, true);
@@ -45,45 +46,65 @@ public:
*/
void analyzeProcessors(const GrFragmentProcessor* const* processors, int cnt);
- bool isSolidWhite() const { return fInOut.isSolidWhite(); }
- bool isOpaque() const { return fInOut.isOpaque(); }
- bool allStagesMultiplyInput() const { return fInOut.allStagesMulInput(); }
+ bool isSolidWhite() const {
+ return fProcessorsVisitedWithKnownOutput == fTotalProcessorsVisited &&
+ fLastKnownOutputColor == GrColor4f::OpaqueWhite();
+ }
+ bool isOpaque() const { return fIsOpaque; }
+ bool allProcessorsModulateByPremul() const { return fAllProcessorsModulatePremul; }
bool isLCDCoverage() const { return fIsLCDCoverage; }
- GrColor color() const { return fInOut.color(); }
- GrColorComponentFlags validFlags() const { return fInOut.validFlags(); }
/**
- * Returns the index of the first effective color processor. If an intermediate processor
- * doesn't read its input or has a known output, then we can ignore all earlier processors
- * since they will not affect the final output. Thus the first effective processors index is
- * the index to the first processor that will have an effect on the final output.
- *
- * If processors before the firstEffectiveProcessorIndex() are removed, corresponding values
- * from inputColorIsUsed(), inputColorToEffectiveProcessor(), removeVertexAttribs(), and
- * readsDst() must be used when setting up the draw to ensure correct drawing.
+ * If we detected that the result after the first N processors is a known color then we
+ * eliminate those N processors and replace the GrDrawOp's color input to the GrPipeline with
+ * the known output of the Nth processor, so that the Nth+1 fragment processor (or the XP if
+ * there are only N processors) sees its expected input. If this returns 0 then there are no
+ * processors to eliminate.
*/
- int firstEffectiveProcessorIndex() const { return fFirstEffectiveProcessorIndex; }
+ int initialProcessorsToEliminate(GrColor* newPipelineInputColor) const {
+ if (fProcessorsVisitedWithKnownOutput > 0) {
+ *newPipelineInputColor = fLastKnownOutputColor.toGrColor();
+ }
+ return SkTMax(0, fProcessorsVisitedWithKnownOutput);
+ }
+ int initialProcessorsToEliminate(GrColor4f* newPipelineInputColor) const {
+ if (fProcessorsVisitedWithKnownOutput > 0) {
+ *newPipelineInputColor = fLastKnownOutputColor;
+ }
+ return SkTMax(0, fProcessorsVisitedWithKnownOutput);
+ }
- /**
- * If input color is used and per-vertex colors are not used, this is the input color to the
- * first effective processor.
- */
- GrColor inputColorToFirstEffectiveProccesor() const { return fInputColor; }
+ bool hasKnownOutputColor(GrColor* knownOutputColor = nullptr) const {
+ if (fProcessorsVisitedWithKnownOutput != fTotalProcessorsVisited) {
+ return false;
+ }
+ if (knownOutputColor) {
+ *knownOutputColor = fLastKnownOutputColor.toGrColor();
+ }
+ return true;
+ }
private:
void internalReset(GrColor color, GrColorComponentFlags colorFlags, bool isLCDCoverage) {
- fInOut.reset(color, colorFlags);
- fFirstEffectiveProcessorIndex = 0;
- fInputColor = color;
+ fTotalProcessorsVisited = 0;
fIsLCDCoverage = isLCDCoverage;
+ fIsOpaque = (kA_GrColorComponentFlag & colorFlags) && GrColorIsOpaque(color);
+ fAllProcessorsModulatePremul = true;
+ if (kRGBA_GrColorComponentFlags == colorFlags) {
+ fProcessorsVisitedWithKnownOutput = 0;
+ fLastKnownOutputColor = GrColor4f::FromGrColor(color);
+ } else {
+ // -1 so that we know that even without adding processors that the color is not known.
+ fProcessorsVisitedWithKnownOutput = -1;
+ }
}
- void internalCalc(const GrFragmentProcessor* const[], int cnt);
-
- GrInvariantOutput fInOut;
- int fFirstEffectiveProcessorIndex = 0;
- bool fIsLCDCoverage = false;
- GrColor fInputColor = 0;
+ int fTotalProcessorsVisited;
+ int fProcessorsVisitedWithKnownOutput;
+ bool fIsLCDCoverage;
+ bool fIsOpaque;
+ bool fAllProcessorsModulatePremul;
+ GrColor4f fLastKnownOutputColor;
};
#endif