| Flutter Impeller |

Classes | Public Member Functions | Public Attributes | List of all members
impeller::ContentContextOptions Struct Reference

`#include <content_context.h>`

## Classes
struct | Equal
struct | Hash

## Public Member Functions
void | ApplyToPipelineDescriptor (PipelineDescriptor &desc) const

## Public Attributes
SampleCount | sample_count = SampleCount::kCount1
BlendMode | blend_mode = BlendMode::kSourceOver
CompareFunction | stencil_compare = CompareFunction::kEqual
StencilOperation | stencil_operation = StencilOperation::kKeep
PrimitiveType | primitive_type = PrimitiveType::kTriangle
PixelFormat | color_attachment_pixel_format = PixelFormat::kUnknown
bool | has_stencil_attachment = true
bool | wireframe = false
bool | is_for_rrect_blur_clear = false

## Detailed Description

Pipeline state configuration.

Each unique combination of these options requires a different pipeline state object to be built. This struct is used as a key for the per-pipeline variant cache.

When adding fields to this key, reliant features should take care to limit the combinatorical explosion of variations. A sufficiently complicated Flutter application may easily require building hundreds of PSOs in total, but they shouldn't require e.g. 10s of thousands.

Definition at line 302 of file content_context.h.

## Member Function Documentation

## ◆ ApplyToPipelineDescriptor()

void impeller::ContentContextOptions::ApplyToPipelineDescriptor | ( | PipelineDescriptor & | desc | ) | const

Definition at line 23 of file content_context.cc.

24 {
25 auto pipeline_blend = blend_mode;
26 if (blend_mode > Entity::kLastPipelineBlendMode) {
27 VALIDATION_LOG << "Cannot use blend mode " << static_cast<int>(blend_mode)
28 << " as a pipeline blend.";
29 pipeline_blend = BlendMode::kSourceOver;
30 }
31
32 desc.SetSampleCount(sample_count);
33
34 ColorAttachmentDescriptor color0 = *desc.GetColorAttachmentDescriptor(0u);
35 color0.format = color_attachment_pixel_format;
36 color0.alpha_blend_op = BlendOperation::kAdd;
37 color0.color_blend_op = BlendOperation::kAdd;
38
39 switch (pipeline_blend) {
40 case BlendMode::kClear:
41 if (is_for_rrect_blur_clear) {
42 color0.alpha_blend_op = BlendOperation::kReverseSubtract;
43 color0.color_blend_op = BlendOperation::kReverseSubtract;
44 color0.dst_alpha_blend_factor = BlendFactor::kOne;
45 color0.dst_color_blend_factor = BlendFactor::kOne;
46 color0.src_alpha_blend_factor = BlendFactor::kDestinationColor;
47 color0.src_color_blend_factor = BlendFactor::kDestinationColor;
48 } else {
49 color0.dst_alpha_blend_factor = BlendFactor::kZero;
50 color0.dst_color_blend_factor = BlendFactor::kZero;
51 color0.src_alpha_blend_factor = BlendFactor::kZero;
52 color0.src_color_blend_factor = BlendFactor::kZero;
53 }
54 break;
55 case BlendMode::kSource:
56 color0.blending_enabled = false;
57 color0.dst_alpha_blend_factor = BlendFactor::kZero;
58 color0.dst_color_blend_factor = BlendFactor::kZero;
59 color0.src_alpha_blend_factor = BlendFactor::kOne;
60 color0.src_color_blend_factor = BlendFactor::kOne;
61 break;
62 case BlendMode::kDestination:
63 color0.dst_alpha_blend_factor = BlendFactor::kOne;
64 color0.dst_color_blend_factor = BlendFactor::kOne;
65 color0.src_alpha_blend_factor = BlendFactor::kZero;
66 color0.src_color_blend_factor = BlendFactor::kZero;
67 break;
68 case BlendMode::kSourceOver:
69 color0.dst_alpha_blend_factor = BlendFactor::kOneMinusSourceAlpha;
70 color0.dst_color_blend_factor = BlendFactor::kOneMinusSourceAlpha;
71 color0.src_alpha_blend_factor = BlendFactor::kOne;
72 color0.src_color_blend_factor = BlendFactor::kOne;
73 break;
74 case BlendMode::kDestinationOver:
75 color0.dst_alpha_blend_factor = BlendFactor::kOne;
76 color0.dst_color_blend_factor = BlendFactor::kOne;
77 color0.src_alpha_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
78 color0.src_color_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
79 break;
80 case BlendMode::kSourceIn:
81 color0.dst_alpha_blend_factor = BlendFactor::kZero;
82 color0.dst_color_blend_factor = BlendFactor::kZero;
83 color0.src_alpha_blend_factor = BlendFactor::kDestinationAlpha;
84 color0.src_color_blend_factor = BlendFactor::kDestinationAlpha;
85 break;
86 case BlendMode::kDestinationIn:
87 color0.dst_alpha_blend_factor = BlendFactor::kSourceAlpha;
88 color0.dst_color_blend_factor = BlendFactor::kSourceAlpha;
89 color0.src_alpha_blend_factor = BlendFactor::kZero;
90 color0.src_color_blend_factor = BlendFactor::kZero;
91 break;
92 case BlendMode::kSourceOut:
93 color0.dst_alpha_blend_factor = BlendFactor::kZero;
94 color0.dst_color_blend_factor = BlendFactor::kZero;
95 color0.src_alpha_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
96 color0.src_color_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
97 break;
98 case BlendMode::kDestinationOut:
99 color0.dst_alpha_blend_factor = BlendFactor::kOneMinusSourceAlpha;
100 color0.dst_color_blend_factor = BlendFactor::kOneMinusSourceAlpha;
101 color0.src_alpha_blend_factor = BlendFactor::kZero;
102 color0.src_color_blend_factor = BlendFactor::kZero;
103 break;
104 case BlendMode::kSourceATop:
105 color0.dst_alpha_blend_factor = BlendFactor::kOneMinusSourceAlpha;
106 color0.dst_color_blend_factor = BlendFactor::kOneMinusSourceAlpha;
107 color0.src_alpha_blend_factor = BlendFactor::kDestinationAlpha;
108 color0.src_color_blend_factor = BlendFactor::kDestinationAlpha;
109 break;
110 case BlendMode::kDestinationATop:
111 color0.dst_alpha_blend_factor = BlendFactor::kSourceAlpha;
112 color0.dst_color_blend_factor = BlendFactor::kSourceAlpha;
113 color0.src_alpha_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
114 color0.src_color_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
115 break;
116 case BlendMode::kXor:
117 color0.dst_alpha_blend_factor = BlendFactor::kOneMinusSourceAlpha;
118 color0.dst_color_blend_factor = BlendFactor::kOneMinusSourceAlpha;
119 color0.src_alpha_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
120 color0.src_color_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
121 break;
122 case BlendMode::kPlus:
123 color0.dst_alpha_blend_factor = BlendFactor::kOne;
124 color0.dst_color_blend_factor = BlendFactor::kOne;
125 color0.src_alpha_blend_factor = BlendFactor::kOne;
126 color0.src_color_blend_factor = BlendFactor::kOne;
127 break;
128 case BlendMode::kModulate:
129 color0.dst_alpha_blend_factor = BlendFactor::kSourceAlpha;
130 color0.dst_color_blend_factor = BlendFactor::kSourceColor;
131 color0.src_alpha_blend_factor = BlendFactor::kZero;
132 color0.src_color_blend_factor = BlendFactor::kZero;
133 break;
134 default:
135 FML_UNREACHABLE();
136 }
137 desc.SetColorAttachmentDescriptor(0u, color0);
138
139 if (!has_stencil_attachment) {
140 desc.ClearStencilAttachments();
141 }
142
143 auto maybe_stencil = desc.GetFrontStencilAttachmentDescriptor();
144 if (maybe_stencil.has_value()) {
145 StencilAttachmentDescriptor stencil = maybe_stencil.value();
146 stencil.stencil_compare = stencil_compare;
147 stencil.depth_stencil_pass = stencil_operation;
148 desc.SetStencilAttachmentDescriptors(stencil);
149 }
150
151 desc.SetPrimitiveType(primitive_type);
152
153 desc.SetPolygonMode(wireframe ? PolygonMode::kLine : PolygonMode::kFill);
154 }

References impeller::ColorAttachmentDescriptor::alpha_blend_op, blend_mode, impeller::ColorAttachmentDescriptor::blending_enabled, impeller::PipelineDescriptor::ClearStencilAttachments(), color_attachment_pixel_format, impeller::ColorAttachmentDescriptor::color_blend_op, impeller::StencilAttachmentDescriptor::depth_stencil_pass, impeller::ColorAttachmentDescriptor::dst_alpha_blend_factor, impeller::ColorAttachmentDescriptor::dst_color_blend_factor, impeller::ColorAttachmentDescriptor::format, impeller::PipelineDescriptor::GetColorAttachmentDescriptor(), impeller::PipelineDescriptor::GetFrontStencilAttachmentDescriptor(), has_stencil_attachment, is_for_rrect_blur_clear, impeller::kAdd, impeller::kClear, impeller::kDestination, impeller::kDestinationAlpha, impeller::kDestinationATop, impeller::kDestinationColor, impeller::kDestinationIn, impeller::kDestinationOut, impeller::kDestinationOver, impeller::kFill, impeller::Entity::kLastPipelineBlendMode, impeller::kLine, impeller::kModulate, impeller::kOne, impeller::kOneMinusDestinationAlpha, impeller::kOneMinusSourceAlpha, impeller::kPlus, impeller::kReverseSubtract, impeller::kSource, impeller::kSourceAlpha, impeller::kSourceATop, impeller::kSourceColor, impeller::kSourceIn, impeller::kSourceOut, impeller::kSourceOver, impeller::kXor, impeller::kZero, primitive_type, sample_count, impeller::PipelineDescriptor::SetColorAttachmentDescriptor(), impeller::PipelineDescriptor::SetPolygonMode(), impeller::PipelineDescriptor::SetPrimitiveType(), impeller::PipelineDescriptor::SetSampleCount(), impeller::PipelineDescriptor::SetStencilAttachmentDescriptors(), impeller::ColorAttachmentDescriptor::src_alpha_blend_factor, impeller::ColorAttachmentDescriptor::src_color_blend_factor, stencil_compare, impeller::StencilAttachmentDescriptor::stencil_compare, stencil_operation, VALIDATION_LOG, and wireframe.

## Member Data Documentation

## ◆ blend_mode

BlendMode impeller::ContentContextOptions::blend_mode = BlendMode::kSourceOver

Definition at line 304 of file content_context.h.

Referenced by ApplyToPipelineDescriptor(), impeller::ContentContextOptions::Hash::operator()(), impeller::ContentContextOptions::Equal::operator()(), impeller::OptionsFromPassAndEntity(), and impeller::testing::TEST_P().

## ◆ color_attachment_pixel_format

PixelFormat impeller::ContentContextOptions::color_attachment_pixel_format = PixelFormat::kUnknown

Definition at line 308 of file content_context.h.

Referenced by ApplyToPipelineDescriptor(), impeller::ContentContextOptions::Hash::operator()(), impeller::ContentContextOptions::Equal::operator()(), impeller::OptionsFromPass(), and impeller::testing::TEST_P().

## ◆ has_stencil_attachment

bool impeller::ContentContextOptions::has_stencil_attachment = true

Definition at line 309 of file content_context.h.

Referenced by ApplyToPipelineDescriptor(), impeller::ContentContextOptions::Hash::operator()(), impeller::ContentContextOptions::Equal::operator()(), impeller::OptionsFromPass(), and impeller::testing::TEST_P().

## ◆ is_for_rrect_blur_clear

bool impeller::ContentContextOptions::is_for_rrect_blur_clear = false

Definition at line 311 of file content_context.h.

Referenced by ApplyToPipelineDescriptor(), impeller::ContentContextOptions::Hash::operator()(), impeller::ContentContextOptions::Equal::operator()(), and impeller::SolidRRectBlurContents::Render().

## ◆ primitive_type

PrimitiveType impeller::ContentContextOptions::primitive_type = PrimitiveType::kTriangle

Definition at line 307 of file content_context.h.

Referenced by ApplyToPipelineDescriptor(), impeller::ContentContextOptions::Hash::operator()(), impeller::ContentContextOptions::Equal::operator()(), impeller::SolidRRectBlurContents::Render(), and impeller::testing::TEST_P().

## ◆ sample_count

SampleCount impeller::ContentContextOptions::sample_count = SampleCount::kCount1

Definition at line 303 of file content_context.h.

Referenced by ApplyToPipelineDescriptor(), impeller::ContentContext::ContentContext(), impeller::CreateDefaultPipeline(), impeller::ContentContextOptions::Hash::operator()(), impeller::ContentContextOptions::Equal::operator()(), impeller::OptionsFromPass(), and impeller::testing::TEST_P().

## ◆ stencil_compare

CompareFunction impeller::ContentContextOptions::stencil_compare = CompareFunction::kEqual

Definition at line 305 of file content_context.h.

Referenced by ApplyToPipelineDescriptor(), impeller::ContentContextOptions::Hash::operator()(), impeller::ContentContextOptions::Equal::operator()(), and impeller::testing::TEST_P().

## ◆ stencil_operation

StencilOperation impeller::ContentContextOptions::stencil_operation = StencilOperation::kKeep

Definition at line 306 of file content_context.h.

Referenced by ApplyToPipelineDescriptor(), impeller::ContentContextOptions::Hash::operator()(), impeller::ContentContextOptions::Equal::operator()(), and impeller::testing::TEST_P().

## ◆ wireframe

bool impeller::ContentContextOptions::wireframe = false

Definition at line 310 of file content_context.h.

Referenced by ApplyToPipelineDescriptor(), impeller::ContentContextOptions::Hash::operator()(), and impeller::ContentContextOptions::Equal::operator()().

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

- impeller/entity/contents/content_context.h
- impeller/entity/contents/content_context.cc

impeller::Entity::kLastPipelineBlendMode
static constexpr BlendMode kLastPipelineBlendMode
Definition: entity.h:23
impeller::BlendFactor::kOneMinusSourceAlpha
@ kOneMinusSourceAlpha
impeller::BlendMode::kSourceIn
@ kSourceIn
impeller::ContentContextOptions::blend_mode
BlendMode blend_mode
Definition: content_context.h:304
impeller::BlendFactor::kDestinationAlpha
@ kDestinationAlpha
impeller::BlendMode::kDestinationIn
@ kDestinationIn
impeller::PolygonMode::kFill
@ kFill
impeller::ContentContextOptions::wireframe
bool wireframe
Definition: content_context.h:310
impeller::BlendFactor::kSourceColor
@ kSourceColor
impeller::BlendMode::kXor
@ kXor
impeller::BlendFactor::kDestinationColor
@ kDestinationColor
impeller::ContentContextOptions::stencil_compare
CompareFunction stencil_compare
Definition: content_context.h:305
impeller::BlendFactor::kZero
@ kZero
impeller::ContentContextOptions::color_attachment_pixel_format
PixelFormat color_attachment_pixel_format
Definition: content_context.h:308
impeller::BlendMode::kSourceOver
@ kSourceOver
impeller::BlendOperation::kReverseSubtract
@ kReverseSubtract
impeller::BlendMode::kPlus
@ kPlus
impeller::BlendMode::kDestination
@ kDestination
impeller::BlendOperation::kAdd
@ kAdd
impeller::BlendMode::kDestinationATop
@ kDestinationATop
impeller::ContentContextOptions::has_stencil_attachment
bool has_stencil_attachment
Definition: content_context.h:309
impeller::BlendFactor::kOne
@ kOne
impeller::ContentContextOptions::is_for_rrect_blur_clear
bool is_for_rrect_blur_clear
Definition: content_context.h:311
impeller::BlendMode::kDestinationOut
@ kDestinationOut
impeller::ContentContextOptions::primitive_type
PrimitiveType primitive_type
Definition: content_context.h:307
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:60
impeller::BlendMode::kDestinationOver
@ kDestinationOver
impeller::ContentContextOptions::sample_count
SampleCount sample_count
Definition: content_context.h:303
impeller::BlendMode::kClear
@ kClear
impeller::PolygonMode::kLine
@ kLine
impeller::BlendMode::kSourceATop
@ kSourceATop
impeller::BlendMode::kModulate
@ kModulate
impeller::BlendFactor::kSourceAlpha
@ kSourceAlpha
impeller::BlendMode::kSourceOut
@ kSourceOut
impeller::BlendMode::kSource
@ kSource
impeller::BlendFactor::kOneMinusDestinationAlpha
@ kOneMinusDestinationAlpha
impeller::ContentContextOptions::stencil_operation
StencilOperation stencil_operation
Definition: content_context.h:306