| Flutter Impeller |

content_context.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "impeller/entity/contents/content_context.h"
6
7 #include <memory>
8
9 #include "impeller/base/strings.h"
10 #include "impeller/core/formats.h"
11 #include "impeller/entity/contents/framebuffer_blend_contents.h"
12 #include "impeller/entity/entity.h"
13 #include "impeller/entity/render_target_cache.h"
14 #include "impeller/renderer/command_buffer.h"
15 #include "impeller/renderer/pipeline_descriptor.h"
16 #include "impeller/renderer/pipeline_library.h"
17 #include "impeller/renderer/render_target.h"
18 #include "impeller/tessellator/tessellator.h"
19 #include "impeller/typographer/typographer_context.h"
20
21 namespace impeller {
22
23 void ContentContextOptions::ApplyToPipelineDescriptor(
24 PipelineDescriptor& desc) const {
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 }
155
156 template <typename PipelineT>
157 static std::unique_ptr<PipelineT> CreateDefaultPipeline(
158 const Context& context) {
159 auto desc = PipelineT::Builder::MakeDefaultPipelineDescriptor(context);
160 if (!desc.has_value()) {
161 return nullptr;
162 }
163 // Apply default ContentContextOptions to the descriptor.
164 const auto default_color_format =
165 context.GetCapabilities()->GetDefaultColorFormat();
166 ContentContextOptions{.sample_count = SampleCount::kCount4,
167 .primitive_type = PrimitiveType::kTriangleStrip,
168 .color_attachment_pixel_format = default_color_format}
169 .ApplyToPipelineDescriptor(*desc);
170 return std::make_unique<PipelineT>(context, desc);
171 }
172
173 ContentContext::ContentContext(
174 std::shared_ptr<Context> context,
175 std::shared_ptr<TypographerContext> typographer_context,
176 std::shared_ptr<RenderTargetAllocator> render_target_allocator)
177 : context_(std::move(context)),
178 lazy_glyph_atlas_(
179 std::make_shared<LazyGlyphAtlas>(std::move(typographer_context))),
180 tessellator_(std::make_shared<Tessellator>()),
181 #if IMPELLER_ENABLE_3D
182 scene_context_(std::make_shared<scene::SceneContext>(context_)),
183 #endif // IMPELLER_ENABLE_3D
184 render_target_cache_(render_target_allocator == nullptr
185 ? std::make_shared<RenderTargetCache>(
186 context_->GetResourceAllocator())
187 : std::move(render_target_allocator)) {
188 if (!context_ || !context_->IsValid()) {
189 return;
190 }
191 auto options = ContentContextOptions{
192 .sample_count = SampleCount::kCount4,
193 .color_attachment_pixel_format =
194 context_->GetCapabilities()->GetDefaultColorFormat()};
195 auto options_trianglestrip = ContentContextOptions{
196 .sample_count = SampleCount::kCount4,
197 .primitive_type = PrimitiveType::kTriangleStrip,
198 .color_attachment_pixel_format =
199 context_->GetCapabilities()->GetDefaultColorFormat()};
200 const auto supports_decal = static_cast<Scalar>(
201 context_->GetCapabilities()->SupportsDecalSamplerAddressMode());
202
203 #ifdef IMPELLER_DEBUG
204 checkerboard_pipelines_.CreateDefault(*context_, options);
205 #endif // IMPELLER_DEBUG
206
207 solid_fill_pipelines_.CreateDefault(*context_, options);
208
209 if (context_->GetCapabilities()->SupportsSSBO()) {
210 linear_gradient_ssbo_fill_pipelines_.CreateDefault(*context_, options);
211 radial_gradient_ssbo_fill_pipelines_.CreateDefault(*context_, options);
212 conical_gradient_ssbo_fill_pipelines_.CreateDefault(*context_, options);
213 sweep_gradient_ssbo_fill_pipelines_.CreateDefault(*context_, options);
214 } else {
215 linear_gradient_fill_pipelines_.CreateDefault(*context_, options);
216 radial_gradient_fill_pipelines_.CreateDefault(*context_, options);
217 conical_gradient_fill_pipelines_.CreateDefault(*context_, options);
218 sweep_gradient_fill_pipelines_.CreateDefault(*context_, options);
219 }
220
221 if (context_->GetCapabilities()->SupportsFramebufferFetch()) {
222 framebuffer_blend_color_pipelines_.CreateDefault(
223 *context_, options_trianglestrip,
224 {static_cast<Scalar>(BlendSelectValues::kColor), supports_decal},
225 UseSubpassInput::kYes);
226 framebuffer_blend_colorburn_pipelines_.CreateDefault(
227 *context_, options_trianglestrip,
228 {static_cast<Scalar>(BlendSelectValues::kColorBurn), supports_decal},
229 UseSubpassInput::kYes);
230 framebuffer_blend_colordodge_pipelines_.CreateDefault(
231 *context_, options_trianglestrip,
232 {static_cast<Scalar>(BlendSelectValues::kColorDodge), supports_decal},
233 UseSubpassInput::kYes);
234 framebuffer_blend_darken_pipelines_.CreateDefault(
235 *context_, options_trianglestrip,
236 {static_cast<Scalar>(BlendSelectValues::kDarken), supports_decal},
237 UseSubpassInput::kYes);
238 framebuffer_blend_difference_pipelines_.CreateDefault(
239 *context_, options_trianglestrip,
240 {static_cast<Scalar>(BlendSelectValues::kDifference), supports_decal},
241 UseSubpassInput::kYes);
242 framebuffer_blend_exclusion_pipelines_.CreateDefault(
243 *context_, options_trianglestrip,
244 {static_cast<Scalar>(BlendSelectValues::kExclusion), supports_decal},
245 UseSubpassInput::kYes);
246 framebuffer_blend_hardlight_pipelines_.CreateDefault(
247 *context_, options_trianglestrip,
248 {static_cast<Scalar>(BlendSelectValues::kHardLight), supports_decal},
249 UseSubpassInput::kYes);
250 framebuffer_blend_hue_pipelines_.CreateDefault(
251 *context_, options_trianglestrip,
252 {static_cast<Scalar>(BlendSelectValues::kHue), supports_decal},
253 UseSubpassInput::kYes);
254 framebuffer_blend_lighten_pipelines_.CreateDefault(
255 *context_, options_trianglestrip,
256 {static_cast<Scalar>(BlendSelectValues::kLighten), supports_decal},
257 UseSubpassInput::kYes);
258 framebuffer_blend_luminosity_pipelines_.CreateDefault(
259 *context_, options_trianglestrip,
260 {static_cast<Scalar>(BlendSelectValues::kLuminosity), supports_decal},
261 UseSubpassInput::kYes);
262 framebuffer_blend_multiply_pipelines_.CreateDefault(
263 *context_, options_trianglestrip,
264 {static_cast<Scalar>(BlendSelectValues::kMultiply), supports_decal},
265 UseSubpassInput::kYes);
266 framebuffer_blend_overlay_pipelines_.CreateDefault(
267 *context_, options_trianglestrip,
268 {static_cast<Scalar>(BlendSelectValues::kOverlay), supports_decal},
269 UseSubpassInput::kYes);
270 framebuffer_blend_saturation_pipelines_.CreateDefault(
271 *context_, options_trianglestrip,
272 {static_cast<Scalar>(BlendSelectValues::kSaturation), supports_decal},
273 UseSubpassInput::kYes);
274 framebuffer_blend_screen_pipelines_.CreateDefault(
275 *context_, options_trianglestrip,
276 {static_cast<Scalar>(BlendSelectValues::kScreen), supports_decal},
277 UseSubpassInput::kYes);
278 framebuffer_blend_softlight_pipelines_.CreateDefault(
279 *context_, options_trianglestrip,
280 {static_cast<Scalar>(BlendSelectValues::kSoftLight), supports_decal},
281 UseSubpassInput::kYes);
282 }
283
284 blend_color_pipelines_.CreateDefault(
285 *context_, options_trianglestrip,
286 {static_cast<Scalar>(BlendSelectValues::kColor), supports_decal});
287 blend_colorburn_pipelines_.CreateDefault(
288 *context_, options_trianglestrip,
289 {static_cast<Scalar>(BlendSelectValues::kColorBurn), supports_decal});
290 blend_colordodge_pipelines_.CreateDefault(
291 *context_, options_trianglestrip,
292 {static_cast<Scalar>(BlendSelectValues::kColorDodge), supports_decal});
293 blend_darken_pipelines_.CreateDefault(
294 *context_, options_trianglestrip,
295 {static_cast<Scalar>(BlendSelectValues::kDarken), supports_decal});
296 blend_difference_pipelines_.CreateDefault(
297 *context_, options_trianglestrip,
298 {static_cast<Scalar>(BlendSelectValues::kDifference), supports_decal});
299 blend_exclusion_pipelines_.CreateDefault(
300 *context_, options_trianglestrip,
301 {static_cast<Scalar>(BlendSelectValues::kExclusion), supports_decal});
302 blend_hardlight_pipelines_.CreateDefault(
303 *context_, options_trianglestrip,
304 {static_cast<Scalar>(BlendSelectValues::kHardLight), supports_decal});
305 blend_hue_pipelines_.CreateDefault(
306 *context_, options_trianglestrip,
307 {static_cast<Scalar>(BlendSelectValues::kHue), supports_decal});
308 blend_lighten_pipelines_.CreateDefault(
309 *context_, options_trianglestrip,
310 {static_cast<Scalar>(BlendSelectValues::kLighten), supports_decal});
311 blend_luminosity_pipelines_.CreateDefault(
312 *context_, options_trianglestrip,
313 {static_cast<Scalar>(BlendSelectValues::kLuminosity), supports_decal});
314 blend_multiply_pipelines_.CreateDefault(
315 *context_, options_trianglestrip,
316 {static_cast<Scalar>(BlendSelectValues::kMultiply), supports_decal});
317 blend_overlay_pipelines_.CreateDefault(
318 *context_, options_trianglestrip,
319 {static_cast<Scalar>(BlendSelectValues::kOverlay), supports_decal});
320 blend_saturation_pipelines_.CreateDefault(
321 *context_, options_trianglestrip,
322 {static_cast<Scalar>(BlendSelectValues::kSaturation), supports_decal});
323 blend_screen_pipelines_.CreateDefault(
324 *context_, options_trianglestrip,
325 {static_cast<Scalar>(BlendSelectValues::kScreen), supports_decal});
326 blend_softlight_pipelines_.CreateDefault(
327 *context_, options_trianglestrip,
328 {static_cast<Scalar>(BlendSelectValues::kSoftLight), supports_decal});
329
330 rrect_blur_pipelines_.CreateDefault(*context_, options_trianglestrip);
331 texture_blend_pipelines_.CreateDefault(*context_, options);
332 texture_pipelines_.CreateDefault(*context_, options);
333 position_uv_pipelines_.CreateDefault(*context_, options);
334 tiled_texture_pipelines_.CreateDefault(*context_, options);
335 gaussian_blur_noalpha_decal_pipelines_.CreateDefault(*context_,
336 options_trianglestrip);
337 gaussian_blur_noalpha_nodecal_pipelines_.CreateDefault(*context_,
338 options_trianglestrip);
339 kernel_decal_pipelines_.CreateDefault(*context_, options_trianglestrip);
340 kernel_nodecal_pipelines_.CreateDefault(*context_, options_trianglestrip);
341 border_mask_blur_pipelines_.CreateDefault(*context_, options_trianglestrip);
342 morphology_filter_pipelines_.CreateDefault(*context_, options_trianglestrip,
343 {supports_decal});
344 color_matrix_color_filter_pipelines_.CreateDefault(*context_,
345 options_trianglestrip);
346 linear_to_srgb_filter_pipelines_.CreateDefault(*context_,
347 options_trianglestrip);
348 srgb_to_linear_filter_pipelines_.CreateDefault(*context_,
349 options_trianglestrip);
350 glyph_atlas_pipelines_.CreateDefault(*context_, options);
351 glyph_atlas_color_pipelines_.CreateDefault(*context_, options);
352 geometry_color_pipelines_.CreateDefault(*context_, options);
353 yuv_to_rgb_filter_pipelines_.CreateDefault(*context_, options_trianglestrip);
354 porter_duff_blend_pipelines_.CreateDefault(*context_, options_trianglestrip,
355 {supports_decal});
356 // GLES only shader that is unsupported on macOS.
357 #if defined(IMPELLER_ENABLE_OPENGLES) && !defined(FML_OS_MACOSX)
358 if (GetContext()->GetBackendType() == Context::BackendType::kOpenGLES) {
359 texture_external_pipelines_.CreateDefault(*context_, options);
360 }
361 if (GetContext()->GetBackendType() == Context::BackendType::kOpenGLES) {
362 tiled_texture_external_pipelines_.CreateDefault(*context_, options);
363 }
364 #endif // IMPELLER_ENABLE_OPENGLES
365 if (context_->GetCapabilities()->SupportsCompute()) {
366 auto pipeline_desc =
367 PointsComputeShaderPipeline::MakeDefaultPipelineDescriptor(*context_);
368 point_field_compute_pipelines_ =
369 context_->GetPipelineLibrary()->GetPipeline(pipeline_desc).Get();
370
371 auto uv_pipeline_desc =
372 UvComputeShaderPipeline::MakeDefaultPipelineDescriptor(*context_);
373 uv_compute_pipelines_ =
374 context_->GetPipelineLibrary()->GetPipeline(uv_pipeline_desc).Get();
375 }
376
377 /// Setup default clip pipeline.
378
379 auto clip_pipeline_descriptor =
380 ClipPipeline::Builder::MakeDefaultPipelineDescriptor(*context_);
381 if (!clip_pipeline_descriptor.has_value()) {
382 return;
383 }
384 ContentContextOptions{
385 .sample_count = SampleCount::kCount4,
386 .color_attachment_pixel_format =
387 context_->GetCapabilities()->GetDefaultColorFormat()}
388 .ApplyToPipelineDescriptor(*clip_pipeline_descriptor);
389 // Disable write to all color attachments.
390 auto clip_color_attachments =
391 clip_pipeline_descriptor->GetColorAttachmentDescriptors();
392 for (auto& color_attachment : clip_color_attachments) {
393 color_attachment.second.write_mask =
394 static_cast<uint64_t>(ColorWriteMask::kNone);
395 }
396 clip_pipeline_descriptor->SetColorAttachmentDescriptors(
397 std::move(clip_color_attachments));
398 clip_pipelines_.SetDefault(options, std::make_unique<ClipPipeline>(
399 *context_, clip_pipeline_descriptor));
400
401 is_valid_ = true;
402 }
403
404 ContentContext::~ContentContext() = default;
405
406 bool ContentContext::IsValid() const {
407 return is_valid_;
408 }
409
410 fml::StatusOr<RenderTarget> ContentContext::MakeSubpass(
411 const std::string& label,
412 ISize texture_size,
413 const SubpassCallback& subpass_callback,
414 bool msaa_enabled) const {
415 std::shared_ptr<Context> context = GetContext();
416 RenderTarget subpass_target;
417 if (context->GetCapabilities()->SupportsOffscreenMSAA() && msaa_enabled) {
418 subpass_target = RenderTarget::CreateOffscreenMSAA(
419 *context, *GetRenderTargetCache(), texture_size,
420 SPrintF("%s Offscreen", label.c_str()),
421 RenderTarget::kDefaultColorAttachmentConfigMSAA,
422 std::nullopt // stencil_attachment_config
423 );
424 } else {
425 subpass_target = RenderTarget::CreateOffscreen(
426 *context, *GetRenderTargetCache(), texture_size,
427 SPrintF("%s Offscreen", label.c_str()),
428 RenderTarget::kDefaultColorAttachmentConfig, //
429 std::nullopt // stencil_attachment_config
430 );
431 }
432 return MakeSubpass(label, subpass_target, subpass_callback);
433 }
434
435 fml::StatusOr<RenderTarget> ContentContext::MakeSubpass(
436 const std::string& label,
437 const RenderTarget& subpass_target,
438 const SubpassCallback& subpass_callback) const {
439 std::shared_ptr<Context> context = GetContext();
440
441 auto subpass_texture = subpass_target.GetRenderTargetTexture();
442 if (!subpass_texture) {
443 return fml::Status(fml::StatusCode::kUnknown, "");
444 }
445
446 auto sub_command_buffer = context->CreateCommandBuffer();
447 sub_command_buffer->SetLabel(SPrintF("%s CommandBuffer", label.c_str()));
448 if (!sub_command_buffer) {
449 return fml::Status(fml::StatusCode::kUnknown, "");
450 }
451
452 auto sub_renderpass = sub_command_buffer->CreateRenderPass(subpass_target);
453 if (!sub_renderpass) {
454 return fml::Status(fml::StatusCode::kUnknown, "");
455 }
456 sub_renderpass->SetLabel(SPrintF("%s RenderPass", label.c_str()));
457
458 if (!subpass_callback(*this, *sub_renderpass)) {
459 return fml::Status(fml::StatusCode::kUnknown, "");
460 }
461
462 if (!sub_command_buffer->EncodeAndSubmit(sub_renderpass)) {
463 return fml::Status(fml::StatusCode::kUnknown, "");
464 }
465
466 return subpass_target;
467 }
468
469 #if IMPELLER_ENABLE_3D
470 std::shared_ptr<scene::SceneContext> ContentContext::GetSceneContext() const {
471 return scene_context_;
472 }
473 #endif // IMPELLER_ENABLE_3D
474
475 std::shared_ptr<Tessellator> ContentContext::GetTessellator() const {
476 return tessellator_;
477 }
478
479 std::shared_ptr<Context> ContentContext::GetContext() const {
480 return context_;
481 }
482
483 const Capabilities& ContentContext::GetDeviceCapabilities() const {
484 return *context_->GetCapabilities();
485 }
486
487 void ContentContext::SetWireframe(bool wireframe) {
488 wireframe_ = wireframe;
489 }
490
491 } // namespace impeller
impeller::PipelineDescriptor
Definition: pipeline_descriptor.h:29
impeller::BlendSelectValues::kSaturation
@ kSaturation
impeller::ColorAttachmentDescriptor::src_color_blend_factor
BlendFactor src_color_blend_factor
Definition: formats.h:498
impeller::PipelineDescriptor::SetPolygonMode
void SetPolygonMode(PolygonMode mode)
Definition: pipeline_descriptor.cc:278
impeller::kColor
@ kColor
impeller::Entity::kLastPipelineBlendMode
static constexpr BlendMode kLastPipelineBlendMode
Definition: entity.h:23
impeller::BlendMode::kDestinationATop
@ kDestinationATop
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::BlendSelectValues::kColorBurn
@ kColorBurn
impeller::RenderTarget::kDefaultColorAttachmentConfig
static constexpr AttachmentConfig kDefaultColorAttachmentConfig
Definition: render_target.h:66
impeller::StencilAttachmentDescriptor::stencil_compare
CompareFunction stencil_compare
Definition: formats.h:593
impeller::ContentContext::ContentContext
ContentContext(std::shared_ptr< Context > context, std::shared_ptr< TypographerContext > typographer_context, std::shared_ptr< RenderTargetAllocator > render_target_allocator=nullptr)
Definition: content_context.cc:173
impeller::BlendSelectValues::kMultiply
@ kMultiply
impeller::PipelineDescriptor::SetStencilAttachmentDescriptors
PipelineDescriptor & SetStencilAttachmentDescriptors(std::optional< StencilAttachmentDescriptor > front_and_back)
Definition: pipeline_descriptor.cc:159
entity.h
impeller::PipelineDescriptor::SetColorAttachmentDescriptor
PipelineDescriptor & SetColorAttachmentDescriptor(size_t index, ColorAttachmentDescriptor desc)
Definition: pipeline_descriptor.cc:112
impeller::Tessellator
A utility that generates triangles of the specified fill type given a polyline. This happens on the C...
Definition: tessellator.h:39
impeller::BlendFactor::kOneMinusSourceAlpha
@ kOneMinusSourceAlpha
impeller::Context::GetCapabilities
virtual const std::shared_ptr< const Capabilities > & GetCapabilities() const =0
Get the capabilities of Impeller context. All optionally supported feature of the platform,...
impeller::PipelineDescriptor::GetColorAttachmentDescriptor
const ColorAttachmentDescriptor * GetColorAttachmentDescriptor(size_t index) const
Definition: pipeline_descriptor.cc:126
impeller::BlendMode::kSource
@ kSource
impeller::PipelineDescriptor::SetPrimitiveType
void SetPrimitiveType(PrimitiveType type)
Definition: pipeline_descriptor.cc:270
impeller::ContentContext::MakeSubpass
fml::StatusOr< RenderTarget > MakeSubpass(const std::string &label, ISize texture_size, const SubpassCallback &subpass_callback, bool msaa_enabled=true) const
Creates a new texture of size texture_size and calls subpass_callback with a RenderPass for drawing t...
Definition: content_context.cc:410
impeller::BlendMode::kDestination
@ kDestination
impeller::RenderTarget::kDefaultColorAttachmentConfigMSAA
static constexpr AttachmentConfigMSAA kDefaultColorAttachmentConfigMSAA
Definition: render_target.h:72
formats.h
impeller::ColorAttachmentDescriptor::alpha_blend_op
BlendOperation alpha_blend_op
Definition: formats.h:503
impeller::BlendMode::kDestinationOver
@ kDestinationOver
impeller::BlendMode::kPlus
@ kPlus
impeller::BlendSelectValues::kSoftLight
@ kSoftLight
impeller::ContentContextOptions::blend_mode
BlendMode blend_mode
Definition: content_context.h:278
typographer_context.h
impeller::BlendFactor::kDestinationAlpha
@ kDestinationAlpha
impeller::BlendSelectValues::kDifference
@ kDifference
impeller::ContentContextOptions::ApplyToPipelineDescriptor
void ApplyToPipelineDescriptor(PipelineDescriptor &desc) const
Definition: content_context.cc:23
framebuffer_blend_contents.h
impeller::BlendMode::kModulate
@ kModulate
impeller::PolygonMode::kFill
@ kFill
impeller::ContentContextOptions::wireframe
bool wireframe
Definition: content_context.h:284
impeller::BlendFactor::kSourceColor
@ kSourceColor
impeller::BlendMode::kSourceOut
@ kSourceOut
tessellator.h
impeller::BlendFactor::kDestinationColor
@ kDestinationColor
impeller::ContentContextOptions::stencil_compare
CompareFunction stencil_compare
Definition: content_context.h:279
impeller::BlendSelectValues::kDarken
@ kDarken
impeller::BlendSelectValues::kExclusion
@ kExclusion
impeller::BlendFactor::kZero
@ kZero
impeller::Capabilities
Definition: capabilities.h:15
impeller::TSize< int64_t >
impeller::PrimitiveType::kTriangleStrip
@ kTriangleStrip
impeller::ComputePipelineBuilder::MakeDefaultPipelineDescriptor
static std::optional< ComputePipelineDescriptor > MakeDefaultPipelineDescriptor(const Context &context)
Create a default pipeline descriptor using the combination reflected shader information....
Definition: compute_pipeline_builder.h:40
impeller::ContentContextOptions::color_attachment_pixel_format
PixelFormat color_attachment_pixel_format
Definition: content_context.h:282
impeller::ContentContext::~ContentContext
~ContentContext()
impeller::RenderTarget::GetRenderTargetTexture
std::shared_ptr< Texture > GetRenderTargetTexture() const
Definition: render_target.cc:155
impeller::BlendOperation::kReverseSubtract
@ kReverseSubtract
impeller::Context::BackendType::kOpenGLES
@ kOpenGLES
impeller::SPrintF
std::string SPrintF(const char *format,...)
Definition: strings.cc:12
impeller::BlendMode::kClear
@ kClear
impeller::ContentContext::GetContext
std::shared_ptr< Context > GetContext() const
Definition: content_context.cc:479
impeller::BlendOperation::kAdd
@ kAdd
impeller::ColorWriteMask::kNone
@ kNone
impeller::ContentContext::GetRenderTargetCache
std::shared_ptr< RenderTargetAllocator > GetRenderTargetCache() const
Definition: content_context.h:728
impeller::ColorAttachmentDescriptor::format
PixelFormat format
Definition: formats.h:495
impeller::StencilAttachmentDescriptor::depth_stencil_pass
StencilOperation depth_stencil_pass
Definition: formats.h:606
impeller::RenderTarget
Definition: render_target.h:49
impeller::ContentContextOptions::has_stencil_attachment
bool has_stencil_attachment
Definition: content_context.h:283
impeller::BlendFactor::kOne
@ kOne
impeller::ContentContextOptions::is_for_rrect_blur_clear
bool is_for_rrect_blur_clear
Definition: content_context.h:285
strings.h
impeller::ContentContext::GetTessellator
std::shared_ptr< Tessellator > GetTessellator() const
Definition: content_context.cc:475
impeller::ContentContextOptions::primitive_type
PrimitiveType primitive_type
Definition: content_context.h:281
pipeline_library.h
impeller::ContentContext::SubpassCallback
std::function< bool(const ContentContext &, RenderPass &)> SubpassCallback
Definition: content_context.h:708
impeller::PipelineDescriptor::SetSampleCount
PipelineDescriptor & SetSampleCount(SampleCount samples)
Definition: pipeline_descriptor.cc:78
impeller::ColorAttachmentDescriptor::src_alpha_blend_factor
BlendFactor src_alpha_blend_factor
Definition: formats.h:502
impeller::RenderTarget::CreateOffscreen
static RenderTarget CreateOffscreen(const Context &context, RenderTargetAllocator &allocator, ISize size, const std::string &label="Offscreen", AttachmentConfig color_attachment_config=kDefaultColorAttachmentConfig, std::optional< AttachmentConfig > stencil_attachment_config=kDefaultStencilAttachmentConfig)
Definition: render_target.cc:223
impeller::BlendMode::kDestinationIn
@ kDestinationIn
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:67
command_buffer.h
impeller::ColorAttachmentDescriptor::dst_color_blend_factor
BlendFactor dst_color_blend_factor
Definition: formats.h:500
content_context.h
impeller::BlendMode::kDestinationOut
@ kDestinationOut
impeller::PipelineDescriptor::GetFrontStencilAttachmentDescriptor
std::optional< StencilAttachmentDescriptor > GetFrontStencilAttachmentDescriptor() const
Definition: pipeline_descriptor.cc:204
impeller::ColorAttachmentDescriptor::dst_alpha_blend_factor
BlendFactor dst_alpha_blend_factor
Definition: formats.h:504
impeller::ContentContext::GetDeviceCapabilities
const Capabilities & GetDeviceCapabilities() const
Definition: content_context.cc:483
impeller::Context
To do anything rendering related with Impeller, you need a context.
Definition: context.h:47
std
Definition: comparable.h:95
impeller::BlendSelectValues::kHardLight
@ kHardLight
impeller::ContentContextOptions::sample_count
SampleCount sample_count
Definition: content_context.h:277
impeller::BlendSelectValues::kScreen
@ kScreen
impeller::RenderTargetCache
An implementation of the [RenderTargetAllocator] that caches all allocated texture data for one frame...
Definition: render_target_cache.h:16
impeller::StencilAttachmentDescriptor
Definition: formats.h:587
impeller::BlendSelectValues::kLighten
@ kLighten
impeller::BlendMode::kSourceIn
@ kSourceIn
impeller::ContentContext::SetWireframe
void SetWireframe(bool wireframe)
Definition: content_context.cc:487
impeller::BlendSelectValues::kHue
@ kHue
impeller::SampleCount::kCount4
@ kCount4
impeller::PolygonMode::kLine
@ kLine
impeller::BlendSelectValues::kLuminosity
@ kLuminosity
impeller::UseSubpassInput::kYes
@ kYes
pipeline_descriptor.h
impeller::ColorAttachmentDescriptor::color_blend_op
BlendOperation color_blend_op
Definition: formats.h:499
render_target.h
impeller::BlendMode::kXor
@ kXor
impeller::PipelineBuilder::MakeDefaultPipelineDescriptor
static std::optional< PipelineDescriptor > MakeDefaultPipelineDescriptor(const Context &context, const std::vector< Scalar > &constants={})
Create a default pipeline descriptor using the combination reflected shader information....
Definition: pipeline_builder.h:51
render_target_cache.h
impeller::BlendFactor::kSourceAlpha
@ kSourceAlpha
impeller::ContentContextOptions
Definition: content_context.h:276
impeller::LazyGlyphAtlas
Definition: lazy_glyph_atlas.h:18
impeller::PipelineDescriptor::ClearStencilAttachments
void ClearStencilAttachments()
Definition: pipeline_descriptor.cc:172
impeller
Definition: aiks_context.cc:10
impeller::ContentContext::IsValid
bool IsValid() const
Definition: content_context.cc:406
impeller::BlendMode::kSourceATop
@ kSourceATop
impeller::ColorAttachmentDescriptor::blending_enabled
bool blending_enabled
Definition: formats.h:496
impeller::RenderTarget::CreateOffscreenMSAA
static RenderTarget CreateOffscreenMSAA(const Context &context, RenderTargetAllocator &allocator, ISize size, const std::string &label="Offscreen MSAA", AttachmentConfigMSAA color_attachment_config=kDefaultColorAttachmentConfigMSAA, std::optional< AttachmentConfig > stencil_attachment_config=kDefaultStencilAttachmentConfig)
Definition: render_target.cc:265
impeller::BlendSelectValues::kColorDodge
@ kColorDodge
impeller::CreateDefaultPipeline
static std::unique_ptr< PipelineT > CreateDefaultPipeline(const Context &context)
Definition: content_context.cc:157
impeller::BlendMode::kSourceOver
@ kSourceOver
impeller::BlendSelectValues::kOverlay
@ kOverlay
impeller::BlendFactor::kOneMinusDestinationAlpha
@ kOneMinusDestinationAlpha
impeller::ContentContextOptions::stencil_operation
StencilOperation stencil_operation
Definition: content_context.h:280
impeller::ColorAttachmentDescriptor
Describe the color attachment that will be used with this pipeline.
Definition: formats.h:494