36 fShaderOptions.clear();
37 fShaderOptions.push_back_n(shaders.size(), shaders.data());
41 fImageFilterOptions.clear();
42 fImageFilterOptions.push_back_n(imageFilters.size(), imageFilters.data());
46 fMaskFilterOptions.clear();
47 fMaskFilterOptions.push_back_n(maskFilters.size(), maskFilters.data());
51 fColorFilterOptions.clear();
52 fColorFilterOptions.push_back_n(colorFilters.size(), colorFilters.data());
56 fColorFilterOptions.push_back(std::move(cf));
60 fBlendModeOptions.
clear();
66 if (
b->priv().asBlendMode().has_value()) {
67 fBlendModeOptions.
push_back(
b->priv().asBlendMode().value());
69 fBlenderOptions.push_back(
b);
76 fClipShaderOptions.reserve(2 * clipShaders.size());
85 fClipShaderOptions.emplace_back(std::move(withCTM));
86 fClipShaderOptions.emplace_back(std::move(inverted));
90int PaintOptions::numShaderCombinations()
const {
91 int numShaderCombinations = 0;
93 numShaderCombinations +=
s->numCombinations();
97 return numShaderCombinations ? numShaderCombinations : 1;
100int PaintOptions::numColorFilterCombinations()
const {
101 int numColorFilterCombinations = 0;
104 ++numColorFilterCombinations;
106 numColorFilterCombinations += cf->numCombinations();
111 return numColorFilterCombinations ? numColorFilterCombinations : 1;
114int PaintOptions::numBlendCombinations()
const {
115 int numBlendCombos = fBlendModeOptions.
size();
117 SkASSERT(!
b->priv().asBlendMode().has_value());
118 numBlendCombos +=
b->priv().numChildCombinations();
121 if (!numBlendCombos) {
126 return numBlendCombos;
129int PaintOptions::numClipShaderCombinations()
const {
130 int numClipShaderCombos = 0;
133 numClipShaderCombos += cs->priv().numChildCombinations();
135 ++numClipShaderCombos;
140 return numClipShaderCombos ? numClipShaderCombos : 1;
143int PaintOptions::numCombinations()
const {
144 return this->numShaderCombinations() *
145 this->numColorFilterCombinations() *
146 this->numBlendCombinations() *
147 this->numClipShaderCombinations();
154 PrecompileBlender* blender) {
163void PaintOptions::createKey(
const KeyContext& keyContext,
164 PaintParamsKeyBuilder* keyBuilder,
165 PipelineDataGatherer* gatherer,
166 int desiredCombination,
167 bool addPrimitiveBlender,
170 SkASSERT(desiredCombination < this->numCombinations());
172 const
int numClipShaderCombos = this->numClipShaderCombinations();
173 const
int numBlendModeCombos = this->numBlendCombinations();
174 const
int numColorFilterCombinations = this->numColorFilterCombinations();
176 const
int desiredClipShaderCombination = desiredCombination % numClipShaderCombos;
177 int remainingCombinations = desiredCombination / numClipShaderCombos;
179 const
int desiredBlendCombination = remainingCombinations % numBlendModeCombos;
180 remainingCombinations /= numBlendModeCombos;
182 const
int desiredColorFilterCombination = remainingCombinations % numColorFilterCombinations;
183 remainingCombinations /= numColorFilterCombinations;
185 const
int desiredShaderCombination = remainingCombinations;
186 SkASSERT(desiredShaderCombination < this->numShaderCombinations());
189 const
bool kOpaquePaintColor =
true;
191 auto clipShader = PrecompileBase::SelectOption(
SkSpan(fClipShaderOptions),
192 desiredClipShaderCombination);
194 std::pair<
sk_sp<PrecompileBlender>,
int> finalBlender;
195 if (desiredBlendCombination < fBlendModeOptions.
size()) {
200 desiredBlendCombination - fBlendModeOptions.
size());
202 if (!finalBlender.first) {
206 finalBlender.first.get());
208 PaintOption option(kOpaquePaintColor,
211 desiredShaderCombination),
213 desiredColorFilterCombination),
219 option.toKey(keyContext, keyBuilder, gatherer);
224void create_image_drawing_pipelines(
const KeyContext& keyContext,
225 PipelineDataGatherer* gatherer,
227 const PaintOptions& orig) {
228 PaintOptions imagePaintOptions;
234 imagePaintOptions.setShaders({ imageShader });
235 imagePaintOptions.setBlendModes(orig.getBlendModes());
236 imagePaintOptions.setBlenders(orig.getBlenders());
237 imagePaintOptions.setColorFilters(orig.getColorFilters());
238 imagePaintOptions.priv().addColorFilter(
nullptr);
240 imagePaintOptions.priv().buildCombinations(keyContext,
250void PaintOptions::buildCombinations(
251 const KeyContext& keyContext,
252 PipelineDataGatherer* gatherer,
254 bool withPrimitiveBlender,
256 const ProcessCombination& processCombination)
const {
258 PaintParamsKeyBuilder
builder(keyContext.dict());
260 if (!fImageFilterOptions.empty() || !fMaskFilterOptions.empty()) {
265 tmp.setImageFilters({});
266 tmp.setMaskFilters({});
269 if (!fImageFilterOptions.empty()) {
270 std::vector<sk_sp<PrecompileColorFilter>> newCFs(tmp.fColorFilterOptions.begin(),
271 tmp.fColorFilterOptions.end());
272 if (newCFs.empty()) {
276 newCFs.push_back(
nullptr);
284 if (imageFiltersCF) {
285 if (!tmp.fColorFilterOptions.empty()) {
290 newCFs.push_back(std::move(newCF));
293 newCFs.push_back(imageFiltersCF);
298 tmp.setColorFilters(newCFs);
301 tmp.buildCombinations(keyContext, gatherer, drawTypes, withPrimitiveBlender,
coverage,
304 create_image_drawing_pipelines(keyContext, gatherer, processCombination, *
this);
307 o->createPipelines(keyContext, gatherer, processCombination);
310 o->createPipelines(keyContext, gatherer, processCombination);
313 int numCombinations = this->numCombinations();
314 for (
int i = 0;
i < numCombinations; ++
i) {
319 this->createKey(keyContext, &
builder, gatherer,
i, withPrimitiveBlender,
coverage);
323 UniquePaintParamsID paintID = keyContext.dict()->findOrCreate(&
builder);
325 processCombination(paintID, drawTypes, withPrimitiveBlender,
coverage);
331 fPaintOptions->addColorFilter(std::move(cf));
@ kSrcOver
r = s + (1-sa)*d
SkSpan(Container &&) -> SkSpan< std::remove_pointer_t< decltype(std::data(std::declval< Container >()))> >
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
constexpr T * data() const
constexpr size_t size() const
void addColorFilter(sk_sp< PrecompileColorFilter > cf)
PaintOptions::ProcessCombination ProcessCombination
void setColorFilters(SkSpan< const sk_sp< PrecompileColorFilter > > colorFilters)
void setBlendModes(SkSpan< const SkBlendMode > blendModes)
void setShaders(SkSpan< const sk_sp< PrecompileShader > > shaders)
void setMaskFilters(SkSpan< const sk_sp< PrecompileMaskFilter > > maskFilters)
void setImageFilters(SkSpan< const sk_sp< PrecompileImageFilter > > imageFilters)
PaintOptions & operator=(const PaintOptions &)
void setBlenders(SkSpan< const sk_sp< PrecompileBlender > > blenders)
static std::pair< sk_sp< T >, int > SelectOption(SkSpan< const sk_sp< T > > options, int desiredOption)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
SK_API sk_sp< PrecompileBlender > Mode(SkBlendMode)
SK_API sk_sp< PrecompileColorFilter > Blend()
sk_sp< PrecompileShader > Image(SkEnumBitMask< PrecompileImageShaderFlags >)
sk_sp< PrecompileShader > CTM(SkSpan< const sk_sp< PrecompileShader > > wrapped)
DstReadRequirement GetDstReadRequirement(const Caps *caps, std::optional< SkBlendMode > blendMode, Coverage coverage)