Brian Salomon | 92ce594 | 2017-01-18 11:01:10 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrProcessorSet_DEFINED |
| 9 | #define GrProcessorSet_DEFINED |
| 10 | |
| 11 | #include "GrFragmentProcessor.h" |
| 12 | #include "GrPaint.h" |
| 13 | #include "GrPipeline.h" |
| 14 | #include "SkTemplates.h" |
| 15 | |
| 16 | class GrXPFactory; |
| 17 | |
| 18 | class GrProcessorSet : private SkNoncopyable { |
| 19 | public: |
| 20 | GrProcessorSet(GrPaint&& paint); |
| 21 | |
| 22 | ~GrProcessorSet() { |
| 23 | // We are deliberately not using sk_sp here because this will be updated to work with |
| 24 | // "pending execution" refs. |
| 25 | for (auto fp : fFragmentProcessors) { |
| 26 | fp->unref(); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | int numColorFragmentProcessors() const { return fColorFragmentProcessorCnt; } |
| 31 | int numCoverageFragmentProcessors() const { |
| 32 | return fFragmentProcessors.count() - fColorFragmentProcessorCnt; |
| 33 | } |
| 34 | int numFragmentProcessors() const { return fFragmentProcessors.count(); } |
| 35 | |
| 36 | const GrFragmentProcessor* colorFragmentProcessor(int idx) const { |
| 37 | SkASSERT(idx < fColorFragmentProcessorCnt); |
| 38 | return fFragmentProcessors[idx]; |
| 39 | } |
| 40 | const GrFragmentProcessor* coverageFragmentProcessor(int idx) const { |
| 41 | return fFragmentProcessors[idx + fColorFragmentProcessorCnt]; |
| 42 | } |
| 43 | |
| 44 | const GrXPFactory* xpFactory() const { return fXPFactory; } |
| 45 | |
| 46 | void analyzeFragmentProcessors(GrPipelineAnalysis* analysis) const { |
| 47 | const GrFragmentProcessor* const* fps = fFragmentProcessors.get(); |
Brian Salomon | 0831f1b | 2017-01-18 11:08:41 -0500 | [diff] [blame^] | 48 | analysis->fColorPOI.analyzeProcessors(fps, fColorFragmentProcessorCnt); |
Brian Salomon | 92ce594 | 2017-01-18 11:01:10 -0500 | [diff] [blame] | 49 | fps += fColorFragmentProcessorCnt; |
Brian Salomon | 0831f1b | 2017-01-18 11:08:41 -0500 | [diff] [blame^] | 50 | analysis->fCoveragePOI.analyzeProcessors(fps, this->numCoverageFragmentProcessors()); |
Brian Salomon | 92ce594 | 2017-01-18 11:01:10 -0500 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | private: |
| 54 | const GrXPFactory* fXPFactory = nullptr; |
| 55 | SkAutoSTArray<4, const GrFragmentProcessor*> fFragmentProcessors; |
| 56 | int fColorFragmentProcessorCnt; |
| 57 | }; |
| 58 | |
| 59 | #endif |