Flutter Impeller
impeller::ContentContext Class Reference

#include <content_context.h>

Inheritance diagram for impeller::ContentContext:
impeller::testing::FlushTestContentContext

Classes

struct  Pipelines
 

Public Types

using SubpassCallback = std::function< bool(const ContentContext &, RenderPass &)>
 

Public Member Functions

 ContentContext (std::shared_ptr< Context > context, std::shared_ptr< TypographerContext > typographer_context, std::shared_ptr< RenderTargetAllocator > render_target_allocator=nullptr)
 
 ~ContentContext ()
 
bool IsValid () const
 
TessellatorGetTessellator () const
 
PipelineRef GetBlendColorBurnPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendColorDodgePipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendColorPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendDarkenPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendDifferencePipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendExclusionPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendHardLightPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendHuePipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendLightenPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendLuminosityPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendMultiplyPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendOverlayPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendSaturationPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendScreenPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendSoftLightPipeline (ContentContextOptions opts) const
 
PipelineRef GetBorderMaskBlurPipeline (ContentContextOptions opts) const
 
PipelineRef GetClearBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetClipPipeline (ContentContextOptions opts) const
 
PipelineRef GetColorMatrixColorFilterPipeline (ContentContextOptions opts) const
 
PipelineRef GetConicalGradientFillPipeline (ContentContextOptions opts, ConicalKind kind) const
 
PipelineRef GetConicalGradientSSBOFillPipeline (ContentContextOptions opts, ConicalKind kind) const
 
PipelineRef GetConicalGradientUniformFillPipeline (ContentContextOptions opts, ConicalKind kind) const
 
PipelineRef GetDestinationATopBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetDestinationBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetDestinationInBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetDestinationOutBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetDestinationOverBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetDownsamplePipeline (ContentContextOptions opts) const
 
PipelineRef GetDrawVerticesUberPipeline (BlendMode blend_mode, ContentContextOptions opts) const
 
PipelineRef GetFastGradientPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendColorBurnPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendColorDodgePipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendColorPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendDarkenPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendDifferencePipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendExclusionPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendHardLightPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendHuePipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendLightenPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendLuminosityPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendMultiplyPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendOverlayPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendSaturationPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendScreenPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendSoftLightPipeline (ContentContextOptions opts) const
 
PipelineRef GetGaussianBlurPipeline (ContentContextOptions opts) const
 
PipelineRef GetGlyphAtlasPipeline (ContentContextOptions opts) const
 
PipelineRef GetLinePipeline (ContentContextOptions opts) const
 
PipelineRef GetLinearGradientFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetLinearGradientSSBOFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetLinearGradientUniformFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetLinearToSrgbFilterPipeline (ContentContextOptions opts) const
 
PipelineRef GetModulateBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetMorphologyFilterPipeline (ContentContextOptions opts) const
 
PipelineRef GetPlusBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetPorterDuffPipeline (BlendMode mode, ContentContextOptions opts) const
 
PipelineRef GetRadialGradientFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetRadialGradientSSBOFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetRadialGradientUniformFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetRRectBlurPipeline (ContentContextOptions opts) const
 
PipelineRef GetRSuperellipseBlurPipeline (ContentContextOptions opts) const
 
PipelineRef GetScreenBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetSolidFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetSourceATopBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetSourceBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetSourceInBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetSourceOutBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetSourceOverBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetSrgbToLinearFilterPipeline (ContentContextOptions opts) const
 
PipelineRef GetSweepGradientFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetSweepGradientSSBOFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetSweepGradientUniformFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetTexturePipeline (ContentContextOptions opts) const
 
PipelineRef GetTextureStrictSrcPipeline (ContentContextOptions opts) const
 
PipelineRef GetTiledTexturePipeline (ContentContextOptions opts) const
 
PipelineRef GetXorBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetYUVToRGBFilterPipeline (ContentContextOptions opts) const
 
std::shared_ptr< TextureGetEmptyTexture () const
 
std::shared_ptr< ContextGetContext () const
 
const CapabilitiesGetDeviceCapabilities () const
 
fml::StatusOr< RenderTargetMakeSubpass (std::string_view label, ISize texture_size, const std::shared_ptr< CommandBuffer > &command_buffer, const SubpassCallback &subpass_callback, bool msaa_enabled=true, bool depth_stencil_enabled=false, int32_t mip_count=1) const
 Creates a new texture of size texture_size and calls subpass_callback with a RenderPass for drawing to the texture. More...
 
fml::StatusOr< RenderTargetMakeSubpass (std::string_view label, const RenderTarget &subpass_target, const std::shared_ptr< CommandBuffer > &command_buffer, const SubpassCallback &subpass_callback) const
 Makes a subpass that will render to subpass_target. More...
 
const std::shared_ptr< LazyGlyphAtlas > & GetLazyGlyphAtlas () const
 
const std::shared_ptr< RenderTargetAllocator > & GetRenderTargetCache () const
 
PipelineRef GetCachedRuntimeEffectPipeline (const std::string &unique_entrypoint_name, const ContentContextOptions &options, const std::function< std::shared_ptr< Pipeline< PipelineDescriptor >>()> &create_callback) const
 
void ClearCachedRuntimeEffectPipeline (const std::string &unique_entrypoint_name) const
 
HostBufferGetTransientsBuffer () const
 Retrieve the currnent host buffer for transient storage. More...
 
TextShadowCacheGetTextShadowCache () const
 

Protected Member Functions

void SetTransientsBuffer (std::shared_ptr< HostBuffer > host_buffer)
 

Detailed Description

Definition at line 138 of file content_context.h.

Member Typedef Documentation

◆ SubpassCallback

Definition at line 244 of file content_context.h.

Constructor & Destructor Documentation

◆ ContentContext()

impeller::ContentContext::ContentContext ( std::shared_ptr< Context context,
std::shared_ptr< TypographerContext typographer_context,
std::shared_ptr< RenderTargetAllocator render_target_allocator = nullptr 
)
explicit

Setup default clip pipeline.

Definition at line 544 of file content_context.cc.

548  : context_(std::move(context)),
549  lazy_glyph_atlas_(
550  std::make_shared<LazyGlyphAtlas>(std::move(typographer_context))),
551  pipelines_(new Pipelines()),
552  tessellator_(std::make_shared<Tessellator>()),
553  render_target_cache_(render_target_allocator == nullptr
554  ? std::make_shared<RenderTargetCache>(
555  context_->GetResourceAllocator())
556  : std::move(render_target_allocator)),
557  host_buffer_(HostBuffer::Create(
558  context_->GetResourceAllocator(),
559  context_->GetIdleWaiter(),
560  context_->GetCapabilities()->GetMinimumUniformAlignment())),
561  text_shadow_cache_(std::make_unique<TextShadowCache>()) {
562  if (!context_ || !context_->IsValid()) {
563  return;
564  }
565 
566  {
567  TextureDescriptor desc;
568  desc.storage_mode = StorageMode::kDevicePrivate;
569  desc.format = PixelFormat::kR8G8B8A8UNormInt;
570  desc.size = ISize{1, 1};
571  empty_texture_ = GetContext()->GetResourceAllocator()->CreateTexture(desc);
572 
573  std::array<uint8_t, 4> data = Color::BlackTransparent().ToR8G8B8A8();
574  std::shared_ptr<CommandBuffer> cmd_buffer =
575  GetContext()->CreateCommandBuffer();
576  std::shared_ptr<BlitPass> blit_pass = cmd_buffer->CreateBlitPass();
577  HostBuffer& host_buffer = GetTransientsBuffer();
578  BufferView buffer_view = host_buffer.Emplace(data);
579  blit_pass->AddCopy(buffer_view, empty_texture_);
580 
581  if (!blit_pass->EncodeCommands() || !GetContext()
582  ->GetCommandQueue()
583  ->Submit({std::move(cmd_buffer)})
584  .ok()) {
585  VALIDATION_LOG << "Failed to create empty texture.";
586  }
587  }
588 
589  auto options = ContentContextOptions{
590  .sample_count = SampleCount::kCount4,
591  .color_attachment_pixel_format =
592  context_->GetCapabilities()->GetDefaultColorFormat()};
593  auto options_trianglestrip = ContentContextOptions{
594  .sample_count = SampleCount::kCount4,
595  .primitive_type = PrimitiveType::kTriangleStrip,
596  .color_attachment_pixel_format =
597  context_->GetCapabilities()->GetDefaultColorFormat()};
598  auto options_no_msaa_no_depth_stencil = ContentContextOptions{
599  .sample_count = SampleCount::kCount1,
600  .primitive_type = PrimitiveType::kTriangleStrip,
601  .color_attachment_pixel_format =
602  context_->GetCapabilities()->GetDefaultColorFormat(),
603  .has_depth_stencil_attachments = false};
604  const auto supports_decal = static_cast<Scalar>(
605  context_->GetCapabilities()->SupportsDecalSamplerAddressMode());
606 
607  // Futures for the following pipelines may block in case the first frame is
608  // rendered without the pipelines being ready. Put pipelines that are more
609  // likely to be used first.
610  {
611  pipelines_->glyph_atlas.CreateDefault(
612  *context_, options,
613  {static_cast<Scalar>(
614  GetContext()->GetCapabilities()->GetDefaultGlyphAtlasFormat() ==
616  pipelines_->solid_fill.CreateDefault(*context_, options);
617  pipelines_->texture.CreateDefault(*context_, options);
618  pipelines_->fast_gradient.CreateDefault(*context_, options);
619  pipelines_->line.CreateDefault(*context_, options);
620 
621  if (context_->GetCapabilities()->SupportsSSBO()) {
622  pipelines_->linear_gradient_ssbo_fill.CreateDefault(*context_, options);
623  pipelines_->radial_gradient_ssbo_fill.CreateDefault(*context_, options);
624  pipelines_->conical_gradient_ssbo_fill.CreateDefault(*context_, options,
625  {3.0});
626  pipelines_->conical_gradient_ssbo_fill_radial.CreateDefault(
627  *context_, options, {1.0});
628  pipelines_->conical_gradient_ssbo_fill_strip.CreateDefault(
629  *context_, options, {2.0});
630  pipelines_->conical_gradient_ssbo_fill_strip_and_radial.CreateDefault(
631  *context_, options, {0.0});
632  pipelines_->sweep_gradient_ssbo_fill.CreateDefault(*context_, options);
633  } else {
634  pipelines_->linear_gradient_uniform_fill.CreateDefault(*context_,
635  options);
636  pipelines_->radial_gradient_uniform_fill.CreateDefault(*context_,
637  options);
638  pipelines_->conical_gradient_uniform_fill.CreateDefault(*context_,
639  options);
640  pipelines_->conical_gradient_uniform_fill_radial.CreateDefault(*context_,
641  options);
642  pipelines_->conical_gradient_uniform_fill_strip.CreateDefault(*context_,
643  options);
644  pipelines_->conical_gradient_uniform_fill_strip_and_radial.CreateDefault(
645  *context_, options);
646  pipelines_->sweep_gradient_uniform_fill.CreateDefault(*context_, options);
647 
648  pipelines_->linear_gradient_fill.CreateDefault(*context_, options);
649  pipelines_->radial_gradient_fill.CreateDefault(*context_, options);
650  pipelines_->conical_gradient_fill.CreateDefault(*context_, options);
651  pipelines_->conical_gradient_fill_radial.CreateDefault(*context_,
652  options);
653  pipelines_->conical_gradient_fill_strip.CreateDefault(*context_, options);
654  pipelines_->conical_gradient_fill_strip_and_radial.CreateDefault(
655  *context_, options);
656  pipelines_->sweep_gradient_fill.CreateDefault(*context_, options);
657  }
658 
659  /// Setup default clip pipeline.
660  auto clip_pipeline_descriptor =
662  if (!clip_pipeline_descriptor.has_value()) {
663  return;
664  }
665  ContentContextOptions{
666  .sample_count = SampleCount::kCount4,
667  .color_attachment_pixel_format =
668  context_->GetCapabilities()->GetDefaultColorFormat()}
669  .ApplyToPipelineDescriptor(*clip_pipeline_descriptor);
670  // Disable write to all color attachments.
671  auto clip_color_attachments =
672  clip_pipeline_descriptor->GetColorAttachmentDescriptors();
673  for (auto& color_attachment : clip_color_attachments) {
674  color_attachment.second.write_mask = ColorWriteMaskBits::kNone;
675  }
676  clip_pipeline_descriptor->SetColorAttachmentDescriptors(
677  std::move(clip_color_attachments));
678  if (GetContext()->GetFlags().lazy_shader_mode) {
679  pipelines_->clip.SetDefaultDescriptor(clip_pipeline_descriptor);
680  pipelines_->clip.SetDefault(options, nullptr);
681  } else {
682  pipelines_->clip.SetDefault(
683  options,
684  std::make_unique<ClipPipeline>(*context_, clip_pipeline_descriptor));
685  }
686  pipelines_->texture_downsample.CreateDefault(
687  *context_, options_no_msaa_no_depth_stencil);
688  pipelines_->rrect_blur.CreateDefault(*context_, options_trianglestrip);
689  pipelines_->rsuperellipse_blur.CreateDefault(*context_,
690  options_trianglestrip);
691  pipelines_->texture_strict_src.CreateDefault(*context_, options);
692  pipelines_->tiled_texture.CreateDefault(*context_, options,
693  {supports_decal});
694  pipelines_->gaussian_blur.CreateDefault(
695  *context_, options_no_msaa_no_depth_stencil, {supports_decal});
696  pipelines_->border_mask_blur.CreateDefault(*context_,
697  options_trianglestrip);
698  pipelines_->color_matrix_color_filter.CreateDefault(*context_,
699  options_trianglestrip);
700  pipelines_->vertices_uber_1_.CreateDefault(*context_, options,
701  {supports_decal});
702  pipelines_->vertices_uber_2_.CreateDefault(*context_, options,
703  {supports_decal});
704 
705  const std::array<std::vector<Scalar>, 15> porter_duff_constants =
706  GetPorterDuffSpecConstants(supports_decal);
707  pipelines_->clear_blend.CreateDefault(*context_, options_trianglestrip,
708  porter_duff_constants[0]);
709  pipelines_->source_blend.CreateDefault(*context_, options_trianglestrip,
710  porter_duff_constants[1]);
711  pipelines_->destination_blend.CreateDefault(
712  *context_, options_trianglestrip, porter_duff_constants[2]);
713  pipelines_->source_over_blend.CreateDefault(
714  *context_, options_trianglestrip, porter_duff_constants[3]);
715  pipelines_->destination_over_blend.CreateDefault(
716  *context_, options_trianglestrip, porter_duff_constants[4]);
717  pipelines_->source_in_blend.CreateDefault(*context_, options_trianglestrip,
718  porter_duff_constants[5]);
719  pipelines_->destination_in_blend.CreateDefault(
720  *context_, options_trianglestrip, porter_duff_constants[6]);
721  pipelines_->source_out_blend.CreateDefault(*context_, options_trianglestrip,
722  porter_duff_constants[7]);
723  pipelines_->destination_out_blend.CreateDefault(
724  *context_, options_trianglestrip, porter_duff_constants[8]);
725  pipelines_->source_a_top_blend.CreateDefault(
726  *context_, options_trianglestrip, porter_duff_constants[9]);
727  pipelines_->destination_a_top_blend.CreateDefault(
728  *context_, options_trianglestrip, porter_duff_constants[10]);
729  pipelines_->xor_blend.CreateDefault(*context_, options_trianglestrip,
730  porter_duff_constants[11]);
731  pipelines_->plus_blend.CreateDefault(*context_, options_trianglestrip,
732  porter_duff_constants[12]);
733  pipelines_->modulate_blend.CreateDefault(*context_, options_trianglestrip,
734  porter_duff_constants[13]);
735  pipelines_->screen_blend.CreateDefault(*context_, options_trianglestrip,
736  porter_duff_constants[14]);
737  }
738 
739  if (context_->GetCapabilities()->SupportsFramebufferFetch()) {
740  pipelines_->framebuffer_blend_color.CreateDefault(
741  *context_, options_trianglestrip,
742  {static_cast<Scalar>(BlendSelectValues::kColor), supports_decal});
743  pipelines_->framebuffer_blend_colorburn.CreateDefault(
744  *context_, options_trianglestrip,
745  {static_cast<Scalar>(BlendSelectValues::kColorBurn), supports_decal});
746  pipelines_->framebuffer_blend_colordodge.CreateDefault(
747  *context_, options_trianglestrip,
748  {static_cast<Scalar>(BlendSelectValues::kColorDodge), supports_decal});
749  pipelines_->framebuffer_blend_darken.CreateDefault(
750  *context_, options_trianglestrip,
751  {static_cast<Scalar>(BlendSelectValues::kDarken), supports_decal});
752  pipelines_->framebuffer_blend_difference.CreateDefault(
753  *context_, options_trianglestrip,
754  {static_cast<Scalar>(BlendSelectValues::kDifference), supports_decal});
755  pipelines_->framebuffer_blend_exclusion.CreateDefault(
756  *context_, options_trianglestrip,
757  {static_cast<Scalar>(BlendSelectValues::kExclusion), supports_decal});
758  pipelines_->framebuffer_blend_hardlight.CreateDefault(
759  *context_, options_trianglestrip,
760  {static_cast<Scalar>(BlendSelectValues::kHardLight), supports_decal});
761  pipelines_->framebuffer_blend_hue.CreateDefault(
762  *context_, options_trianglestrip,
763  {static_cast<Scalar>(BlendSelectValues::kHue), supports_decal});
764  pipelines_->framebuffer_blend_lighten.CreateDefault(
765  *context_, options_trianglestrip,
766  {static_cast<Scalar>(BlendSelectValues::kLighten), supports_decal});
767  pipelines_->framebuffer_blend_luminosity.CreateDefault(
768  *context_, options_trianglestrip,
769  {static_cast<Scalar>(BlendSelectValues::kLuminosity), supports_decal});
770  pipelines_->framebuffer_blend_multiply.CreateDefault(
771  *context_, options_trianglestrip,
772  {static_cast<Scalar>(BlendSelectValues::kMultiply), supports_decal});
773  pipelines_->framebuffer_blend_overlay.CreateDefault(
774  *context_, options_trianglestrip,
775  {static_cast<Scalar>(BlendSelectValues::kOverlay), supports_decal});
776  pipelines_->framebuffer_blend_saturation.CreateDefault(
777  *context_, options_trianglestrip,
778  {static_cast<Scalar>(BlendSelectValues::kSaturation), supports_decal});
779  pipelines_->framebuffer_blend_screen.CreateDefault(
780  *context_, options_trianglestrip,
781  {static_cast<Scalar>(BlendSelectValues::kScreen), supports_decal});
782  pipelines_->framebuffer_blend_softlight.CreateDefault(
783  *context_, options_trianglestrip,
784  {static_cast<Scalar>(BlendSelectValues::kSoftLight), supports_decal});
785  } else {
786  pipelines_->blend_color.CreateDefault(
787  *context_, options_trianglestrip,
788  {static_cast<Scalar>(BlendSelectValues::kColor), supports_decal});
789  pipelines_->blend_colorburn.CreateDefault(
790  *context_, options_trianglestrip,
791  {static_cast<Scalar>(BlendSelectValues::kColorBurn), supports_decal});
792  pipelines_->blend_colordodge.CreateDefault(
793  *context_, options_trianglestrip,
794  {static_cast<Scalar>(BlendSelectValues::kColorDodge), supports_decal});
795  pipelines_->blend_darken.CreateDefault(
796  *context_, options_trianglestrip,
797  {static_cast<Scalar>(BlendSelectValues::kDarken), supports_decal});
798  pipelines_->blend_difference.CreateDefault(
799  *context_, options_trianglestrip,
800  {static_cast<Scalar>(BlendSelectValues::kDifference), supports_decal});
801  pipelines_->blend_exclusion.CreateDefault(
802  *context_, options_trianglestrip,
803  {static_cast<Scalar>(BlendSelectValues::kExclusion), supports_decal});
804  pipelines_->blend_hardlight.CreateDefault(
805  *context_, options_trianglestrip,
806  {static_cast<Scalar>(BlendSelectValues::kHardLight), supports_decal});
807  pipelines_->blend_hue.CreateDefault(
808  *context_, options_trianglestrip,
809  {static_cast<Scalar>(BlendSelectValues::kHue), supports_decal});
810  pipelines_->blend_lighten.CreateDefault(
811  *context_, options_trianglestrip,
812  {static_cast<Scalar>(BlendSelectValues::kLighten), supports_decal});
813  pipelines_->blend_luminosity.CreateDefault(
814  *context_, options_trianglestrip,
815  {static_cast<Scalar>(BlendSelectValues::kLuminosity), supports_decal});
816  pipelines_->blend_multiply.CreateDefault(
817  *context_, options_trianglestrip,
818  {static_cast<Scalar>(BlendSelectValues::kMultiply), supports_decal});
819  pipelines_->blend_overlay.CreateDefault(
820  *context_, options_trianglestrip,
821  {static_cast<Scalar>(BlendSelectValues::kOverlay), supports_decal});
822  pipelines_->blend_saturation.CreateDefault(
823  *context_, options_trianglestrip,
824  {static_cast<Scalar>(BlendSelectValues::kSaturation), supports_decal});
825  pipelines_->blend_screen.CreateDefault(
826  *context_, options_trianglestrip,
827  {static_cast<Scalar>(BlendSelectValues::kScreen), supports_decal});
828  pipelines_->blend_softlight.CreateDefault(
829  *context_, options_trianglestrip,
830  {static_cast<Scalar>(BlendSelectValues::kSoftLight), supports_decal});
831  }
832 
833  pipelines_->morphology_filter.CreateDefault(*context_, options_trianglestrip,
834  {supports_decal});
835  pipelines_->linear_to_srgb_filter.CreateDefault(*context_,
836  options_trianglestrip);
837  pipelines_->srgb_to_linear_filter.CreateDefault(*context_,
838  options_trianglestrip);
839  pipelines_->yuv_to_rgb_filter.CreateDefault(*context_, options_trianglestrip);
840 
841 #if defined(IMPELLER_ENABLE_OPENGLES)
842  if (GetContext()->GetBackendType() == Context::BackendType::kOpenGLES) {
843 #if !defined(FML_OS_MACOSX)
844  // GLES only shader that is unsupported on macOS.
845  pipelines_->tiled_texture_external.CreateDefault(*context_, options);
846  pipelines_->tiled_texture_uv_external.CreateDefault(*context_, options);
847 #endif // !defined(FML_OS_MACOSX)
848  pipelines_->texture_downsample_gles.CreateDefault(*context_,
849  options_trianglestrip);
850  }
851 #endif // IMPELLER_ENABLE_OPENGLES
852 
853  is_valid_ = true;
854  InitializeCommonlyUsedShadersIfNeeded();
855 }
BufferView buffer_view
HostBuffer & GetTransientsBuffer() const
Retrieve the currnent host buffer for transient storage.
std::shared_ptr< Context > GetContext() const
static std::shared_ptr< HostBuffer > Create(const std::shared_ptr< Allocator > &allocator, const std::shared_ptr< const IdleWaiter > &idle_waiter, size_t minimum_uniform_alignment)
Definition: host_buffer.cc:21
float Scalar
Definition: scalar.h:19
std::array< std::vector< Scalar >, 15 > GetPorterDuffSpecConstants(bool supports_decal)
ISize64 ISize
Definition: size.h:162
std::array< uint8_t, 4 > ToR8G8B8A8() const
Convert to R8G8B8A8 representation.
Definition: color.h:246
static constexpr Color BlackTransparent()
Definition: color.h:270
static std::optional< PipelineDescriptor > MakeDefaultPipelineDescriptor(const Context &context, const std::vector< Scalar > &constants={})
Create a default pipeline descriptor using the combination reflected shader information....
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:68
#define VALIDATION_LOG
Definition: validation.h:91

References impeller::Color::BlackTransparent(), buffer_view, data, impeller::HostBuffer::Emplace(), impeller::TextureDescriptor::format, GetContext(), impeller::GetPorterDuffSpecConstants(), GetTransientsBuffer(), impeller::kA8UNormInt, impeller::kColor, impeller::kColorBurn, impeller::kColorDodge, impeller::kCount1, impeller::kCount4, impeller::kDarken, impeller::kDevicePrivate, impeller::kDifference, impeller::kExclusion, impeller::kHardLight, impeller::kHue, impeller::kLighten, impeller::kLuminosity, impeller::kMultiply, impeller::kNone, impeller::Context::kOpenGLES, impeller::kOverlay, impeller::kR8G8B8A8UNormInt, impeller::kSaturation, impeller::kScreen, impeller::kSoftLight, impeller::kTriangleStrip, impeller::PipelineBuilder< VertexShader_, FragmentShader_ >::MakeDefaultPipelineDescriptor(), pipelines_, impeller::ContentContextOptions::sample_count, impeller::TextureDescriptor::size, impeller::TextureDescriptor::storage_mode, impeller::Color::ToR8G8B8A8(), and VALIDATION_LOG.

◆ ~ContentContext()

impeller::ContentContext::~ContentContext ( )
default

Member Function Documentation

◆ ClearCachedRuntimeEffectPipeline()

void impeller::ContentContext::ClearCachedRuntimeEffectPipeline ( const std::string &  unique_entrypoint_name) const

Used by hot reload/hot restart to clear a cached pipeline from GetCachedRuntimeEffectPipeline.

Definition at line 960 of file content_context.cc.

961  {
962 #ifdef IMPELLER_DEBUG
963  // destroying in-use pipleines is a validation error.
964  const auto& idle_waiter = GetContext()->GetIdleWaiter();
965  if (idle_waiter) {
966  idle_waiter->WaitIdle();
967  }
968 #endif // IMPELLER_DEBUG
969  for (auto it = runtime_effect_pipelines_.begin();
970  it != runtime_effect_pipelines_.end();) {
971  if (it->first.unique_entrypoint_name == unique_entrypoint_name) {
972  it = runtime_effect_pipelines_.erase(it);
973  } else {
974  it++;
975  }
976  }
977 }

References GetContext().

◆ GetBlendColorBurnPipeline()

PipelineRef impeller::ContentContext::GetBlendColorBurnPipeline ( ContentContextOptions  opts) const

Definition at line 1302 of file content_context.cc.

1303  {
1304  return GetPipeline(this, pipelines_->blend_colorburn, opts);
1305 }

References pipelines_.

◆ GetBlendColorDodgePipeline()

PipelineRef impeller::ContentContext::GetBlendColorDodgePipeline ( ContentContextOptions  opts) const

Definition at line 1307 of file content_context.cc.

1308  {
1309  return GetPipeline(this, pipelines_->blend_colordodge, opts);
1310 }

References pipelines_.

◆ GetBlendColorPipeline()

PipelineRef impeller::ContentContext::GetBlendColorPipeline ( ContentContextOptions  opts) const

Definition at line 1297 of file content_context.cc.

1298  {
1299  return GetPipeline(this, pipelines_->blend_color, opts);
1300 }

References pipelines_.

◆ GetBlendDarkenPipeline()

PipelineRef impeller::ContentContext::GetBlendDarkenPipeline ( ContentContextOptions  opts) const

Definition at line 1312 of file content_context.cc.

1313  {
1314  return GetPipeline(this, pipelines_->blend_darken, opts);
1315 }

References pipelines_.

◆ GetBlendDifferencePipeline()

PipelineRef impeller::ContentContext::GetBlendDifferencePipeline ( ContentContextOptions  opts) const

Definition at line 1317 of file content_context.cc.

1318  {
1319  return GetPipeline(this, pipelines_->blend_difference, opts);
1320 }

References pipelines_.

◆ GetBlendExclusionPipeline()

PipelineRef impeller::ContentContext::GetBlendExclusionPipeline ( ContentContextOptions  opts) const

Definition at line 1322 of file content_context.cc.

1323  {
1324  return GetPipeline(this, pipelines_->blend_exclusion, opts);
1325 }

References pipelines_.

◆ GetBlendHardLightPipeline()

PipelineRef impeller::ContentContext::GetBlendHardLightPipeline ( ContentContextOptions  opts) const

Definition at line 1327 of file content_context.cc.

1328  {
1329  return GetPipeline(this, pipelines_->blend_hardlight, opts);
1330 }

References pipelines_.

◆ GetBlendHuePipeline()

PipelineRef impeller::ContentContext::GetBlendHuePipeline ( ContentContextOptions  opts) const

Definition at line 1332 of file content_context.cc.

1333  {
1334  return GetPipeline(this, pipelines_->blend_hue, opts);
1335 }

References pipelines_.

◆ GetBlendLightenPipeline()

PipelineRef impeller::ContentContext::GetBlendLightenPipeline ( ContentContextOptions  opts) const

Definition at line 1337 of file content_context.cc.

1338  {
1339  return GetPipeline(this, pipelines_->blend_lighten, opts);
1340 }

References pipelines_.

◆ GetBlendLuminosityPipeline()

PipelineRef impeller::ContentContext::GetBlendLuminosityPipeline ( ContentContextOptions  opts) const

Definition at line 1342 of file content_context.cc.

1343  {
1344  return GetPipeline(this, pipelines_->blend_luminosity, opts);
1345 }

References pipelines_.

◆ GetBlendMultiplyPipeline()

PipelineRef impeller::ContentContext::GetBlendMultiplyPipeline ( ContentContextOptions  opts) const

Definition at line 1347 of file content_context.cc.

1348  {
1349  return GetPipeline(this, pipelines_->blend_multiply, opts);
1350 }

References pipelines_.

◆ GetBlendOverlayPipeline()

PipelineRef impeller::ContentContext::GetBlendOverlayPipeline ( ContentContextOptions  opts) const

Definition at line 1352 of file content_context.cc.

1353  {
1354  return GetPipeline(this, pipelines_->blend_overlay, opts);
1355 }

References pipelines_.

◆ GetBlendSaturationPipeline()

PipelineRef impeller::ContentContext::GetBlendSaturationPipeline ( ContentContextOptions  opts) const

Definition at line 1357 of file content_context.cc.

1358  {
1359  return GetPipeline(this, pipelines_->blend_saturation, opts);
1360 }

References pipelines_.

◆ GetBlendScreenPipeline()

PipelineRef impeller::ContentContext::GetBlendScreenPipeline ( ContentContextOptions  opts) const

Definition at line 1362 of file content_context.cc.

1363  {
1364  return GetPipeline(this, pipelines_->blend_screen, opts);
1365 }

References pipelines_.

◆ GetBlendSoftLightPipeline()

PipelineRef impeller::ContentContext::GetBlendSoftLightPipeline ( ContentContextOptions  opts) const

Definition at line 1367 of file content_context.cc.

1368  {
1369  return GetPipeline(this, pipelines_->blend_softlight, opts);
1370 }

References pipelines_.

◆ GetBorderMaskBlurPipeline()

PipelineRef impeller::ContentContext::GetBorderMaskBlurPipeline ( ContentContextOptions  opts) const

Definition at line 1128 of file content_context.cc.

1129  {
1130  return GetPipeline(this, pipelines_->border_mask_blur, opts);
1131 }

References pipelines_.

◆ GetCachedRuntimeEffectPipeline()

PipelineRef impeller::ContentContext::GetCachedRuntimeEffectPipeline ( const std::string &  unique_entrypoint_name,
const ContentContextOptions options,
const std::function< std::shared_ptr< Pipeline< PipelineDescriptor >>()> &  create_callback 
) const

RuntimeEffect pipelines must be obtained via this method to avoid re-creating them every frame.

The unique_entrypoint_name comes from RuntimeEffect::GetEntrypoint. Impellerc generates a unique entrypoint name for runtime effect shaders based on the input file name and shader stage.

The create_callback is synchronously invoked exactly once if a cached pipeline is not found.

Definition at line 947 of file content_context.cc.

951  {
952  RuntimeEffectPipelineKey key{unique_entrypoint_name, options};
953  auto it = runtime_effect_pipelines_.find(key);
954  if (it == runtime_effect_pipelines_.end()) {
955  it = runtime_effect_pipelines_.insert(it, {key, create_callback()});
956  }
957  return raw_ptr(it->second);
958 }

Referenced by impeller::RuntimeEffectContents::Render().

◆ GetClearBlendPipeline()

PipelineRef impeller::ContentContext::GetClearBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1222 of file content_context.cc.

1223  {
1224  return GetPipeline(this, pipelines_->clear_blend, opts);
1225 }

References pipelines_.

Referenced by GetPorterDuffPipeline().

◆ GetClipPipeline()

PipelineRef impeller::ContentContext::GetClipPipeline ( ContentContextOptions  opts) const

Definition at line 1153 of file content_context.cc.

1153  {
1154  return GetPipeline(this, pipelines_->clip, opts);
1155 }

References pipelines_.

Referenced by impeller::ColorSourceContents::DrawGeometry(), impeller::ClipContents::Render(), and impeller::RenderClipRestore().

◆ GetColorMatrixColorFilterPipeline()

PipelineRef impeller::ContentContext::GetColorMatrixColorFilterPipeline ( ContentContextOptions  opts) const

Definition at line 1138 of file content_context.cc.

1139  {
1140  return GetPipeline(this, pipelines_->color_matrix_color_filter, opts);
1141 }

References pipelines_.

Referenced by impeller::ColorFilterAtlasContents::Render().

◆ GetConicalGradientFillPipeline()

PipelineRef impeller::ContentContext::GetConicalGradientFillPipeline ( ContentContextOptions  opts,
ConicalKind  kind 
) const

Definition at line 1072 of file content_context.cc.

1074  {
1075  switch (kind) {
1076  case ConicalKind::kConical:
1077  return GetPipeline(this, pipelines_->conical_gradient_fill, opts);
1078  case ConicalKind::kRadial:
1079  return GetPipeline(this, pipelines_->conical_gradient_fill_radial, opts);
1080  case ConicalKind::kStrip:
1081  return GetPipeline(this, pipelines_->conical_gradient_fill_strip, opts);
1083  return GetPipeline(
1084  this, pipelines_->conical_gradient_fill_strip_and_radial, opts);
1085  }
1086 }

References impeller::kConical, impeller::kRadial, impeller::kStrip, impeller::kStripAndRadial, and pipelines_.

◆ GetConicalGradientSSBOFillPipeline()

PipelineRef impeller::ContentContext::GetConicalGradientSSBOFillPipeline ( ContentContextOptions  opts,
ConicalKind  kind 
) const

Definition at line 1042 of file content_context.cc.

1044  {
1045  FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
1046  switch (kind) {
1047  case ConicalKind::kConical:
1048  return GetPipeline(this, pipelines_->conical_gradient_ssbo_fill, opts);
1049  case ConicalKind::kRadial:
1050  return GetPipeline(this, pipelines_->conical_gradient_ssbo_fill_radial,
1051  opts);
1052  case ConicalKind::kStrip:
1053  return GetPipeline(this, pipelines_->conical_gradient_ssbo_fill_strip,
1054  opts);
1056  return GetPipeline(
1057  this, pipelines_->conical_gradient_ssbo_fill_strip_and_radial, opts);
1058  }
1059 }
const Capabilities & GetDeviceCapabilities() const

References GetDeviceCapabilities(), impeller::kConical, impeller::kRadial, impeller::kStrip, impeller::kStripAndRadial, and pipelines_.

◆ GetConicalGradientUniformFillPipeline()

PipelineRef impeller::ContentContext::GetConicalGradientUniformFillPipeline ( ContentContextOptions  opts,
ConicalKind  kind 
) const

Definition at line 1023 of file content_context.cc.

1025  {
1026  switch (kind) {
1027  case ConicalKind::kConical:
1028  return GetPipeline(this, pipelines_->conical_gradient_uniform_fill, opts);
1029  case ConicalKind::kRadial:
1030  return GetPipeline(this, pipelines_->conical_gradient_uniform_fill_radial,
1031  opts);
1032  case ConicalKind::kStrip:
1033  return GetPipeline(this, pipelines_->conical_gradient_uniform_fill_strip,
1034  opts);
1036  return GetPipeline(
1037  this, pipelines_->conical_gradient_uniform_fill_strip_and_radial,
1038  opts);
1039  }
1040 }

References impeller::kConical, impeller::kRadial, impeller::kStrip, impeller::kStripAndRadial, and pipelines_.

◆ GetContext()

◆ GetDestinationATopBlendPipeline()

PipelineRef impeller::ContentContext::GetDestinationATopBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1272 of file content_context.cc.

1273  {
1274  return GetPipeline(this, pipelines_->destination_a_top_blend, opts);
1275 }

References pipelines_.

Referenced by GetPorterDuffPipeline().

◆ GetDestinationBlendPipeline()

PipelineRef impeller::ContentContext::GetDestinationBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1232 of file content_context.cc.

1233  {
1234  return GetPipeline(this, pipelines_->destination_blend, opts);
1235 }

References pipelines_.

Referenced by GetPorterDuffPipeline().

◆ GetDestinationInBlendPipeline()

PipelineRef impeller::ContentContext::GetDestinationInBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1252 of file content_context.cc.

1253  {
1254  return GetPipeline(this, pipelines_->destination_in_blend, opts);
1255 }

References pipelines_.

Referenced by GetPorterDuffPipeline().

◆ GetDestinationOutBlendPipeline()

PipelineRef impeller::ContentContext::GetDestinationOutBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1262 of file content_context.cc.

1263  {
1264  return GetPipeline(this, pipelines_->destination_out_blend, opts);
1265 }

References pipelines_.

Referenced by GetPorterDuffPipeline().

◆ GetDestinationOverBlendPipeline()

PipelineRef impeller::ContentContext::GetDestinationOverBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1242 of file content_context.cc.

1243  {
1244  return GetPipeline(this, pipelines_->destination_over_blend, opts);
1245 }

References pipelines_.

Referenced by GetPorterDuffPipeline().

◆ GetDeviceCapabilities()

◆ GetDownsamplePipeline()

PipelineRef impeller::ContentContext::GetDownsamplePipeline ( ContentContextOptions  opts) const

Definition at line 1372 of file content_context.cc.

1373  {
1374  return GetPipeline(this, pipelines_->texture_downsample, opts);
1375 }

References pipelines_.

◆ GetDrawVerticesUberPipeline()

PipelineRef impeller::ContentContext::GetDrawVerticesUberPipeline ( BlendMode  blend_mode,
ContentContextOptions  opts 
) const

Definition at line 1467 of file content_context.cc.

1469  {
1470  if (blend_mode <= BlendMode::kHardLight) {
1471  return GetPipeline(this, pipelines_->vertices_uber_1_, opts);
1472  } else {
1473  return GetPipeline(this, pipelines_->vertices_uber_2_, opts);
1474  }
1475 }

References impeller::kHardLight, and pipelines_.

Referenced by impeller::AtlasContents::Render(), and impeller::VerticesSimpleBlendContents::Render().

◆ GetEmptyTexture()

std::shared_ptr< Texture > impeller::ContentContext::GetEmptyTexture ( ) const

Definition at line 863 of file content_context.cc.

863  {
864  return empty_texture_;
865 }

Referenced by impeller::VerticesSimpleBlendContents::Render().

◆ GetFastGradientPipeline()

PipelineRef impeller::ContentContext::GetFastGradientPipeline ( ContentContextOptions  opts) const

Definition at line 986 of file content_context.cc.

987  {
988  return GetPipeline(this, pipelines_->fast_gradient, opts);
989 }

References pipelines_.

◆ GetFramebufferBlendColorBurnPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendColorBurnPipeline ( ContentContextOptions  opts) const

Definition at line 1383 of file content_context.cc.

1384  {
1385  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1386  return GetPipeline(this, pipelines_->framebuffer_blend_colorburn, opts);
1387 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetFramebufferBlendColorDodgePipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendColorDodgePipeline ( ContentContextOptions  opts) const

Definition at line 1389 of file content_context.cc.

1390  {
1391  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1392  return GetPipeline(this, pipelines_->framebuffer_blend_colordodge, opts);
1393 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetFramebufferBlendColorPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendColorPipeline ( ContentContextOptions  opts) const

Definition at line 1377 of file content_context.cc.

1378  {
1379  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1380  return GetPipeline(this, pipelines_->framebuffer_blend_color, opts);
1381 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetFramebufferBlendDarkenPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendDarkenPipeline ( ContentContextOptions  opts) const

Definition at line 1395 of file content_context.cc.

1396  {
1397  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1398  return GetPipeline(this, pipelines_->framebuffer_blend_darken, opts);
1399 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetFramebufferBlendDifferencePipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendDifferencePipeline ( ContentContextOptions  opts) const

Definition at line 1401 of file content_context.cc.

1402  {
1403  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1404  return GetPipeline(this, pipelines_->framebuffer_blend_difference, opts);
1405 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetFramebufferBlendExclusionPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendExclusionPipeline ( ContentContextOptions  opts) const

Definition at line 1407 of file content_context.cc.

1408  {
1409  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1410  return GetPipeline(this, pipelines_->framebuffer_blend_exclusion, opts);
1411 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetFramebufferBlendHardLightPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendHardLightPipeline ( ContentContextOptions  opts) const

Definition at line 1413 of file content_context.cc.

1414  {
1415  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1416  return GetPipeline(this, pipelines_->framebuffer_blend_hardlight, opts);
1417 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetFramebufferBlendHuePipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendHuePipeline ( ContentContextOptions  opts) const

Definition at line 1419 of file content_context.cc.

1420  {
1421  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1422  return GetPipeline(this, pipelines_->framebuffer_blend_hue, opts);
1423 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetFramebufferBlendLightenPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendLightenPipeline ( ContentContextOptions  opts) const

Definition at line 1425 of file content_context.cc.

1426  {
1427  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1428  return GetPipeline(this, pipelines_->framebuffer_blend_lighten, opts);
1429 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetFramebufferBlendLuminosityPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendLuminosityPipeline ( ContentContextOptions  opts) const

Definition at line 1431 of file content_context.cc.

1432  {
1433  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1434  return GetPipeline(this, pipelines_->framebuffer_blend_luminosity, opts);
1435 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetFramebufferBlendMultiplyPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendMultiplyPipeline ( ContentContextOptions  opts) const

Definition at line 1437 of file content_context.cc.

1438  {
1439  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1440  return GetPipeline(this, pipelines_->framebuffer_blend_multiply, opts);
1441 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetFramebufferBlendOverlayPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendOverlayPipeline ( ContentContextOptions  opts) const

Definition at line 1443 of file content_context.cc.

1444  {
1445  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1446  return GetPipeline(this, pipelines_->framebuffer_blend_overlay, opts);
1447 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetFramebufferBlendSaturationPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendSaturationPipeline ( ContentContextOptions  opts) const

Definition at line 1449 of file content_context.cc.

1450  {
1451  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1452  return GetPipeline(this, pipelines_->framebuffer_blend_saturation, opts);
1453 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetFramebufferBlendScreenPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendScreenPipeline ( ContentContextOptions  opts) const

Definition at line 1455 of file content_context.cc.

1456  {
1457  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1458  return GetPipeline(this, pipelines_->framebuffer_blend_screen, opts);
1459 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetFramebufferBlendSoftLightPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendSoftLightPipeline ( ContentContextOptions  opts) const

Definition at line 1461 of file content_context.cc.

1462  {
1463  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1464  return GetPipeline(this, pipelines_->framebuffer_blend_softlight, opts);
1465 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetGaussianBlurPipeline()

PipelineRef impeller::ContentContext::GetGaussianBlurPipeline ( ContentContextOptions  opts) const

Definition at line 1123 of file content_context.cc.

1124  {
1125  return GetPipeline(this, pipelines_->gaussian_blur, opts);
1126 }

References pipelines_.

◆ GetGlyphAtlasPipeline()

PipelineRef impeller::ContentContext::GetGlyphAtlasPipeline ( ContentContextOptions  opts) const

Definition at line 1157 of file content_context.cc.

1158  {
1159  return GetPipeline(this, pipelines_->glyph_atlas, opts);
1160 }

References pipelines_.

Referenced by impeller::TextContents::Render().

◆ GetLazyGlyphAtlas()

const std::shared_ptr<LazyGlyphAtlas>& impeller::ContentContext::GetLazyGlyphAtlas ( ) const
inline

Definition at line 265 of file content_context.h.

265  {
266  return lazy_glyph_atlas_;
267  }

Referenced by impeller::FirstPassDispatcher::drawTextFrame(), impeller::TextContents::Render(), impeller::RenderToTarget(), and impeller::testing::TEST_P().

◆ GetLinearGradientFillPipeline()

PipelineRef impeller::ContentContext::GetLinearGradientFillPipeline ( ContentContextOptions  opts) const

Definition at line 991 of file content_context.cc.

992  {
993  return GetPipeline(this, pipelines_->linear_gradient_fill, opts);
994 }

References pipelines_.

◆ GetLinearGradientSSBOFillPipeline()

PipelineRef impeller::ContentContext::GetLinearGradientSSBOFillPipeline ( ContentContextOptions  opts) const

Definition at line 1011 of file content_context.cc.

1012  {
1013  FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
1014  return GetPipeline(this, pipelines_->linear_gradient_ssbo_fill, opts);
1015 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetLinearGradientUniformFillPipeline()

PipelineRef impeller::ContentContext::GetLinearGradientUniformFillPipeline ( ContentContextOptions  opts) const

Definition at line 996 of file content_context.cc.

997  {
998  return GetPipeline(this, pipelines_->linear_gradient_uniform_fill, opts);
999 }

References pipelines_.

◆ GetLinearToSrgbFilterPipeline()

PipelineRef impeller::ContentContext::GetLinearToSrgbFilterPipeline ( ContentContextOptions  opts) const

Definition at line 1143 of file content_context.cc.

1144  {
1145  return GetPipeline(this, pipelines_->linear_to_srgb_filter, opts);
1146 }

References pipelines_.

◆ GetLinePipeline()

PipelineRef impeller::ContentContext::GetLinePipeline ( ContentContextOptions  opts) const

Definition at line 1477 of file content_context.cc.

1477  {
1478  return GetPipeline(this, pipelines_->line, opts);
1479 }

References pipelines_.

Referenced by impeller::LineContents::Render().

◆ GetModulateBlendPipeline()

PipelineRef impeller::ContentContext::GetModulateBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1287 of file content_context.cc.

1288  {
1289  return GetPipeline(this, pipelines_->modulate_blend, opts);
1290 }

References pipelines_.

Referenced by GetPorterDuffPipeline().

◆ GetMorphologyFilterPipeline()

PipelineRef impeller::ContentContext::GetMorphologyFilterPipeline ( ContentContextOptions  opts) const

Definition at line 1133 of file content_context.cc.

1134  {
1135  return GetPipeline(this, pipelines_->morphology_filter, opts);
1136 }

References pipelines_.

◆ GetPlusBlendPipeline()

PipelineRef impeller::ContentContext::GetPlusBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1282 of file content_context.cc.

1283  {
1284  return GetPipeline(this, pipelines_->plus_blend, opts);
1285 }

References pipelines_.

Referenced by GetPorterDuffPipeline().

◆ GetPorterDuffPipeline()

PipelineRef impeller::ContentContext::GetPorterDuffPipeline ( BlendMode  mode,
ContentContextOptions  opts 
) const

Definition at line 1167 of file content_context.cc.

1169  {
1170  switch (mode) {
1171  case BlendMode::kClear:
1172  return GetClearBlendPipeline(opts);
1173  case BlendMode::kSrc:
1174  return GetSourceBlendPipeline(opts);
1175  case BlendMode::kDst:
1176  return GetDestinationBlendPipeline(opts);
1177  case BlendMode::kSrcOver:
1178  return GetSourceOverBlendPipeline(opts);
1179  case BlendMode::kDstOver:
1180  return GetDestinationOverBlendPipeline(opts);
1181  case BlendMode::kSrcIn:
1182  return GetSourceInBlendPipeline(opts);
1183  case BlendMode::kDstIn:
1184  return GetDestinationInBlendPipeline(opts);
1185  case BlendMode::kSrcOut:
1186  return GetSourceOutBlendPipeline(opts);
1187  case BlendMode::kDstOut:
1188  return GetDestinationOutBlendPipeline(opts);
1189  case BlendMode::kSrcATop:
1190  return GetSourceATopBlendPipeline(opts);
1191  case BlendMode::kDstATop:
1192  return GetDestinationATopBlendPipeline(opts);
1193  case BlendMode::kXor:
1194  return GetXorBlendPipeline(opts);
1195  case BlendMode::kPlus:
1196  return GetPlusBlendPipeline(opts);
1197  case BlendMode::kModulate:
1198  return GetModulateBlendPipeline(opts);
1199  case BlendMode::kScreen:
1200  return GetScreenBlendPipeline(opts);
1201  case BlendMode::kOverlay:
1202  case BlendMode::kDarken:
1203  case BlendMode::kLighten:
1205  case BlendMode::kColorBurn:
1206  case BlendMode::kHardLight:
1207  case BlendMode::kSoftLight:
1209  case BlendMode::kExclusion:
1210  case BlendMode::kMultiply:
1211  case BlendMode::kHue:
1213  case BlendMode::kColor:
1215  VALIDATION_LOG << "Invalid porter duff blend mode "
1216  << BlendModeToString(mode);
1217  return GetClearBlendPipeline(opts);
1218  break;
1219  }
1220 }
PipelineRef GetSourceInBlendPipeline(ContentContextOptions opts) const
PipelineRef GetSourceOutBlendPipeline(ContentContextOptions opts) const
PipelineRef GetScreenBlendPipeline(ContentContextOptions opts) const
PipelineRef GetPlusBlendPipeline(ContentContextOptions opts) const
PipelineRef GetModulateBlendPipeline(ContentContextOptions opts) const
PipelineRef GetDestinationATopBlendPipeline(ContentContextOptions opts) const
PipelineRef GetClearBlendPipeline(ContentContextOptions opts) const
PipelineRef GetDestinationOutBlendPipeline(ContentContextOptions opts) const
PipelineRef GetSourceATopBlendPipeline(ContentContextOptions opts) const
PipelineRef GetXorBlendPipeline(ContentContextOptions opts) const
PipelineRef GetSourceBlendPipeline(ContentContextOptions opts) const
PipelineRef GetDestinationBlendPipeline(ContentContextOptions opts) const
PipelineRef GetDestinationOverBlendPipeline(ContentContextOptions opts) const
PipelineRef GetSourceOverBlendPipeline(ContentContextOptions opts) const
PipelineRef GetDestinationInBlendPipeline(ContentContextOptions opts) const
const char * BlendModeToString(BlendMode blend_mode)
Definition: color.cc:47

References impeller::BlendModeToString(), GetClearBlendPipeline(), GetDestinationATopBlendPipeline(), GetDestinationBlendPipeline(), GetDestinationInBlendPipeline(), GetDestinationOutBlendPipeline(), GetDestinationOverBlendPipeline(), GetModulateBlendPipeline(), GetPlusBlendPipeline(), GetScreenBlendPipeline(), GetSourceATopBlendPipeline(), GetSourceBlendPipeline(), GetSourceInBlendPipeline(), GetSourceOutBlendPipeline(), GetSourceOverBlendPipeline(), GetXorBlendPipeline(), impeller::kClear, impeller::kColor, impeller::kColorBurn, impeller::kColorDodge, impeller::kDarken, impeller::kDifference, impeller::kDst, impeller::kDstATop, impeller::kDstIn, impeller::kDstOut, impeller::kDstOver, impeller::kExclusion, impeller::kHardLight, impeller::kHue, impeller::kLighten, impeller::kLuminosity, impeller::kModulate, impeller::kMultiply, impeller::kOverlay, impeller::kPlus, impeller::kSaturation, impeller::kScreen, impeller::kSoftLight, impeller::kSrc, impeller::kSrcATop, impeller::kSrcIn, impeller::kSrcOut, impeller::kSrcOver, impeller::kXor, and VALIDATION_LOG.

Referenced by impeller::AtlasContents::Render(), and impeller::VerticesSimpleBlendContents::Render().

◆ GetRadialGradientFillPipeline()

PipelineRef impeller::ContentContext::GetRadialGradientFillPipeline ( ContentContextOptions  opts) const

Definition at line 1067 of file content_context.cc.

1068  {
1069  return GetPipeline(this, pipelines_->radial_gradient_fill, opts);
1070 }

References pipelines_.

◆ GetRadialGradientSSBOFillPipeline()

PipelineRef impeller::ContentContext::GetRadialGradientSSBOFillPipeline ( ContentContextOptions  opts) const

Definition at line 1017 of file content_context.cc.

1018  {
1019  FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
1020  return GetPipeline(this, pipelines_->radial_gradient_ssbo_fill, opts);
1021 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetRadialGradientUniformFillPipeline()

PipelineRef impeller::ContentContext::GetRadialGradientUniformFillPipeline ( ContentContextOptions  opts) const

Definition at line 1001 of file content_context.cc.

1002  {
1003  return GetPipeline(this, pipelines_->radial_gradient_uniform_fill, opts);
1004 }

References pipelines_.

◆ GetRenderTargetCache()

const std::shared_ptr<RenderTargetAllocator>& impeller::ContentContext::GetRenderTargetCache ( ) const
inline

◆ GetRRectBlurPipeline()

PipelineRef impeller::ContentContext::GetRRectBlurPipeline ( ContentContextOptions  opts) const

Definition at line 1088 of file content_context.cc.

1089  {
1090  return GetPipeline(this, pipelines_->rrect_blur, opts);
1091 }

References pipelines_.

Referenced by impeller::SolidRRectBlurContents::SetPassInfo().

◆ GetRSuperellipseBlurPipeline()

PipelineRef impeller::ContentContext::GetRSuperellipseBlurPipeline ( ContentContextOptions  opts) const

Definition at line 1093 of file content_context.cc.

1094  {
1095  return GetPipeline(this, pipelines_->rsuperellipse_blur, opts);
1096 }

References pipelines_.

◆ GetScreenBlendPipeline()

PipelineRef impeller::ContentContext::GetScreenBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1292 of file content_context.cc.

1293  {
1294  return GetPipeline(this, pipelines_->screen_blend, opts);
1295 }

References pipelines_.

Referenced by GetPorterDuffPipeline().

◆ GetSolidFillPipeline()

PipelineRef impeller::ContentContext::GetSolidFillPipeline ( ContentContextOptions  opts) const

Definition at line 1103 of file content_context.cc.

1104  {
1105  return GetPipeline(this, pipelines_->solid_fill, opts);
1106 }

References pipelines_.

Referenced by impeller::SolidColorContents::Render(), and impeller::testing::TEST_P().

◆ GetSourceATopBlendPipeline()

PipelineRef impeller::ContentContext::GetSourceATopBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1267 of file content_context.cc.

1268  {
1269  return GetPipeline(this, pipelines_->source_a_top_blend, opts);
1270 }

References pipelines_.

Referenced by GetPorterDuffPipeline().

◆ GetSourceBlendPipeline()

PipelineRef impeller::ContentContext::GetSourceBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1227 of file content_context.cc.

1228  {
1229  return GetPipeline(this, pipelines_->source_blend, opts);
1230 }

References pipelines_.

Referenced by GetPorterDuffPipeline().

◆ GetSourceInBlendPipeline()

PipelineRef impeller::ContentContext::GetSourceInBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1247 of file content_context.cc.

1248  {
1249  return GetPipeline(this, pipelines_->source_in_blend, opts);
1250 }

References pipelines_.

Referenced by GetPorterDuffPipeline().

◆ GetSourceOutBlendPipeline()

PipelineRef impeller::ContentContext::GetSourceOutBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1257 of file content_context.cc.

1258  {
1259  return GetPipeline(this, pipelines_->source_out_blend, opts);
1260 }

References pipelines_.

Referenced by GetPorterDuffPipeline().

◆ GetSourceOverBlendPipeline()

PipelineRef impeller::ContentContext::GetSourceOverBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1237 of file content_context.cc.

1238  {
1239  return GetPipeline(this, pipelines_->source_over_blend, opts);
1240 }

References pipelines_.

Referenced by GetPorterDuffPipeline().

◆ GetSrgbToLinearFilterPipeline()

PipelineRef impeller::ContentContext::GetSrgbToLinearFilterPipeline ( ContentContextOptions  opts) const

Definition at line 1148 of file content_context.cc.

1149  {
1150  return GetPipeline(this, pipelines_->srgb_to_linear_filter, opts);
1151 }

References pipelines_.

◆ GetSweepGradientFillPipeline()

PipelineRef impeller::ContentContext::GetSweepGradientFillPipeline ( ContentContextOptions  opts) const

Definition at line 1098 of file content_context.cc.

1099  {
1100  return GetPipeline(this, pipelines_->sweep_gradient_fill, opts);
1101 }

References pipelines_.

◆ GetSweepGradientSSBOFillPipeline()

PipelineRef impeller::ContentContext::GetSweepGradientSSBOFillPipeline ( ContentContextOptions  opts) const

Definition at line 1061 of file content_context.cc.

1062  {
1063  FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
1064  return GetPipeline(this, pipelines_->sweep_gradient_ssbo_fill, opts);
1065 }

References GetDeviceCapabilities(), and pipelines_.

◆ GetSweepGradientUniformFillPipeline()

PipelineRef impeller::ContentContext::GetSweepGradientUniformFillPipeline ( ContentContextOptions  opts) const

Definition at line 1006 of file content_context.cc.

1007  {
1008  return GetPipeline(this, pipelines_->sweep_gradient_uniform_fill, opts);
1009 }

References pipelines_.

◆ GetTessellator()

Tessellator & impeller::ContentContext::GetTessellator ( ) const

Definition at line 935 of file content_context.cc.

935  {
936  return *tessellator_;
937 }

Referenced by impeller::StrokeRectGeometry::GetPositionBuffer().

◆ GetTextShadowCache()

TextShadowCache& impeller::ContentContext::GetTextShadowCache ( ) const
inline

Definition at line 299 of file content_context.h.

299 { return *text_shadow_cache_; }

Referenced by impeller::DisplayListToTexture(), impeller::RenderToTarget(), and impeller::testing::TEST_P().

◆ GetTexturePipeline()

PipelineRef impeller::ContentContext::GetTexturePipeline ( ContentContextOptions  opts) const

Definition at line 1108 of file content_context.cc.

1109  {
1110  return GetPipeline(this, pipelines_->texture, opts);
1111 }

References pipelines_.

Referenced by impeller::PipelineBlend(), impeller::AtlasContents::Render(), and impeller::TextureContents::Render().

◆ GetTextureStrictSrcPipeline()

PipelineRef impeller::ContentContext::GetTextureStrictSrcPipeline ( ContentContextOptions  opts) const

Definition at line 1113 of file content_context.cc.

1114  {
1115  return GetPipeline(this, pipelines_->texture_strict_src, opts);
1116 }

References pipelines_.

Referenced by impeller::TextureContents::Render().

◆ GetTiledTexturePipeline()

PipelineRef impeller::ContentContext::GetTiledTexturePipeline ( ContentContextOptions  opts) const

Definition at line 1118 of file content_context.cc.

1119  {
1120  return GetPipeline(this, pipelines_->tiled_texture, opts);
1121 }

References pipelines_.

Referenced by impeller::TiledTextureContents::Render().

◆ GetTransientsBuffer()

◆ GetXorBlendPipeline()

PipelineRef impeller::ContentContext::GetXorBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1277 of file content_context.cc.

1278  {
1279  return GetPipeline(this, pipelines_->xor_blend, opts);
1280 }

References pipelines_.

Referenced by GetPorterDuffPipeline().

◆ GetYUVToRGBFilterPipeline()

PipelineRef impeller::ContentContext::GetYUVToRGBFilterPipeline ( ContentContextOptions  opts) const

Definition at line 1162 of file content_context.cc.

1163  {
1164  return GetPipeline(this, pipelines_->yuv_to_rgb_filter, opts);
1165 }

References pipelines_.

◆ IsValid()

bool impeller::ContentContext::IsValid ( ) const

Definition at line 859 of file content_context.cc.

859  {
860  return is_valid_;
861 }

Referenced by impeller::EntityPlayground::OpenPlaygroundHere().

◆ MakeSubpass() [1/2]

fml::StatusOr< RenderTarget > impeller::ContentContext::MakeSubpass ( std::string_view  label,
const RenderTarget subpass_target,
const std::shared_ptr< CommandBuffer > &  command_buffer,
const SubpassCallback subpass_callback 
) const

Makes a subpass that will render to subpass_target.

Definition at line 896 of file content_context.cc.

900  {
901  const std::shared_ptr<Context>& context = GetContext();
902 
903  auto subpass_texture = subpass_target.GetRenderTargetTexture();
904  if (!subpass_texture) {
905  return fml::Status(fml::StatusCode::kUnknown, "");
906  }
907 
908  auto sub_renderpass = command_buffer->CreateRenderPass(subpass_target);
909  if (!sub_renderpass) {
910  return fml::Status(fml::StatusCode::kUnknown, "");
911  }
912  sub_renderpass->SetLabel(label);
913 
914  if (!subpass_callback(*this, *sub_renderpass)) {
915  return fml::Status(fml::StatusCode::kUnknown, "");
916  }
917 
918  if (!sub_renderpass->EncodeCommands()) {
919  return fml::Status(fml::StatusCode::kUnknown, "");
920  }
921 
922  const std::shared_ptr<Texture>& target_texture =
923  subpass_target.GetRenderTargetTexture();
924  if (target_texture->GetMipCount() > 1) {
925  fml::Status mipmap_status =
926  AddMipmapGeneration(command_buffer, context, target_texture);
927  if (!mipmap_status.ok()) {
928  return mipmap_status;
929  }
930  }
931 
932  return subpass_target;
933 }
fml::Status AddMipmapGeneration(const std::shared_ptr< CommandBuffer > &command_buffer, const std::shared_ptr< Context > &context, const std::shared_ptr< Texture > &texture)
Adds a blit command to the render pass.
Definition: texture_util.cc:37

References impeller::AddMipmapGeneration(), GetContext(), and impeller::RenderTarget::GetRenderTargetTexture().

◆ MakeSubpass() [2/2]

fml::StatusOr< RenderTarget > impeller::ContentContext::MakeSubpass ( std::string_view  label,
ISize  texture_size,
const std::shared_ptr< CommandBuffer > &  command_buffer,
const SubpassCallback subpass_callback,
bool  msaa_enabled = true,
bool  depth_stencil_enabled = false,
int32_t  mip_count = 1 
) const

Creates a new texture of size texture_size and calls subpass_callback with a RenderPass for drawing to the texture.

Definition at line 867 of file content_context.cc.

874  {
875  const std::shared_ptr<Context>& context = GetContext();
876  RenderTarget subpass_target;
877 
878  std::optional<RenderTarget::AttachmentConfig> depth_stencil_config =
879  depth_stencil_enabled ? RenderTarget::kDefaultStencilAttachmentConfig
880  : std::optional<RenderTarget::AttachmentConfig>();
881 
882  if (context->GetCapabilities()->SupportsOffscreenMSAA() && msaa_enabled) {
883  subpass_target = GetRenderTargetCache()->CreateOffscreenMSAA(
884  *context, texture_size,
885  /*mip_count=*/mip_count, label,
887  } else {
888  subpass_target = GetRenderTargetCache()->CreateOffscreen(
889  *context, texture_size,
890  /*mip_count=*/mip_count, label,
891  RenderTarget::kDefaultColorAttachmentConfig, depth_stencil_config);
892  }
893  return MakeSubpass(label, subpass_target, command_buffer, subpass_callback);
894 }
fml::StatusOr< RenderTarget > MakeSubpass(std::string_view label, ISize texture_size, const std::shared_ptr< CommandBuffer > &command_buffer, const SubpassCallback &subpass_callback, bool msaa_enabled=true, bool depth_stencil_enabled=false, int32_t mip_count=1) const
Creates a new texture of size texture_size and calls subpass_callback with a RenderPass for drawing t...
const std::shared_ptr< RenderTargetAllocator > & GetRenderTargetCache() const
static constexpr AttachmentConfig kDefaultColorAttachmentConfig
Definition: render_target.h:55
static constexpr AttachmentConfigMSAA kDefaultColorAttachmentConfigMSAA
Definition: render_target.h:61
static constexpr AttachmentConfig kDefaultStencilAttachmentConfig
Definition: render_target.h:68

References GetContext(), GetRenderTargetCache(), impeller::RenderTarget::kDefaultColorAttachmentConfig, impeller::RenderTarget::kDefaultColorAttachmentConfigMSAA, and impeller::RenderTarget::kDefaultStencilAttachmentConfig.

Referenced by impeller::AdvancedBlend(), impeller::PipelineBlend(), and impeller::Contents::RenderToSnapshot().

◆ SetTransientsBuffer()

void impeller::ContentContext::SetTransientsBuffer ( std::shared_ptr< HostBuffer host_buffer)
inlineprotected

Definition at line 303 of file content_context.h.

303  {
304  host_buffer_ = std::move(host_buffer);
305  }

Referenced by impeller::testing::FlushTestContentContext::FlushTestContentContext().


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