diff options
author | Brian Salomon <bsalomon@google.com> | 2017-02-10 14:29:38 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-10 20:02:32 +0000 |
commit | eec6f7be5461e588210f383b8af18f324a2bdb46 (patch) | |
tree | 1d72e2d8636f65b32e0edaa4a47fe3fa6d6c3b05 /src/gpu/GrFragmentProcessor.cpp | |
parent | 2aeae78a2ce3b036f0401fd0381d6fd6e2a7a1fc (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/GrFragmentProcessor.cpp')
-rw-r--r-- | src/gpu/GrFragmentProcessor.cpp | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp index 92d74eb592..07bbe7bd1b 100644 --- a/src/gpu/GrFragmentProcessor.cpp +++ b/src/gpu/GrFragmentProcessor.cpp @@ -394,39 +394,29 @@ sk_sp<GrFragmentProcessor> GrFragmentProcessor::RunInSeries(sk_sp<GrFragmentProc if (!cnt) { return nullptr; } - + if (1 == cnt) { + return series[0]; + } // Run the through the series, do the invariant output processing, and look for eliminations. GrProcOptInfo info(0x0, kNone_GrColorComponentFlags); info.analyzeProcessors(sk_sp_address_as_pointer_address(series), cnt); - if (kRGBA_GrColorComponentFlags == info.validFlags()) { - // TODO: We need to preserve 4f and color spaces during invariant processing. This color - // has definitely lost precision, and could easily be in the wrong gamut (or have been - // built from colors in multiple spaces). - return GrConstColorProcessor::Make(GrColor4f::FromGrColor(info.color()), - GrConstColorProcessor::kIgnore_InputMode); - } - SkTArray<sk_sp<GrFragmentProcessor>> replacementSeries; - - int firstIdx = info.firstEffectiveProcessorIndex(); - cnt -= firstIdx; - if (firstIdx > 0) { - // See comment above - need to preserve 4f and color spaces during invariant processing. - sk_sp<GrFragmentProcessor> colorFP(GrConstColorProcessor::Make( - GrColor4f::FromGrColor(info.inputColorToFirstEffectiveProccesor()), - GrConstColorProcessor::kIgnore_InputMode)); - cnt += 1; + GrColor4f knownColor; + int leadingFPsToEliminate = info.initialProcessorsToEliminate(&knownColor); + if (leadingFPsToEliminate) { + sk_sp<GrFragmentProcessor> colorFP( + GrConstColorProcessor::Make(knownColor, GrConstColorProcessor::kIgnore_InputMode)); + if (leadingFPsToEliminate == cnt) { + return colorFP; + } + cnt = cnt - leadingFPsToEliminate + 1; replacementSeries.reserve(cnt); replacementSeries.emplace_back(std::move(colorFP)); for (int i = 0; i < cnt - 1; ++i) { - replacementSeries.emplace_back(std::move(series[firstIdx + i])); + replacementSeries.emplace_back(std::move(series[leadingFPsToEliminate + i])); } series = replacementSeries.begin(); } - - if (1 == cnt) { - return series[0]; - } return sk_sp<GrFragmentProcessor>(new SeriesFragmentProcessor(series, cnt)); } |