Flutter Engine
The Flutter Engine
PrecompileInternal.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Google LLC
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 skgpu_graphite_PrecompileInternal_DEFINED
9#define skgpu_graphite_PrecompileInternal_DEFINED
10
18
19#include <functional>
20#include <optional>
21#include <vector>
22
23class SkRuntimeEffect;
24
25namespace skgpu::graphite {
26
27enum class Coverage;
28class Context;
29
30
31class UniquePaintParamsID;
32
33// Create the Pipelines specified by 'options' by combining the shading portion w/ the specified
34// 'drawTypes' and a stock set of RenderPass descriptors (e.g., kDepth+msaa, kDepthStencil+msaa)
36 const PaintOptions& options,
37 const KeyContext& keyContext,
38 DrawTypeFlags drawTypes,
39 bool withPrimitiveBlender,
41
42//--------------------------------------------------------------------------------------------------
44public:
45 virtual sk_sp<PrecompileColorFilter> isColorFilterNode() const { return nullptr; }
46
47 int countInputs() const { return fInputs.count(); }
48
49 const PrecompileImageFilter* getInput(int index) const {
50 SkASSERT(index < this->countInputs());
51 return fInputs[index].get();
52 }
53
54protected:
56 : PrecompileBase(Type::kImageFilter) {
57 fInputs.reset(inputs.size());
58 for (int i = 0; i < (int) inputs.size(); ++i) {
59 fInputs[i] = inputs[i];
60 }
61 }
62
63private:
64 friend class PaintOptions; // for createPipelines() access
65
66 // The PrecompileImageFilter classes do not use the PrecompileBase::addToKey virtual since
67 // they, in general, do not themselves contribute to a given SkPaint/Pipeline but, rather,
68 // create separate SkPaints/Pipelines from whole cloth (in onCreatePipelines).
69 void addToKey(const KeyContext& keyContext,
71 PipelineDataGatherer* gatherer,
72 int desiredCombination) const final {
73 SkASSERT(false);
74 }
75
76 sk_sp<PrecompileColorFilter> asAColorFilter() const;
77
78 virtual void onCreatePipelines(const KeyContext&,
81
82 void createPipelines(const KeyContext& keyContext,
83 PipelineDataGatherer* gatherer,
84 const PaintOptionsPriv::ProcessCombination& processCombination) {
85 // TODO: we will want to mark already visited nodes to prevent loops and track
86 // already created Pipelines so we don't over-generate too much (e.g., if a DAG
87 // has multiple blurs we don't want to keep trying to create all the blur pipelines).
88 this->onCreatePipelines(keyContext, gatherer, processCombination);
89
90 for (const sk_sp<PrecompileImageFilter>& input : fInputs) {
91 if (input) {
92 input->createPipelines(keyContext, gatherer, processCombination);
93 }
94 }
95 }
96
98};
99
101public:
103
104private:
105 friend class PaintOptions; // for createPipelines() access
106
107 // The PrecompileMaskFilter classes do not use the PrecompileBase::addToKey virtual since
108 // they, in general, do not themselves contribute to a given SkPaint/Pipeline but, rather,
109 // create separate SkPaints/Pipelines from whole cloth (in createPipelines).
110 void addToKey(const KeyContext& keyContext,
112 PipelineDataGatherer* gatherer,
113 int desiredCombination) const final {
114 SkASSERT(false);
115 }
116
117 virtual void createPipelines(const KeyContext&,
119 const PaintOptionsPriv::ProcessCombination&) const = 0;
120};
121
122} // namespace skgpu::graphite
123
124#endif // skgpu_graphite_PrecompileInternal_DEFINED
const char * options
#define SkASSERT(cond)
Definition: SkAssert.h:116
PaintOptions::ProcessCombination ProcessCombination
virtual void onCreatePipelines(const KeyContext &, PipelineDataGatherer *, const PaintOptionsPriv::ProcessCombination &) const =0
PrecompileImageFilter(SkSpan< sk_sp< PrecompileImageFilter > > inputs)
virtual sk_sp< PrecompileColorFilter > isColorFilterNode() const
const PrecompileImageFilter * getInput(int index) const
virtual void createPipelines(const KeyContext &, PipelineDataGatherer *, const PaintOptionsPriv::ProcessCombination &) const =0
void PrecompileCombinations(Context *context, const PaintOptions &options, const KeyContext &keyContext, DrawTypeFlags drawTypes, bool withPrimitiveBlender, Coverage coverage)