Flutter Engine
The Flutter Engine
Classes | Static Public Member Functions | List of all members
skgpu::graphite::GradientShaderBlocks Struct Reference

#include <KeyHelpers.h>

Classes

struct  GradientData
 

Static Public Member Functions

static void AddBlock (const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *, const GradientData &)
 

Detailed Description

Definition at line 86 of file KeyHelpers.h.

Member Function Documentation

◆ AddBlock()

void skgpu::graphite::GradientShaderBlocks::AddBlock ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const GradientData gradData 
)
static

Definition at line 410 of file KeyHelpers.cpp.

413 {
414 auto dict = keyContext.dict();
415
416 int bufferOffset = 0;
417 if (gradData.fNumStops > GradientData::kNumInternalStorageStops && keyContext.recorder()) {
418 if (gradData.fUseStorageBuffer) {
419 bufferOffset = write_color_and_offset_bufdata(gradData.fNumStops,
420 gradData.fSrcColors,
421 gradData.fSrcOffsets,
422 gradData.fSrcShader,
423 gatherer);
424 } else {
425 SkASSERT(gradData.fColorsAndOffsetsProxy);
426 static constexpr SkTileMode kClampTiling[2] = {SkTileMode::kClamp, SkTileMode::kClamp};
427 gatherer->add(gradData.fColorsAndOffsetsProxy, {SkFilterMode::kNearest, kClampTiling});
428 }
429 }
430
432 switch (gradData.fType) {
434 codeSnippetID =
435 gradData.fNumStops <= 4 ? BuiltInCodeSnippetID::kLinearGradientShader4
436 : gradData.fNumStops <= 8 ? BuiltInCodeSnippetID::kLinearGradientShader8
437 : gradData.fUseStorageBuffer
440 add_linear_gradient_uniform_data(dict, codeSnippetID, gradData, bufferOffset, gatherer);
441 break;
442 case SkShaderBase::GradientType::kRadial:
443 codeSnippetID =
444 gradData.fNumStops <= 4 ? BuiltInCodeSnippetID::kRadialGradientShader4
445 : gradData.fNumStops <= 8 ? BuiltInCodeSnippetID::kRadialGradientShader8
446 : gradData.fUseStorageBuffer
449 add_radial_gradient_uniform_data(dict, codeSnippetID, gradData, bufferOffset, gatherer);
450 break;
451 case SkShaderBase::GradientType::kSweep:
452 codeSnippetID =
453 gradData.fNumStops <= 4 ? BuiltInCodeSnippetID::kSweepGradientShader4
454 : gradData.fNumStops <= 8 ? BuiltInCodeSnippetID::kSweepGradientShader8
455 : gradData.fUseStorageBuffer
458 add_sweep_gradient_uniform_data(dict, codeSnippetID, gradData, bufferOffset, gatherer);
459 break;
460 case SkShaderBase::GradientType::kConical:
461 codeSnippetID =
462 gradData.fNumStops <= 4 ? BuiltInCodeSnippetID::kConicalGradientShader4
463 : gradData.fNumStops <= 8 ? BuiltInCodeSnippetID::kConicalGradientShader8
464 : gradData.fUseStorageBuffer
467 add_conical_gradient_uniform_data(dict, codeSnippetID, gradData, bufferOffset, gatherer);
468 break;
470 default:
471 SkDEBUGFAIL("Expected a gradient shader, but it wasn't one.");
472 break;
473 }
474
475 builder->addBlock(codeSnippetID);
476}
#define SkDEBUGFAIL(message)
Definition: SkAssert.h:118
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkTileMode
Definition: SkTileMode.h:13
static constexpr skcms_TransferFunction kLinear
Definition: SkColorSpace.h:51
static int write_color_and_offset_bufdata(int numStops, const SkPMColor4f *colors, const float *offsets, const SkGradientBaseShader *shader, PipelineDataGatherer *gatherer)
Definition: KeyHelpers.cpp:313

The documentation for this struct was generated from the following files: