blob: 684fb26a84c6eeb085f349310aab49757799d61d [file] [log] [blame]
Brian Salomon92ce5942017-01-18 11:01:10 -05001/*
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
16class GrXPFactory;
17
18class GrProcessorSet : private SkNoncopyable {
19public:
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();
48 analysis->fColorPOI.addProcessors(fps, fColorFragmentProcessorCnt);
49 fps += fColorFragmentProcessorCnt;
50 analysis->fCoveragePOI.addProcessors(fps, this->numCoverageFragmentProcessors());
51 }
52
53private:
54 const GrXPFactory* fXPFactory = nullptr;
55 SkAutoSTArray<4, const GrFragmentProcessor*> fFragmentProcessors;
56 int fColorFragmentProcessorCnt;
57};
58
59#endif