diff options
author | Brian Salomon <bsalomon@google.com> | 2017-07-20 16:46:46 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-21 11:48:53 +0000 |
commit | 650ced07d9660e74eb34ddff79293583f7b70837 (patch) | |
tree | fa178b22588dd1b6df6609432720e99a0e6ac633 /src/gpu/GrProcessorAnalysis.h | |
parent | 6ec9a4ffe43910551d15ddc95150472aabbc8b74 (diff) |
Make GrColorFragmentProcessorAnalysis do all analysis in constructor.
We no longer do piecemeal analysis. This simplifies the change to make FPs have unique ownership.
Change-Id: I4e6b2c23b4277b612dedfc466cee74630a30e997
Reviewed-on: https://skia-review.googlesource.com/25362
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrProcessorAnalysis.h')
-rw-r--r-- | src/gpu/GrProcessorAnalysis.h | 57 |
1 files changed, 21 insertions, 36 deletions
diff --git a/src/gpu/GrProcessorAnalysis.h b/src/gpu/GrProcessorAnalysis.h index a635e65e6c..4175b5ea48 100644 --- a/src/gpu/GrProcessorAnalysis.h +++ b/src/gpu/GrProcessorAnalysis.h @@ -90,28 +90,11 @@ enum class GrProcessorAnalysisCoverage { kNone, kSingleChannel, kLCD }; */ class GrColorFragmentProcessorAnalysis { public: - GrColorFragmentProcessorAnalysis() = default; - - GrColorFragmentProcessorAnalysis(const GrProcessorAnalysisColor& input) - : GrColorFragmentProcessorAnalysis() { - fAllProcessorsCompatibleWithCoverageAsAlpha = true; - fIsOpaque = input.isOpaque(); - GrColor color; - if (input.isConstant(&color)) { - fLastKnownOutputColor = GrColor4f::FromGrColor(color); - fProcessorsVisitedWithKnownOutput = 0; - } - } - - void reset(const GrProcessorAnalysisColor& input) { - *this = GrColorFragmentProcessorAnalysis(input); - } + GrColorFragmentProcessorAnalysis() = delete; - /** - * Runs through a series of processors and updates calculated values. This can be called - * repeatedly for cases when the sequence of processors is not in a contiguous array. - */ - void analyzeProcessors(const GrFragmentProcessor* const* processors, int cnt); + GrColorFragmentProcessorAnalysis(const GrProcessorAnalysisColor& input, + const GrFragmentProcessor* const* processors, + int cnt); bool isOpaque() const { return fIsOpaque; } @@ -121,7 +104,7 @@ public: * as indicated by initialProcessorsToEliminate() are in fact eliminated. */ bool allProcessorsCompatibleWithCoverageAsAlpha() const { - return fAllProcessorsCompatibleWithCoverageAsAlpha; + return fCompatibleWithCoverageAsAlpha; } /** @@ -139,34 +122,36 @@ public: * processors to eliminate. */ int initialProcessorsToEliminate(GrColor* newPipelineInputColor) const { - if (fProcessorsVisitedWithKnownOutput > 0) { + if (fProcessorsToEliminate > 0) { *newPipelineInputColor = fLastKnownOutputColor.toGrColor(); } - return SkTMax(0, fProcessorsVisitedWithKnownOutput); + return fProcessorsToEliminate; } int initialProcessorsToEliminate(GrColor4f* newPipelineInputColor) const { - if (fProcessorsVisitedWithKnownOutput > 0) { + if (fProcessorsToEliminate > 0) { *newPipelineInputColor = fLastKnownOutputColor; } - return SkTMax(0, fProcessorsVisitedWithKnownOutput); + return fProcessorsToEliminate; } + /** + * Provides known information about the last processor's output color. + */ GrProcessorAnalysisColor outputColor() const { - if (fProcessorsVisitedWithKnownOutput != fTotalProcessorsVisited) { - return GrProcessorAnalysisColor(fIsOpaque ? GrProcessorAnalysisColor::Opaque::kYes - : GrProcessorAnalysisColor::Opaque::kNo); + if (fKnowOutputColor) { + return fLastKnownOutputColor.toGrColor(); } - return GrProcessorAnalysisColor(fLastKnownOutputColor.toGrColor()); + return fIsOpaque ? GrProcessorAnalysisColor::Opaque::kYes + : GrProcessorAnalysisColor::Opaque::kNo; } private: - int fTotalProcessorsVisited = 0; - // negative one means even the color is unknown before adding the first processor. - int fProcessorsVisitedWithKnownOutput = -1; - bool fIsOpaque = false; - bool fAllProcessorsCompatibleWithCoverageAsAlpha = true; - bool fUsesLocalCoords = false; + bool fIsOpaque; + bool fCompatibleWithCoverageAsAlpha; + bool fUsesLocalCoords; + bool fKnowOutputColor; + int fProcessorsToEliminate; GrColor4f fLastKnownOutputColor; }; |