186public:
188
191
192
193
194
195
196 virtual bool isConstant() const { return false; }
197
199#define M(type) k##type,
201#undef M
202 };
203
205
206 enum class GradientType {
208#define M(type) k##type,
210#undef M
211 };
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241 struct GradientInfo {
242 int fColorCount = 0;
243
244
245
251 uint32_t fGradientFlags = 0;
252 };
253
254 virtual GradientType asGradient(GradientInfo*
info =
nullptr,
255 SkMatrix* localMatrix =
nullptr)
const {
256 return GradientType::kNone;
257 }
258
260
261 kOpaqueAlpha_Flag = 1 << 0,
262 };
263
264
265
266
267 struct ContextRec {
273 : fMatrixRec(matrixRec)
274 , fDstColorType(dstColorType)
275 , fDstColorSpace(dstColorSpace)
276 , fProps(props)
277 , fPaintAlpha(paintAlpha) {}
278
279 static ContextRec Concat(
const ContextRec& parentRec,
const SkMatrix& localM) {
280 return {parentRec.fPaintAlpha,
281 parentRec.fMatrixRec.concat(localM),
282 parentRec.fDstColorType,
283 parentRec.fDstColorSpace,
284 parentRec.fProps};
285 }
286
292
293 bool isLegacyCompatible(
SkColorSpace* shadersColorSpace)
const;
294 };
295
297 public:
299
301
302
303
304
305
306
307
308
309 virtual uint32_t
getFlags()
const {
return 0; }
310
311
312
313
314
315
317
318 protected:
319
321
322 uint8_t getPaintAlpha() const { return fPaintAlpha; }
323 const SkMatrix& getTotalInverse()
const {
return fTotalInverse; }
324
325 private:
327 uint8_t fPaintAlpha;
328 };
329
330
331
332
333
334
336
337
338
339
340
341
342
343
344
346
347
348
349
350
351
352 [[nodiscard]]
bool appendRootStages(
const SkStageRec& rec,
const SkMatrix& ctm)
const;
353
354
355
356
357
358
360
362 return nullptr;
363 }
364
366
367 static Type GetFlattenableType() {
return kSkShader_Type; }
368 Type getFlattenableType()
const override {
return GetFlattenableType(); }
369
374 }
375 static void RegisterFlattenables();
376
377
378
379
380
382
384#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
386#endif
388 }
389
390protected:
392
394
395#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
396
397
398
399
401 return nullptr;
402 }
403#endif
404
405 virtual bool onAsLuminanceColor(
SkColor4f*)
const {
406 return false;
407 }
408
410};
413}
414
417}
418
421}
422
430
431#endif
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
SkShaderBase * as_SB(SkShader *shader)
void SkRegisterEmptyShaderFlattenable()
void SkRegisterWorkingColorSpaceShaderFlattenable()
void SkRegisterColor4ShaderFlattenable()
#define SK_ALL_GRADIENTS(M)
void SkRegisterColorShaderFlattenable()
void SkRegisterPerlinNoiseShaderFlattenable()
void SkRegisterBlendShaderFlattenable()
void SkRegisterCoordClampShaderFlattenable()
#define SK_ALL_SHADERS(M)
static sk_sp< SkFlattenable > Deserialize(Type, const void *data, size_t length, const SkDeserialProcs *procs=nullptr)
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)