diff options
author | Brian Salomon <bsalomon@google.com> | 2017-01-18 11:01:10 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-18 16:48:41 +0000 |
commit | 92ce5946855aa8d55bb4a0dd0a47d58746d67d0a (patch) | |
tree | ed5040bbd28661901009337c4a6ee311175ab142 /src/gpu/GrProcessorSet.h | |
parent | 70a309aa055dad8b2e7a6cbd90774f44a7fcd5fb (diff) |
Add class GrProcessorSet which represents color and coverage FPs and a XPFactory.
Eventually ops can use this to hold their ops and create GrPipelines at flush time.
For now it is used by GrPipelineBuilder.
Change-Id: I0db3892032f2d07238e4c847a790678b3aab456f
Reviewed-on: https://skia-review.googlesource.com/7132
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrProcessorSet.h')
-rw-r--r-- | src/gpu/GrProcessorSet.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/gpu/GrProcessorSet.h b/src/gpu/GrProcessorSet.h new file mode 100644 index 0000000000..684fb26a84 --- /dev/null +++ b/src/gpu/GrProcessorSet.h @@ -0,0 +1,59 @@ +/* + * Copyright 2017 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrProcessorSet_DEFINED +#define GrProcessorSet_DEFINED + +#include "GrFragmentProcessor.h" +#include "GrPaint.h" +#include "GrPipeline.h" +#include "SkTemplates.h" + +class GrXPFactory; + +class GrProcessorSet : private SkNoncopyable { +public: + GrProcessorSet(GrPaint&& paint); + + ~GrProcessorSet() { + // We are deliberately not using sk_sp here because this will be updated to work with + // "pending execution" refs. + for (auto fp : fFragmentProcessors) { + fp->unref(); + } + } + + int numColorFragmentProcessors() const { return fColorFragmentProcessorCnt; } + int numCoverageFragmentProcessors() const { + return fFragmentProcessors.count() - fColorFragmentProcessorCnt; + } + int numFragmentProcessors() const { return fFragmentProcessors.count(); } + + const GrFragmentProcessor* colorFragmentProcessor(int idx) const { + SkASSERT(idx < fColorFragmentProcessorCnt); + return fFragmentProcessors[idx]; + } + const GrFragmentProcessor* coverageFragmentProcessor(int idx) const { + return fFragmentProcessors[idx + fColorFragmentProcessorCnt]; + } + + const GrXPFactory* xpFactory() const { return fXPFactory; } + + void analyzeFragmentProcessors(GrPipelineAnalysis* analysis) const { + const GrFragmentProcessor* const* fps = fFragmentProcessors.get(); + analysis->fColorPOI.addProcessors(fps, fColorFragmentProcessorCnt); + fps += fColorFragmentProcessorCnt; + analysis->fCoveragePOI.addProcessors(fps, this->numCoverageFragmentProcessors()); + } + +private: + const GrXPFactory* fXPFactory = nullptr; + SkAutoSTArray<4, const GrFragmentProcessor*> fFragmentProcessors; + int fColorFragmentProcessorCnt; +}; + +#endif |